aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/SimplifyCFG/switch_thread.ll
diff options
context:
space:
mode:
authorDan Gohman <djg@cray.com>2007-07-18 16:29:46 +0000
committerDan Gohman <djg@cray.com>2007-07-18 16:29:46 +0000
commitf17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc (patch)
treeebb79ea1ee5e3bc1fdf38541a811a8b804f0679a /test/Transforms/SimplifyCFG/switch_thread.ll
downloadexternal_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.zip
external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.tar.gz
external_llvm-f17a25c88b892d30c2b41ba7ecdfbdfb2b4be9cc.tar.bz2
It's not necessary to do rounding for alloca operations when the requested
alignment is equal to the stack alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/SimplifyCFG/switch_thread.ll')
-rw-r--r--test/Transforms/SimplifyCFG/switch_thread.ll79
1 files changed, 79 insertions, 0 deletions
diff --git a/test/Transforms/SimplifyCFG/switch_thread.ll b/test/Transforms/SimplifyCFG/switch_thread.ll
new file mode 100644
index 0000000..f120851
--- /dev/null
+++ b/test/Transforms/SimplifyCFG/switch_thread.ll
@@ -0,0 +1,79 @@
+; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
+; RUN: not grep {call void %DEAD}
+
+; Test that we can thread a simple known condition through switch statements.
+
+declare void %foo1()
+declare void %foo2()
+declare void %DEAD()
+
+void %test1(uint %V) {
+ switch uint %V, label %A [
+ uint 4, label %T
+ uint 17, label %Done
+ uint 1234, label %A
+ ]
+
+T: ;; V == 4 if we get here.
+ call void %foo1()
+ ;; This switch is always statically determined.
+ switch uint %V, label %A2 [
+ uint 4, label %B
+ uint 17, label %C
+ uint 42, label %C
+ ]
+A2:
+ call void %DEAD()
+ call void %DEAD()
+ %cond2 = seteq uint %V, 4 ;; always false
+ br bool %cond2, label %Done, label %C
+
+A:
+ call void %foo1()
+ %cond = setne uint %V, 4 ;; always true
+ br bool %cond, label %Done, label %C
+
+
+Done:
+ ret void
+
+B:
+ call void %foo2()
+ %cond3 = seteq uint %V, 4 ;; always true
+ br bool %cond3, label %Done, label %C
+C:
+ call void %DEAD()
+ ret void
+}
+
+void %test2(uint %V) {
+ switch uint %V, label %A [
+ uint 4, label %T
+ uint 17, label %D
+ uint 1234, label %E
+ ]
+
+A: ;; V != 4, 17, 1234 here.
+ call void %foo1()
+ ;; This switch is always statically determined.
+ switch uint %V, label %E [
+ uint 4, label %C
+ uint 17, label %C
+ uint 42, label %D
+ ]
+C:
+ call void %DEAD() ;; unreacahble.
+ ret void
+T:
+ call void %foo1()
+ call void %foo1()
+ ret void
+
+D:
+ call void %foo1()
+ ret void
+
+E:
+ ret void
+}
+