blob: f12085172680047464a6c81ec5202c72d82b5ced [file] [log] [blame]
Reid Spencera551c042007-04-15 09:21:47 +00001; RUN: llvm-upgrade < %s | llvm-as | opt -simplifycfg | llvm-dis | \
2; RUN: not grep {call void %DEAD}
Chris Lattnerc0968c72005-02-24 06:15:27 +00003
4; Test that we can thread a simple known condition through switch statements.
5
6declare void %foo1()
7declare void %foo2()
8declare void %DEAD()
9
10void %test1(uint %V) {
11 switch uint %V, label %A [
12 uint 4, label %T
13 uint 17, label %Done
14 uint 1234, label %A
15 ]
16
17T: ;; V == 4 if we get here.
18 call void %foo1()
19 ;; This switch is always statically determined.
20 switch uint %V, label %A2 [
21 uint 4, label %B
22 uint 17, label %C
23 uint 42, label %C
24 ]
25A2:
26 call void %DEAD()
27 call void %DEAD()
28 %cond2 = seteq uint %V, 4 ;; always false
29 br bool %cond2, label %Done, label %C
30
31A:
32 call void %foo1()
33 %cond = setne uint %V, 4 ;; always true
34 br bool %cond, label %Done, label %C
35
36
37Done:
38 ret void
39
40B:
41 call void %foo2()
42 %cond3 = seteq uint %V, 4 ;; always true
43 br bool %cond3, label %Done, label %C
44C:
45 call void %DEAD()
46 ret void
47}
48
49void %test2(uint %V) {
50 switch uint %V, label %A [
51 uint 4, label %T
52 uint 17, label %D
53 uint 1234, label %E
54 ]
55
56A: ;; V != 4, 17, 1234 here.
57 call void %foo1()
58 ;; This switch is always statically determined.
59 switch uint %V, label %E [
60 uint 4, label %C
61 uint 17, label %C
62 uint 42, label %D
63 ]
64C:
65 call void %DEAD() ;; unreacahble.
66 ret void
67T:
68 call void %foo1()
69 call void %foo1()
70 ret void
71
72D:
73 call void %foo1()
74 ret void
75
76E:
77 ret void
78}
79