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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [email protected]


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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to