[LLVMbugs] [Bug 3142] New: Invalid instcombine of (-X)/-3

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Fri Nov 28 23:47:32 PST 2008


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

           Summary: Invalid instcombine of (-X)/-3
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Windows NT
            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


Originally reported in bug 1931, but I apparently missed the following issue:

define i32 @a(i32 %X) nounwind readnone {
entry:
        %0 = sub i32 0, %X
        %1 = sdiv i32 %0, -3
        ret i32 %1
}

define i32 @b(i32 %X) nounwind readnone {
entry:
        %0 = call i32 @a(i32 -2147483648)
        ret i32 %0
}

define i32 @c(i32 %X) nounwind readnone {
entry:
        %0 = sub i32 0, -2147483648
        %1 = sdiv i32 %0, -3
        ret i32 %1
}

Run through opt -instcombine -inline, functions b and c return different
results.  This is the result of illegally combining (-X)/-3 to X/3: the
transformation is only valid when the negation doesn't overflow.


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