[llvm-bugs] [Bug 31176] New: [PowerPC] could have used a CR-setting subtract

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Nov 27 16:09:09 PST 2016


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

            Bug ID: 31176
           Summary: [PowerPC] could have used a CR-setting subtract
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

; ret = x > y ? x-y : 0
define i32 @max(i32 %x, i32 %y) {
  %sub = sub nsw i32 %x, %y
  %cmp = icmp sgt i32 %x, %y
  %sel = select i1 %cmp, i32 %sub, i32 0
  ret i32 %sel
}

$ ./llc -o - max.ll -mtriple=powerpc64 -mattr=isel
    subf 5, 4, 3    <--- use "subf."
    cmpw 0, 3, 4    <--- and eliminate this cmp
    li 3, 0
    isel 3, 5, 3, 1
    blr


There's a 2nd potential bug in this example: the 'li' could be removed because
isel RT,RA,RB,BC with RA=0 treats r0 as a zero operand?

-- 
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/20161128/3192a91f/attachment.html>


More information about the llvm-bugs mailing list