1 ; RUN: opt -S -basicaa -licm %s | FileCheck %s
2 ; RUN: opt -aa-pipeline=basic-aa -passes='require<aa>,require<targetir>,require<scalar-evolution>,require<opt-remark-emit>,loop(licm)' < %s -S | FileCheck %s
4 declare i32 @load(i32* %p) argmemonly readonly nounwind
6 define void @test_load(i32* noalias %loc, i32* noalias %sink) {
7 ; CHECK-LABEL: @test_load
9 ; CHECK: call i32 @load
15 %iv = phi i32 [0, %entry], [%iv.next, %loop]
16 %ret = call i32 @load(i32* %loc)
17 store volatile i32 %ret, i32* %sink
18 %iv.next = add i32 %iv, 1
19 %cmp = icmp slt i32 %iv, 200
20 br i1 %cmp, label %loop, label %exit
27 declare void @store(i32 %val, i32* %p) argmemonly writeonly nounwind
29 define void @test(i32* %loc) {
32 ; CHECK: call void @store
38 %iv = phi i32 [0, %entry], [%iv.next, %loop]
39 call void @store(i32 0, i32* %loc)
40 %iv.next = add i32 %iv, 1
41 %cmp = icmp slt i32 %iv, 200
42 br i1 %cmp, label %loop, label %exit
48 define void @test_multiexit(i32* %loc, i1 %earlycnd) {
49 ; CHECK-LABEL: @test_multiexit
51 ; CHECK: call void @store
52 ; CHECK-LABEL: backedge:
57 %iv = phi i32 [0, %entry], [%iv.next, %backedge]
58 call void @store(i32 0, i32* %loc)
59 %iv.next = add i32 %iv, 1
60 br i1 %earlycnd, label %exit1, label %backedge
63 %cmp = icmp slt i32 %iv, 200
64 br i1 %cmp, label %loop, label %exit2
72 define void @neg_lv_value(i32* %loc) {
73 ; CHECK-LABEL: @neg_lv_value
75 ; CHECK: call void @store
81 %iv = phi i32 [0, %entry], [%iv.next, %loop]
82 call void @store(i32 %iv, i32* %loc)
83 %iv.next = add i32 %iv, 1
84 %cmp = icmp slt i32 %iv, 200
85 br i1 %cmp, label %loop, label %exit
91 define void @neg_lv_addr(i32* %loc) {
92 ; CHECK-LABEL: @neg_lv_addr
94 ; CHECK: call void @store
100 %iv = phi i32 [0, %entry], [%iv.next, %loop]
101 %p = getelementptr i32, i32* %loc, i32 %iv
102 call void @store(i32 0, i32* %p)
103 %iv.next = add i32 %iv, 1
104 %cmp = icmp slt i32 %iv, 200
105 br i1 %cmp, label %loop, label %exit
111 define void @neg_mod(i32* %loc) {
112 ; CHECK-LABEL: @neg_mod
114 ; CHECK: call void @store
120 %iv = phi i32 [0, %entry], [%iv.next, %loop]
121 call void @store(i32 0, i32* %loc)
122 store i32 %iv, i32* %loc
123 %iv.next = add i32 %iv, 1
124 %cmp = icmp slt i32 %iv, 200
125 br i1 %cmp, label %loop, label %exit
131 define void @neg_ref(i32* %loc) {
132 ; CHECK-LABEL: @neg_ref
134 ; CHECK: call void @store
135 ; CHECK-LABEL: exit1:
140 %iv = phi i32 [0, %entry], [%iv.next, %backedge]
141 call void @store(i32 0, i32* %loc)
142 %v = load i32, i32* %loc
143 %earlycnd = icmp eq i32 %v, 198
144 br i1 %earlycnd, label %exit1, label %backedge
147 %iv.next = add i32 %iv, 1
148 %cmp = icmp slt i32 %iv, 200
149 br i1 %cmp, label %loop, label %exit2
157 declare void @modref()
159 define void @neg_modref(i32* %loc) {
160 ; CHECK-LABEL: @neg_modref
162 ; CHECK: call void @store
168 %iv = phi i32 [0, %entry], [%iv.next, %loop]
169 call void @store(i32 0, i32* %loc)
171 %iv.next = add i32 %iv, 1
172 %cmp = icmp slt i32 %iv, 200
173 br i1 %cmp, label %loop, label %exit
179 define void @neg_fence(i32* %loc) {
180 ; CHECK-LABEL: @neg_fence
182 ; CHECK: call void @store
188 %iv = phi i32 [0, %entry], [%iv.next, %loop]
189 call void @store(i32 0, i32* %loc)
191 %iv.next = add i32 %iv, 1
192 %cmp = icmp slt i32 %iv, 200
193 br i1 %cmp, label %loop, label %exit
199 declare void @not_nounwind(i32 %v, i32* %p) writeonly argmemonly
200 declare void @not_argmemonly(i32 %v, i32* %p) writeonly nounwind
201 declare void @not_writeonly(i32 %v, i32* %p) argmemonly nounwind
203 define void @neg_not_nounwind(i32* %loc) {
204 ; CHECK-LABEL: @neg_not_nounwind
206 ; CHECK: call void @not_nounwind
212 %iv = phi i32 [0, %entry], [%iv.next, %loop]
213 call void @not_nounwind(i32 0, i32* %loc)
214 %iv.next = add i32 %iv, 1
215 %cmp = icmp slt i32 %iv, 200
216 br i1 %cmp, label %loop, label %exit
222 define void @neg_not_argmemonly(i32* %loc) {
223 ; CHECK-LABEL: @neg_not_argmemonly
225 ; CHECK: call void @not_argmemonly
231 %iv = phi i32 [0, %entry], [%iv.next, %loop]
232 call void @not_argmemonly(i32 0, i32* %loc)
233 %iv.next = add i32 %iv, 1
234 %cmp = icmp slt i32 %iv, 200
235 br i1 %cmp, label %loop, label %exit
241 define void @neg_not_writeonly(i32* %loc) {
242 ; CHECK-LABEL: @neg_not_writeonly
244 ; CHECK: call void @not_writeonly
250 %iv = phi i32 [0, %entry], [%iv.next, %loop]
251 call void @not_writeonly(i32 0, i32* %loc)
252 %iv.next = add i32 %iv, 1
253 %cmp = icmp slt i32 %iv, 200
254 br i1 %cmp, label %loop, label %exit