summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2012-11-07 21:35:12 +0000
committerHans Wennborg <hans@hanshq.net>2012-11-07 21:35:12 +0000
commitc3c8d95c51f3741c4d864a0cccf203d4e6c9147d (patch)
treec41dca67ac2be5799cf7d4a602d0b8e22d70e52c
parentefa45b2508bc25c7ae8fd2ea855b5e4c17276a6b (diff)
downloadbcm5719-llvm-c3c8d95c51f3741c4d864a0cccf203d4e6c9147d.tar.gz
bcm5719-llvm-c3c8d95c51f3741c4d864a0cccf203d4e6c9147d.zip
Only do switch-to-lookup table transformation when TargetTransformInfo
is available. llvm-svn: 167552
-rw-r--r--llvm/lib/Transforms/Utils/SimplifyCFG.cpp3
-rw-r--r--llvm/test/Transforms/SimplifyCFG/X86/lit.local.cfg6
-rw-r--r--llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll (renamed from llvm/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll)2
-rw-r--r--llvm/test/Transforms/SimplifyCFG/switch_create.ll5
4 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 9823433e861..b33d0d473b1 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3538,7 +3538,8 @@ static bool SwitchToLookupTable(SwitchInst *SI,
const TargetTransformInfo *TTI) {
assert(SI->getNumCases() > 1 && "Degenerate switch?");
- if (TTI && !TTI->getScalarTargetTransformInfo()->shouldBuildLookupTables())
+ // Only build lookup table when we have a target that supports it.
+ if (!TTI || !TTI->getScalarTargetTransformInfo()->shouldBuildLookupTables())
return false;
// FIXME: If the switch is too sparse for a lookup table, perhaps we could
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/lit.local.cfg b/llvm/test/Transforms/SimplifyCFG/X86/lit.local.cfg
new file mode 100644
index 00000000000..a8ad0f1a28b
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/X86/lit.local.cfg
@@ -0,0 +1,6 @@
+config.suffixes = ['.ll', '.c', '.cpp']
+
+targets = set(config.root.targets_to_build.split())
+if not 'X86' in targets:
+ config.unsupported = True
+
diff --git a/llvm/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
index 0f5eb6a135d..8a59992f5e6 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_to_lookup_table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -simplifycfg -S | FileCheck %s
+; RUN: opt < %s -simplifycfg -S -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/llvm/test/Transforms/SimplifyCFG/switch_create.ll b/llvm/test/Transforms/SimplifyCFG/switch_create.ll
index b28e4a45509..546cc75f297 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_create.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch_create.ll
@@ -141,9 +141,8 @@ UnifiedReturnBlock: ; preds = %shortcirc_done.4, %shortcirc_next.4
ret i1 %UnifiedRetVal
; CHECK: @test6
-; CHECK: %switch.tableidx = sub i32 %tmp.2.i, 14
-; CHECK: %0 = icmp ult i32 %switch.tableidx, 6
-; CHECK: select i1 %0, i1 true, i1 false
+; CHECK: %tmp.2.i.off = add i32 %tmp.2.i, -14
+; CHECK: %switch = icmp ult i32 %tmp.2.i.off, 6
}
define void @test7(i8 zeroext %c, i32 %x) nounwind ssp noredzone {
OpenPOWER on IntegriCloud