[LLVMbugs] [Bug 2993] New: instcombine causes miscompilation with rems -1

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Oct 31 04:13:34 PDT 2008


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

           Summary: instcombine causes miscompilation with rems -1
           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: richard at xmos.com
                CC: llvmbugs at cs.uiuc.edu


Running "opt -instcombine" on the following testcase:

define i1 @main_bb_bb_2E_ce(i32 %i.0.reg2mem.0) {
newFuncRoot:
        br label %bb.ce

bb2.exitStub:           ; preds = %bb.ce
        ret i1 true

codeRepl1.exitStub:             ; preds = %bb.ce
        ret i1 false

bb.ce:          ; preds = %newFuncRoot
        %0 = srem i32 %i.0.reg2mem.0, -1                ; <i32> [#uses=1]
        %1 = icmp eq i32 %0, 0          ; <i1> [#uses=1]
        br i1 %1, label %bb2.exitStub, label %codeRepl1.exitStub
}

turns it into:

define i1 @main_bb_bb_2E_ce(i32 %i.0.reg2mem.0) {
newFuncRoot:
        br label %bb.ce

bb2.exitStub:           ; preds = %bb.ce
        ret i1 true

codeRepl1.exitStub:             ; preds = %bb.ce
        ret i1 false

bb.ce:          ; preds = %newFuncRoot
        %0 = icmp eq i32 %i.0.reg2mem.0, 0              ; <i1> [#uses=1]
        br i1 %0, label %bb2.exitStub, label %codeRepl1.exitStub
}

This transformation is incorrect. Instruction Combine should not be turning

        %0 = srem i32 %i.0.reg2mem.0, -1                ; <i32> [#uses=1]
        %1 = icmp eq i32 %0, 0          ; <i1> [#uses=1]
into 
        %0 = icmp eq i32 %i.0.reg2mem.0, 0              ; <i1> [#uses=1]


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