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: unassignedb...@nondot.org
          Reporter: spatel+l...@rotateright.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to