diff options
author | Hans Wennborg <hans@hanshq.net> | 2012-10-30 11:23:25 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2012-10-30 11:23:25 +0000 |
commit | 04d7d13d301df66f6c232e41611145c062183bf3 (patch) | |
tree | 506f923fd1e30024c1b3be9b63fcdb46f52d1f1b /test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll | |
parent | c588e0e162fa08c81558871fb0c50fb51569afe3 (diff) | |
download | external_llvm-04d7d13d301df66f6c232e41611145c062183bf3.zip external_llvm-04d7d13d301df66f6c232e41611145c062183bf3.tar.gz external_llvm-04d7d13d301df66f6c232e41611145c062183bf3.tar.bz2 |
Use TargetTransformInfo to control switch-to-lookup table transformation
When the switch-to-lookup tables transform landed in SimplifyCFG, it
was pointed out that this could be inappropriate for some targets.
Since there was no way at the time for the pass to know anything about
the target, an awkward reverse-transform was added in CodeGenPrepare
that turned lookup tables back into switches for some targets.
This patch uses the new TargetTransformInfo to determine if a
switch should be transformed, and removes
CodeGenPrepare::ConvertLoadToSwitch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167011 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll')
-rw-r--r-- | test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll b/test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll new file mode 100644 index 0000000..9d15685 --- /dev/null +++ b/test/Transforms/SimplifyCFG/SPARC/switch_to_lookup_table.ll @@ -0,0 +1,32 @@ +; RUN: opt < %s -simplifycfg -S -mtriple=sparc-unknown-unknown | FileCheck %s + +; Check that switches are not turned into lookup tables, as this is not +; considered profitable on the target. + +define i32 @f(i32 %c) nounwind uwtable readnone { +entry: + switch i32 %c, label %sw.default [ + i32 42, label %return + i32 43, label %sw.bb1 + i32 44, label %sw.bb2 + i32 45, label %sw.bb3 + i32 46, label %sw.bb4 + i32 47, label %sw.bb5 + i32 48, label %sw.bb6 + ] + +sw.bb1: br label %return +sw.bb2: br label %return +sw.bb3: br label %return +sw.bb4: br label %return +sw.bb5: br label %return +sw.bb6: br label %return +sw.default: br label %return +return: + %retval.0 = phi i32 [ 15, %sw.default ], [ 1, %sw.bb6 ], [ 62, %sw.bb5 ], [ 27, %sw.bb4 ], [ -1, %sw.bb3 ], [ 0, %sw.bb2 ], [ 123, %sw.bb1 ], [ 55, %entry ] + ret i32 %retval.0 + +; CHECK: @f +; CHECK-NOT: getelementptr +; CHECK: switch i32 %c +} |