[llvm-bugs] [Bug 31065] New: [ppc] ISEL instruction should take advantage r0=0 if it is the first src operand

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 18 14:22:29 PST 2016


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

            Bug ID: 31065
           Summary: [ppc] ISEL instruction should take advantage r0=0 if
                    it is the first src operand
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: carrot at google.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Compile the source code with options -m64 -O2

bool foo(int a, int b)
{
  return a > b;
}

bool bar(int a, int b)
{
  return a < b;
}

I got

_Z3fooii:                               # @_Z3fooii
.Lfunc_begin0:
# BB#0:                                 # %entry
        li 5, 0                           // unnecessary
        cmpw 0, 3, 4
        li 12, 1
        isel 3, 12, 5, 1                  // isel 3, 0, 12, 0
        blr

_Z3barii:                               # @_Z3barii
.Lfunc_begin1:
# BB#0:                                 # %entry
        li 5, 0                           // unnecessary
        cmpw 0, 3, 4
        li 12, 1
        isel 3, 12, 5, 0                  // isel 3, 0, 12, 1
        blr


For ISEL instruction, if r0 is the first source operand, it is treated as 0. So
we can change the generated instructions as in comments, then "li 5, 0" can be
removed.
There are more complex cases that involves composition of several comparisons
and cross BBs.

-- 
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/20161118/6d49a747/attachment.html>


More information about the llvm-bugs mailing list