1 ; Basic testcases - these are only tested by inspection, but illustrate the
2 ; basic cases PRE can handle.
4 ; RUN: llvm-as < %s | opt -pre -disable-output
9 void %test0(int %A, int %B) { ;; Fully redundant
12 call void %use(int %X)
13 call void %use(int %Y)
17 void %test1(int %cond, int %A, int %B) {
18 switch int %cond, label %Out [
24 call void %use(int %X1)
28 call void %use(int %X2)
36 call void %use(int %X3)
44 void %testloop(bool %cond, int %A, int %B) {
48 %C = add int %A, %B ; loop invariant
49 call void %use(int %C)
52 call void %use(int %D)
54 br bool %cond, label %Loop, label %Exit
61 void %test3(bool %cond, int %A, int %B) {
62 br bool %cond, label %A, label %B
66 call void %use(int %C)
70 call void %use(int %D)
75 call void %use(int %E)
79 void %test4(bool %cond, int %A, int %B) {
80 br bool %cond, label %A, label %B
86 call void %use(int %D)
91 call void %use(int %E)
96 int %test5(bool %cond, int %A, int %B) {
100 br bool %cond, label %A, label %B
106 call void %use(int %D)
110 br bool %cond, label %Loop, label %Out
118 void %test6(bool %cond, int %A, int %B) {
119 br bool %cond, label %A1, label %Def
123 call void %use(int %C)
124 br bool %cond, label %F1, label %F2
132 call void %use(int %D)
136 void %testloop-load(bool %cond, int* %P, int* %Q) {
140 store int 5, int* %Q ;; Q may alias P
141 %D = load int* %P ;; Should not hoist load out of loop
142 call void %use(int %D)
144 br bool %cond, label %Loop, label %Exit
149 void %test7(bool %cond) { ;; Test anticipatibility
154 %B = add int %A, %A ; Cannot hoist from loop
155 call void %use(int %B)
157 br bool %cond, label %Loop, label %Exit
163 void %test8(bool %cond, int %A, int %B) { ;; Test irreducible loop
164 br bool %cond, label %LoopHead, label %LoopMiddle
167 %C = add int %A, %B ; Should hoist from loop
168 call void %use(int %C)
173 br bool %cond, label %LoopHead, label %Exit
176 call void %use(int %D)
181 void %test9(bool %cond, int %A, int %B) { ;; Test irreducible loop
182 br bool %cond, label %LoopHead, label %LoopMiddle
185 call int %get() ; random function call
189 %C = add int %A, %B ; Should hoist from loop
190 call void %use(int %C)
191 br bool %cond, label %LoopHead, label %Exit