summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/and.ll
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2017-01-17 00:45:57 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2017-01-17 00:45:57 +0000
commit36d382b773bd83daf7304e3a5d11a828e3316e2c (patch)
treec2e98b8f5765991398253af319c619dcc643430e /llvm/test/Transforms/InstCombine/and.ll
parentc8cc2be9f847a8c81ae9f97009b4af1e71eb6e1f (diff)
downloadbcm5719-llvm-36d382b773bd83daf7304e3a5d11a828e3316e2c.tar.gz
bcm5719-llvm-36d382b773bd83daf7304e3a5d11a828e3316e2c.zip
[InstCombine] Fold ((C1-zext(X)) & C2) -> zext((C1-X) & C2)
This is valid if C2 fits within the bitwidth of X thanks to two's complement modulo arithmetic. llvm-svn: 292179
Diffstat (limited to 'llvm/test/Transforms/InstCombine/and.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/and.ll11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/and.ll b/llvm/test/Transforms/InstCombine/and.ll
index e45012878ed..ee1dfbbe12e 100644
--- a/llvm/test/Transforms/InstCombine/and.ll
+++ b/llvm/test/Transforms/InstCombine/and.ll
@@ -425,3 +425,14 @@ define <2 x i32> @PR24942(<2 x i32> %x) {
ret <2 x i32> %and
}
+define i64 @test35(i32 %X) {
+; CHECK-LABEL: @test35(
+; CHECK-NEXT: %[[sub:.*]] = sub i32 0, %X
+; CHECK-NEXT: %[[and:.*]] = and i32 %[[sub]], 240
+; CHECK-NEXT: %[[cst:.*]] = zext i32 %[[and]] to i64
+; CHECK-NEXT: ret i64 %[[cst]]
+ %zext = zext i32 %X to i64
+ %zsub = sub i64 0, %zext
+ %res = and i64 %zsub, 240
+ ret i64 %res
+}
OpenPOWER on IntegriCloud