Closed
Description
Bugzilla Link | 20681 |
Resolution | FIXED |
Resolved on | Aug 16, 2014 03:55 |
Version | trunk |
OS | Linux |
Reporter | LLVM Bugzilla Contributor |
CC | @majnemer |
Extended Description
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 x/3.
Testcases:
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
}