https://bugs.llvm.org/show_bug.cgi?id=32442

            Bug ID: 32442
           Summary: [ppc] redundant zero extension when returning bool
                    value
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Compile the following code with options -m64 -O2 -mvsx -mcpu=power8

bool foo(int i, int* p) {
  if (i==0)
    return false;

  *p = i;
  return true;
}


LLVM generates:

_Z3fooiPi:                              # @_Z3fooiPi
.Lfunc_begin0:
# BB#0:                                 # %entry
        cmplwi   3, 0
        beq      0, .LBB0_2
# BB#1:                                 # %if.end
        stw 3, 0(4)
        li 3, 1
        clrldi   3, 3, 32           // redundant
        blr
.LBB0_2:
        li 3, 0
        clrldi   3, 3, 32           // redundant
        blr


The problem is when PPCBoolRetToInt.cpp converts the old the old cmp/isel
behavior into today's integer operation, it uses  i32 type, on ppc64, it needs
to be zero extended to 64bit before return. We should use i64 on ppc64 and i32
on ppc32.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to