summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2013-06-29 23:44:53 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2013-06-29 23:44:53 +0000
commit58b6dc032a668e637a9a9e63290652f32d372a5f (patch)
tree85da3febc257d052ac3db7aaade17e71b867acd6 /test/Transforms
parentbebf6222f6b7cc871cfbc51f78cdb33d17fedb6c (diff)
ValueTracking: Teach isKnownToBeAPowerOfTwo about (ADD X, (XOR X, Y)) where X is a power of two
This allows us to simplify urem instructions involving the add+xor to turn into simpler math. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/rem.ll15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/rem.ll b/test/Transforms/InstCombine/rem.ll
index 808d51eba1d..2b49385b922 100644
--- a/test/Transforms/InstCombine/rem.ll
+++ b/test/Transforms/InstCombine/rem.ll
@@ -163,3 +163,18 @@ define i32 @test16(i32 %x, i32 %y) {
%rem = urem i32 %x, %add
ret i32 %rem
}
+
+define i32 @test17(i16 %x, i32 %y) {
+; CHECK: @test17
+; CHECK-NEXT: [[AND:%.*]] = and i16 %x, 4
+; CHECK-NEXT: [[EXT:%.*]] = zext i16 [[AND]] to i32
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i32 [[EXT]], 3
+; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[SHL]], 63
+; CHECK-NEXT: [[REM:%.*]] = and i32 [[XOR]], %y
+; CHECK-NEXT: ret i32 [[REM]]
+ %1 = and i16 %x, 4
+ %2 = icmp ne i16 %1, 0
+ %3 = select i1 %2, i32 32, i32 64
+ %4 = urem i32 %y, %3
+ ret i32 %4
+}