[LLVMbugs] [Bug 8862] New: instcombine shouldn't canonicalize 'sdiv exact' into ashr

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Dec 26 15:50:12 PST 2010


           Summary: instcombine shouldn't canonicalize 'sdiv exact' into
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: clattner at apple.com
                CC: llvmbugs at cs.uiuc.edu

Instcombine should compile this identity function to return X:

define i32 @test(i32 %X) {
  %A = sdiv exact i32 %X, 4
  %B = mul i32 %A, 4
  ret i32 %B

instead we get:

define i32 @test(i32 %X) {
  %A1 = and i32 %X, -4
  ret i32 %A1

This is because it simplifies the sdiv into an ashr instruction, which loses
information.  This sort of thing comes up when handling array/pointer
difference stuff.

To fix this, SDISel whould lower sdiv exact into ashr, instcombine should
handle sdiv's as aggressively as ashr's, and then we should stop canonicalizing
ashr to sdiv in instcombine.

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