[llvm-bugs] [Bug 32520] New: [PowerPC] icmp ne 0 can be implemented using the carry bit
    via llvm-bugs 
    llvm-bugs at lists.llvm.org
       
    Tue Apr  4 06:47:51 PDT 2017
    
    
  
https://bugs.llvm.org/show_bug.cgi?id=32520
            Bug ID: 32520
           Summary: [PowerPC] icmp ne 0 can be implemented using the carry
                    bit
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: PowerPC
          Assignee: unassignedbugs at nondot.org
          Reporter: spatel+llvm at rotateright.com
                CC: llvm-bugs at lists.llvm.org
I noticed this opportunity in https://reviews.llvm.org/D31483.
This is from "Optimal Code Sequences" P. 200 of the Compiler Writer's Guide:
ne: not equal to r = v0 != v1;
subf R5,R3,R4 
addic R6,R5,-1 
subfe R7,R6,R5
define zeroext i1 @ne0(i32 %x) {
  %cmp = icmp ne i32 %x, 0
  ret i1 %cmp
}
Currently (r299396), the PPC backend seems to choose a cntlzw variant for all
compares against zero:
$ ./llc ne0.ll -o - -mtriple=powerpc64
        cntlzw 3, 3
        nor 3, 3, 3  <-- extended mnemonic for "not" would be nicer!
        rlwinm 3, 3, 27, 31, 31
I don't know anything about recent PPC uarch, so this may not be faster, but it
is smaller:
addic 4, 3, -1
subfe 3, 4, 3
-- 
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/20170404/f848c5a0/attachment.html>
    
    
More information about the llvm-bugs
mailing list