summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/shift-combine.ll
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2015-06-26 14:51:36 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2015-06-26 14:51:36 +0000
commit07e70b4fa4d6e2504fcd3d6c0b0415e378b937eb (patch)
tree7470eb8033b880cfff580626efd7453d1e168602 /llvm/test/CodeGen/X86/shift-combine.ll
parenta17cbff2f6987dc3862ffdfd50aa9cb5dd12b984 (diff)
downloadbcm5719-llvm-07e70b4fa4d6e2504fcd3d6c0b0415e378b937eb.tar.gz
bcm5719-llvm-07e70b4fa4d6e2504fcd3d6c0b0415e378b937eb.zip
[DAGCombine] fold (X >>?,exact C1) << C2 --> X << (C2-C1)
Instcombine also does this but many opportunities only become visible after GEPs are lowered. llvm-svn: 240787
Diffstat (limited to 'llvm/test/CodeGen/X86/shift-combine.ll')
-rw-r--r--llvm/test/CodeGen/X86/shift-combine.ll49
1 files changed, 49 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/shift-combine.ll b/llvm/test/CodeGen/X86/shift-combine.ll
index ec62bcdcdba..7fb19a6cad0 100644
--- a/llvm/test/CodeGen/X86/shift-combine.ll
+++ b/llvm/test/CodeGen/X86/shift-combine.ll
@@ -17,3 +17,52 @@ entry:
ret i32 %tmp5
}
+define i32* @test_exact1(i32 %a, i32 %b, i32* %x) {
+; CHECK-LABEL: test_exact1:
+; CHECK: sarl %
+
+ %sub = sub i32 %b, %a
+ %shr = ashr exact i32 %sub, 3
+ %gep = getelementptr inbounds i32, i32* %x, i32 %shr
+ ret i32* %gep
+}
+
+define i32* @test_exact2(i32 %a, i32 %b, i32* %x) {
+; CHECK-LABEL: test_exact2:
+; CHECK: sarl %
+
+ %sub = sub i32 %b, %a
+ %shr = ashr exact i32 %sub, 3
+ %gep = getelementptr inbounds i32, i32* %x, i32 %shr
+ ret i32* %gep
+}
+
+define i32* @test_exact4(i32 %a, i32 %b, i32* %x) {
+; CHECK-LABEL: test_exact4:
+; CHECK: shrl %
+
+ %sub = sub i32 %b, %a
+ %shr = lshr exact i32 %sub, 3
+ %gep = getelementptr inbounds i32, i32* %x, i32 %shr
+ ret i32* %gep
+}
+
+define i32* @test_exact5(i32 %a, i32 %b, i32* %x) {
+; CHECK-LABEL: test_exact5:
+; CHECK: shrl %
+
+ %sub = sub i32 %b, %a
+ %shr = lshr exact i32 %sub, 3
+ %gep = getelementptr inbounds i32, i32* %x, i32 %shr
+ ret i32* %gep
+}
+
+define i32* @test_exact6(i32 %a, i32 %b, i32* %x) {
+; CHECK-LABEL: test_exact6:
+; CHECK-NOT: shrl
+
+ %sub = sub i32 %b, %a
+ %shr = lshr exact i32 %sub, 2
+ %gep = getelementptr inbounds i32, i32* %x, i32 %shr
+ ret i32* %gep
+}
OpenPOWER on IntegriCloud