diff options
author | David Majnemer <david.majnemer@gmail.com> | 2013-05-12 00:07:05 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2013-05-12 00:07:05 +0000 |
commit | fa49d7d6e4384381e4307a0d2495e6e5b15821e3 (patch) | |
tree | fbab3795f1f20e90c81c010d2a598576d73ed6f0 /test/Transforms/InstCombine | |
parent | 9b5d70f07630f99f1ec5589aeaba96c6d8ab0aee (diff) | |
download | external_llvm-fa49d7d6e4384381e4307a0d2495e6e5b15821e3.zip external_llvm-fa49d7d6e4384381e4307a0d2495e6e5b15821e3.tar.gz external_llvm-fa49d7d6e4384381e4307a0d2495e6e5b15821e3.tar.bz2 |
InstCombine: Flip the order of two urem transforms
There are two transforms in visitUrem that conflict with each other.
*) One, if a divisor is a power of two, subtracts one from the divisor
and turns it into a bitwise-and.
*) The other unwraps both operands if they are surrounded by zext
instructions.
Flipping the order allows the subtraction to go beneath the sign
extension.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181668 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine')
-rw-r--r-- | test/Transforms/InstCombine/rem.ll | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll index 9b8b98a..450a62a 100644 --- a/test/Transforms/InstCombine/rem.ll +++ b/test/Transforms/InstCombine/rem.ll @@ -135,3 +135,17 @@ define i64 @test14(i64 %x, i32 %y) { %urem = urem i64 %x, %zext ret i64 %urem } + +define i64 @test15(i32 %x, i32 %y) { +; CHECK: @test15 +; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 1, %y +; CHECK-NEXT: [[ADD:%.*]] = add i32 [[SHL]], -1 +; CHECK-NEXT: [[AND:%.*]] = and i32 [[ADD]], %x +; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[AND]] to i64 +; CHECK-NEXT: ret i64 [[ZEXT]] + %shl = shl i32 1, %y + %zext0 = zext i32 %shl to i64 + %zext1 = zext i32 %x to i64 + %urem = urem i64 %zext1, %zext0 + ret i64 %urem +} |