[LLVMbugs] [Bug 20681] New: missed optz'n in mul+div

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 15 15:30:13 PDT 2014


            Bug ID: 20681
           Summary: missed optz'n in mul+div
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: david.majnemer at gmail.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

I noticed this when looking at some vectorized code. We turned the shift+divide
into vector shift and vector divide. It was doing x<<2/12, which is really just


define i32 @test1(i32 %a) {
  %A = shl nsw i32 %a, 2
  %B = sdiv i32 %A, 12
; CHECK: %B = sdiv i32 %a, 3
  ret i32 %B

define i32 @test2(i32 %a) {
  %A = mul nsw i32 %a, 3
  %B = sdiv i32 %A, 12
; CHECK: %B = sdiv i32 %a, 4  ;; we don't simplify that to ashr?
  ret i32 %B

define i32 @test3(i32 %a) {
  %A = shl nuw i32 %a, 2
  %B = udiv i32 %A, 12
; CHECK: %B = udiv i32 %a, 3
  ret i32 %B

define i32 @test4(i32 %a) {
  %A = mul nuw i32 %a, 3
  %B = udiv i32 %A, 12
; CHECK: %B = lshr i32 %a, 2
  ret i32 %B

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140815/41ffbe2b/attachment.html>

More information about the llvm-bugs mailing list