summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-05-12 00:07:05 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-05-12 00:07:05 +0000
commit6c30f49af39da4c39cdab5f303f57f4809218b41 (patch)
treeeb372f6198fa0992596c4b53c3cd5c3cbba3c94a /llvm/test/Transforms
parentf2305e44675390adc80bae4834672132c12686f5 (diff)
downloadbcm5719-llvm-6c30f49af39da4c39cdab5f303f57f4809218b41.tar.gz
bcm5719-llvm-6c30f49af39da4c39cdab5f303f57f4809218b41.zip
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. llvm-svn: 181668
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstCombine/rem.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/rem.ll b/llvm/test/Transforms/InstCombine/rem.ll
index 9b8b98a1708..450a62ae6de 100644
--- a/llvm/test/Transforms/InstCombine/rem.ll
+++ b/llvm/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
+}
OpenPOWER on IntegriCloud