summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2011-06-18 10:28:47 +0000
committerHans Wennborg <hans@hanshq.net>2011-06-18 10:28:47 +0000
commit4ab4a8e63a5a99face7d7b523529d3805385c93a (patch)
tree388f435796f21d8e15bfe3031a116d0db6959fe0 /llvm/test
parent54a2c06cf2ca527e9b4456776af83f2a12860da7 (diff)
downloadbcm5719-llvm-4ab4a8e63a5a99face7d7b523529d3805385c93a.tar.gz
bcm5719-llvm-4ab4a8e63a5a99face7d7b523529d3805385c93a.zip
Fix PR10103: Less code for enum type translation.
In cases such as the attached test, where the case value for a switch destination is used in a phi node that follows the destination, it might be better to replace that value with the condition value of the switch, so that more blocks can be folded away with TryToSimplifyUncondBranchFromEmptyBlock because there are less conflicts in the phi node. llvm-svn: 133344
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/ForwardSwitchConditionToPHI.ll36
-rw-r--r--llvm/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll2
2 files changed, 37 insertions, 1 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/ForwardSwitchConditionToPHI.ll b/llvm/test/Transforms/SimplifyCFG/ForwardSwitchConditionToPHI.ll
new file mode 100644
index 00000000000..1b70c065ba3
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/ForwardSwitchConditionToPHI.ll
@@ -0,0 +1,36 @@
+; RUN: opt < %s -simplifycfg -S | \
+; RUN: not grep " switch"
+; PR10131
+
+; ModuleID = '<stdin>'
+target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
+target triple = "i386-pc-linux-gnu"
+
+define i32 @t(i32 %m) nounwind readnone {
+entry:
+ switch i32 %m, label %sw.bb4 [
+ i32 0, label %sw.bb0
+ i32 1, label %sw.bb1
+ i32 2, label %sw.bb2
+ i32 3, label %sw.bb3
+ ]
+
+sw.bb0: ; preds = %entry
+ br label %return
+
+sw.bb1: ; preds = %entry
+ br label %return
+
+sw.bb2: ; preds = %entry
+ br label %return
+
+sw.bb3: ; preds = %entry
+ br label %return
+
+sw.bb4: ; preds = %entry
+ br label %return
+
+return: ; preds = %entry, %sw.bb4, %sw.bb3, %sw.bb2, %sw.bb1
+ %retval.0 = phi i32 [ 4, %sw.bb4 ], [ 3, %sw.bb3 ], [ 2, %sw.bb2 ], [ 1, %sw.bb1 ], [ 0, %sw.bb0 ]
+ ret i32 %retval.0
+}
diff --git a/llvm/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll b/llvm/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll
index 7d7391af1b9..343e169edc2 100644
--- a/llvm/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll
+++ b/llvm/test/Transforms/SimplifyCFG/switch_switch_fold_dbginfo.ll
@@ -1,5 +1,5 @@
; RUN: opt < %s -simplifycfg -S | \
-; RUN: grep switch | count 1
+; RUN: not grep " switch"
; ModuleID = '<stdin>'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
OpenPOWER on IntegriCloud