summaryrefslogtreecommitdiff
path: root/test/Transforms/GVN
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-10-07 08:29:06 +0000
committerDuncan Sands <baldrick@free.fr>2011-10-07 08:29:06 +0000
commit3f329cb781492e19a72af267cd3b7c2d8307a818 (patch)
tree2332fd912c30ef02c25f5187751796d9979b99cb /test/Transforms/GVN
parent75fe5f3bab7c33c14e5f7956e01a9d95d2712cc5 (diff)
downloadllvm-3f329cb781492e19a72af267cd3b7c2d8307a818.tar.gz
llvm-3f329cb781492e19a72af267cd3b7c2d8307a818.tar.bz2
llvm-3f329cb781492e19a72af267cd3b7c2d8307a818.tar.xz
Teach GVN to also propagate switch cases. For example, in this code
switch (n) { case 27: do_something(x); ... } the call do_something(x) will be replaced with do_something(27). In gcc-as-one-big-file this results in the removal of about 500 lines of bitcode (about 0.02%), so has about 1/10 of the effect of propagating branch conditions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN')
-rw-r--r--test/Transforms/GVN/condprop.ll33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Transforms/GVN/condprop.ll b/test/Transforms/GVN/condprop.ll
index 705490b67f..0b31b01b7b 100644
--- a/test/Transforms/GVN/condprop.ll
+++ b/test/Transforms/GVN/condprop.ll
@@ -97,3 +97,36 @@ nope:
; CHECK: call void @foo(i1 false)
ret void
}
+
+; CHECK: @test4
+define void @test4(i1 %b, i32 %x) {
+ br i1 %b, label %sw, label %case3
+sw:
+ switch i32 %x, label %default [
+ i32 0, label %case0
+ i32 1, label %case1
+ i32 2, label %case0
+ i32 3, label %case3
+ i32 4, label %default
+ ]
+default:
+; CHECK: default:
+ call void @bar(i32 %x)
+; CHECK: call void @bar(i32 %x)
+ ret void
+case0:
+; CHECK: case0:
+ call void @bar(i32 %x)
+; CHECK: call void @bar(i32 %x)
+ ret void
+case1:
+; CHECK: case1:
+ call void @bar(i32 %x)
+; CHECK: call void @bar(i32 1)
+ ret void
+case3:
+; CHECK: case3:
+ call void @bar(i32 %x)
+; CHECK: call void @bar(i32 %x)
+ ret void
+}