[LLVMbugs] [Bug 2506] New: Invalid instcombine with select+div

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jun 29 14:42:46 PDT 2008


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

           Summary: Invalid instcombine with select+div
           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


Testcase:
define i32 @a(i32 %x, i32 %y) {
entry:
        %tobool = icmp ne i32 %y, 0             ; <i1> [#uses=1]
        %cond = select i1 %tobool, i32 5, i32 0         ; <i32> [#uses=2]
        %call = call i32 @b( i32 %cond )                ; <i32> [#uses=0]
        %div = sdiv i32 %x, %cond               ; <i32> [#uses=1]
        ret i32 %div
}

declare i32 @b(i32)

Run through opt -instcombine produces:

define i32 @a(i32 %x, i32 %y) {
entry:
        %call = call i32 @b( i32 5 )            ; <i32> [#uses=0]
        %div = sdiv i32 %x, 5           ; <i32> [#uses=1]
        ret i32 %div
}

declare i32 @b(i32)

This optimization is wrong because it assumes that b eventually returns, which
is not guaranteed.


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