[LLVMbugs] [Bug 2298] New: Missed optimization: should instcombine icmp ~A, ~B to icmp B, A

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu May 8 01:00:09 PDT 2008


http://llvm.org/bugs/show_bug.cgi?id=2298

           Summary: Missed optimization: should instcombine icmp ~A, ~B to
                    icmp B, A
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


Pretty simple bug: int a(int a, int b) {return ~a < ~b;} currently outputs the
following:
define i32 @a(i32 %a, i32 %b) nounwind  {
entry:
        %tmp1not = xor i32 %a, -1               ; <i32> [#uses=1]
        %tmp2not = xor i32 %b, -1               ; <i32> [#uses=1]
        %tmp3 = icmp slt i32 %tmp1not, %tmp2not         ; <i1> [#uses=1]
        %tmp34 = zext i1 %tmp3 to i32           ; <i32> [#uses=1]
        ret i32 %tmp34
}

It should output the following:
define i32 @a(i32 %a, i32 %b) nounwind  {
entry:
        %tmp3 = icmp slt i32 %b, %a             ; <i1> [#uses=1]
        %tmp34 = zext i1 %tmp3 to i32           ; <i32> [#uses=1]
        ret i32 %tmp34
}

Not an especially useful instcombine, but it's extremely cheap to implement.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list