diff options
author | Duncan Sands <baldrick@free.fr> | 2011-10-07 08:29:06 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2011-10-07 08:29:06 +0000 |
commit | 3f329cb781492e19a72af267cd3b7c2d8307a818 (patch) | |
tree | 2332fd912c30ef02c25f5187751796d9979b99cb /test/Transforms/GVN/condprop.ll | |
parent | 75fe5f3bab7c33c14e5f7956e01a9d95d2712cc5 (diff) | |
download | external_llvm-3f329cb781492e19a72af267cd3b7c2d8307a818.zip external_llvm-3f329cb781492e19a72af267cd3b7c2d8307a818.tar.gz external_llvm-3f329cb781492e19a72af267cd3b7c2d8307a818.tar.bz2 |
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/condprop.ll')
-rw-r--r-- | test/Transforms/GVN/condprop.ll | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/Transforms/GVN/condprop.ll b/test/Transforms/GVN/condprop.ll index 705490b..0b31b01 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 +} |