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