[LLVMbugs] [Bug 5634] New: Missed optimisation on comparisons to 0 becoming ORs

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sat Nov 28 10:31:13 PST 2009


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

           Summary: Missed optimisation on comparisons to 0 becoming ORs
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: arplynn at gmail.com
                CC: llvmbugs at cs.uiuc.edu


The following IR:

define void @bar(i32 %left, i32 %right) nounwind {
  %1 = icmp eq i32 %left, 0                       ; <i1> [#uses=1]
  %2 = icmp eq i32 %right, 0                      ; <i1> [#uses=1]
  %or.cond = and i1 %2, %1                        ; <i1> [#uses=1]
  br i1 %or.cond, label %3, label %4

; <label>:3                                       ; preds = %0
  tail call void (...)* @foo() nounwind
  ret void

; <label>:4                                       ; preds = %0
  ret void
}

declare void @foo(...) nounwind

generates this (x86_64):

_bar:                                                       ## @bar
## BB#0:
        subq    $8, %rsp
        testl   %esi, %esi
        jne     LBB1_3
## BB#1:
        testl   %edi, %edi
        jne     LBB1_3
## BB#2:
        call    _foo
LBB1_3:
        addq    $8, %rsp
        ret

which could be simplified to:

_bar:                                                       ## @bar
## BB#0:
        subq $8, %rsp
        orl %esi, %edi
        jnz LBB1_3
## BB#2:
        call _foo
LBB1_3:
        addq $8, %rsp
        ret


-- 
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