Skip to content

Commit c491c93

Browse files
committed
[LAA] Refine tests added in 9c535a3.
Refine FIXMEs in added tests, the problematic case only materializes if there's either both a read and write from an indirect address.
1 parent dc298fe commit c491c93

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

llvm/test/Analysis/LoopAccessAnalysis/loops-with-indirect-reads-and-writes.ll

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ exit:
7979
ret void
8080
}
8181

82-
; FIXME: Not safe with runtime checks due to the indirect pointers are modified
83-
; in the loop.
8482
define void @test_indirect_read_loop_also_modifies_pointer_array(ptr noundef %arr) {
8583
; CHECK-LABEL: 'test_indirect_read_loop_also_modifies_pointer_array'
8684
; CHECK-NEXT: loop.1:
@@ -149,8 +147,6 @@ exit:
149147
ret void
150148
}
151149

152-
; FIXME: Not safe with runtime checks due to the indirect pointers are modified
153-
; in the loop.
154150
define void @test_indirect_write_loop_also_modifies_pointer_array(ptr noundef %arr) {
155151
; CHECK-LABEL: 'test_indirect_write_loop_also_modifies_pointer_array'
156152
; CHECK-NEXT: loop.1:
@@ -206,8 +202,7 @@ loop.2:
206202
%iv.2 = phi i64 [ %iv.lcssa, %loop.1.exit ], [ %iv.2.next, %loop.2 ]
207203
%gep.iv.1 = getelementptr inbounds ptr, ptr %arr, i64 %iv.1
208204
%l.1 = load ptr, ptr %gep.iv.1, align 8, !tbaa !6
209-
%l.2 = load i64, ptr %l.1, align 8, !tbaa !13
210-
%inc = add i64 %l.2, 1
205+
%inc = add i64 %iv.1, 1
211206
store i64 %inc, ptr %l.1, align 8, !tbaa !13
212207
%iv.2.next = add nsw i64 %iv.2, 1
213208
%gep.iv.2 = getelementptr inbounds ptr, ptr %arr, i64 %iv.2
@@ -220,7 +215,9 @@ exit:
220215
ret void
221216
}
222217

223-
define void @test_indirect_read_write_loop_does_not_modify_pointer_array(ptr noundef %arr) {
218+
; FIXME: Not safe with runtime checks due to the indirect pointers are modified
219+
; in the loop.
220+
define void @test_indirect_read_write_loop_does_not_modify_pointer_array(ptr noundef %arr, ptr noundef noalias %arr2) {
224221
; CHECK-LABEL: 'test_indirect_read_write_loop_does_not_modify_pointer_array'
225222
; CHECK-NEXT: loop.1:
226223
; CHECK-NEXT: Report: could not determine number of loop iterations
@@ -238,16 +235,16 @@ define void @test_indirect_read_write_loop_does_not_modify_pointer_array(ptr nou
238235
; CHECK-NEXT: Run-time memory checks:
239236
; CHECK-NEXT: Check 0:
240237
; CHECK-NEXT: Comparing group ([[GRP7:0x[0-9a-f]+]]):
241-
; CHECK-NEXT: %gep.iv.2 = getelementptr inbounds ptr, ptr %arr, i64 %iv.2
238+
; CHECK-NEXT: %gep.arr2.iv.2 = getelementptr inbounds i64, ptr %arr2, i64 %iv.2
242239
; CHECK-NEXT: Against group ([[GRP8:0x[0-9a-f]+]]):
243-
; CHECK-NEXT: %gep.iv.1 = getelementptr inbounds ptr, ptr %arr, i64 %iv.1
240+
; CHECK-NEXT: %gep.arr2.iv.1 = getelementptr inbounds i64, ptr %arr2, i64 %iv.1
244241
; CHECK-NEXT: Grouped accesses:
245242
; CHECK-NEXT: Group [[GRP7]]:
246-
; CHECK-NEXT: (Low: {(64 + %arr),+,64}<%loop.1> High: {(8064 + %arr),+,64}<%loop.1>)
247-
; CHECK-NEXT: Member: {{\{\{}}(64 + %arr),+,64}<%loop.1>,+,8}<%loop.2>
243+
; CHECK-NEXT: (Low: {(64 + %arr2),+,64}<%loop.1> High: {(8064 + %arr2),+,64}<%loop.1>)
244+
; CHECK-NEXT: Member: {{\{\{}}(64 + %arr2),+,64}<%loop.1>,+,8}<%loop.2>
248245
; CHECK-NEXT: Group [[GRP8]]:
249-
; CHECK-NEXT: (Low: %arr High: (8000 + %arr))
250-
; CHECK-NEXT: Member: {%arr,+,8}<nuw><%loop.2>
246+
; CHECK-NEXT: (Low: %arr2 High: (8000 + %arr2))
247+
; CHECK-NEXT: Member: {%arr2,+,8}<nuw><%loop.2>
251248
; CHECK-EMPTY:
252249
; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
253250
; CHECK-NEXT: SCEV assumptions:
@@ -279,8 +276,11 @@ loop.2:
279276
%inc = add i64 %l.2, 1
280277
store i64 %inc, ptr %l.1, align 8, !tbaa !13
281278
%iv.2.next = add nsw i64 %iv.2, 1
282-
%gep.iv.2 = getelementptr inbounds ptr, ptr %arr, i64 %iv.2
283-
store ptr %l.1, ptr %gep.iv.2, align 8, !tbaa !6
279+
%gep.arr2.iv.1 = getelementptr inbounds i64 , ptr %arr2, i64 %iv.1
280+
%gep.arr2.iv.2 = getelementptr inbounds i64 , ptr %arr2, i64 %iv.2
281+
%l.3 = load i64, ptr %gep.arr2.iv.1
282+
%inc.2 = add i64 %l.3, 5
283+
store i64 %inc.2, ptr %gep.arr2.iv.2, align 8, !tbaa !6
284284
%iv.1.next = add nuw nsw i64 %iv.1, 1
285285
%cmp = icmp ult i64 %iv.1.next, 1000
286286
br i1 %cmp, label %loop.2, label %exit

0 commit comments

Comments
 (0)