[llvm-bugs] [Bug 32442] New: [ppc] redundant zero extension when returning bool value

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 27 14:45:04 PDT 2017


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: unassignedbugs at nondot.org
          Reporter: carrot at google.com
                CC: llvm-bugs at lists.llvm.org

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170327/24fb6501/attachment.html>


More information about the llvm-bugs mailing list