1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
6 ; Test case for https://github.com/llvm/llvm-project/issues/82665.
7 define void @indirect_ptr_recurrences_read_write(ptr %A, ptr %B) {
8 ; CHECK-LABEL: 'indirect_ptr_recurrences_read_write'
10 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
11 ; CHECK-NEXT: Unsafe indirect dependence.
12 ; CHECK-NEXT: Dependences:
13 ; CHECK-NEXT: IndirectUnsafe:
14 ; CHECK-NEXT: %l = load i32, ptr %ptr.recur, align 4, !tbaa !4 ->
15 ; CHECK-NEXT: store i32 %xor, ptr %ptr.recur, align 4, !tbaa !4
17 ; CHECK-NEXT: Run-time memory checks:
18 ; CHECK-NEXT: Grouped accesses:
20 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
21 ; CHECK-NEXT: SCEV assumptions:
23 ; CHECK-NEXT: Expressions re-written:
29 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
30 %ptr.recur = phi ptr [ %A, %entry ], [ %ptr.next, %loop ]
31 %gep.B = getelementptr inbounds ptr, ptr %B, i64 %iv
32 %ptr.next = load ptr, ptr %gep.B, align 8, !tbaa !6
33 %l = load i32, ptr %ptr.recur, align 4, !tbaa !10
35 store i32 %xor, ptr %ptr.recur, align 4, !tbaa !10
36 %iv.next = add nuw nsw i64 %iv, 1
37 %ec = icmp eq i64 %iv.next, 5
38 br i1 %ec, label %exit, label %loop
44 define i32 @indirect_ptr_recurrences_read_only_loop(ptr %A, ptr %B) {
45 ; CHECK-LABEL: 'indirect_ptr_recurrences_read_only_loop'
47 ; CHECK-NEXT: Memory dependences are safe
48 ; CHECK-NEXT: Dependences:
49 ; CHECK-NEXT: Run-time memory checks:
50 ; CHECK-NEXT: Grouped accesses:
52 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
53 ; CHECK-NEXT: SCEV assumptions:
55 ; CHECK-NEXT: Expressions re-written:
61 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
62 %ptr.recur = phi ptr [ %A, %entry ], [ %ptr.next, %loop ]
63 %red = phi i32 [ 0, %entry ], [ %xor, %loop ]
64 %gep.B = getelementptr inbounds ptr, ptr %B, i64 %iv
65 %ptr.next = load ptr, ptr %gep.B, align 8, !tbaa !6
66 %l = load i32, ptr %ptr.recur, align 4, !tbaa !10
68 %iv.next = add nuw nsw i64 %iv, 1
69 %ec = icmp eq i64 %iv.next, 5
70 br i1 %ec, label %exit, label %loop
76 define void @indirect_ptr_recurrences_read_write_may_alias_no_tbaa(ptr %A, ptr %B) {
77 ; CHECK-LABEL: 'indirect_ptr_recurrences_read_write_may_alias_no_tbaa'
79 ; CHECK-NEXT: Report: cannot identify array bounds
80 ; CHECK-NEXT: Dependences:
81 ; CHECK-NEXT: Run-time memory checks:
82 ; CHECK-NEXT: Grouped accesses:
84 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
85 ; CHECK-NEXT: SCEV assumptions:
87 ; CHECK-NEXT: Expressions re-written:
93 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
94 %ptr.recur = phi ptr [ %A, %entry ], [ %ptr.next, %loop ]
95 %gep.B = getelementptr inbounds ptr, ptr %B, i64 %iv
96 %ptr.next = load ptr, ptr %gep.B, align 8, !tbaa !6
97 %l = load i32, ptr %ptr.recur, align 4
99 store i32 %xor, ptr %ptr.recur, align 4
100 %iv.next = add nuw nsw i64 %iv, 1
101 %ec = icmp eq i64 %iv.next, 5
102 br i1 %ec, label %exit, label %loop
108 define void @indirect_ptr_recurrences_read_write_may_alias_different_obj(ptr %A, ptr %B, ptr %C) {
109 ; CHECK-LABEL: 'indirect_ptr_recurrences_read_write_may_alias_different_obj'
111 ; CHECK-NEXT: Report: cannot identify array bounds
112 ; CHECK-NEXT: Dependences:
113 ; CHECK-NEXT: Run-time memory checks:
114 ; CHECK-NEXT: Grouped accesses:
116 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
117 ; CHECK-NEXT: SCEV assumptions:
119 ; CHECK-NEXT: Expressions re-written:
125 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
126 %ptr.recur = phi ptr [ %A, %entry ], [ %ptr.next, %loop ]
127 %gep.B = getelementptr inbounds ptr, ptr %B, i64 %iv
128 %ptr.next = load ptr, ptr %gep.B, align 8, !tbaa !6
129 %l = load i32, ptr %ptr.recur, align 4
131 %gep.C = getelementptr inbounds ptr, ptr %C, i64 %iv
132 store i32 %xor, ptr %gep.C, align 4
133 %iv.next = add nuw nsw i64 %iv, 1
134 %ec = icmp eq i64 %iv.next, 5
135 br i1 %ec, label %exit, label %loop
141 define void @indirect_ptr_recurrences_read_write_may_noalias_different_obj(ptr %A, ptr %B, ptr noalias %C) {
142 ; CHECK-LABEL: 'indirect_ptr_recurrences_read_write_may_noalias_different_obj'
144 ; CHECK-NEXT: Memory dependences are safe
145 ; CHECK-NEXT: Dependences:
146 ; CHECK-NEXT: Run-time memory checks:
147 ; CHECK-NEXT: Grouped accesses:
149 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
150 ; CHECK-NEXT: SCEV assumptions:
152 ; CHECK-NEXT: Expressions re-written:
158 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
159 %ptr.recur = phi ptr [ %A, %entry ], [ %ptr.next, %loop ]
160 %gep.B = getelementptr inbounds ptr, ptr %B, i64 %iv
161 %ptr.next = load ptr, ptr %gep.B, align 8, !tbaa !6
162 %l = load i32, ptr %ptr.recur, align 4
164 %gep.C = getelementptr inbounds ptr, ptr %C, i64 %iv
165 store i32 %xor, ptr %gep.C, align 4
166 %iv.next = add nuw nsw i64 %iv, 1
167 %ec = icmp eq i64 %iv.next, 5
168 br i1 %ec, label %exit, label %loop
175 !6 = !{!7, !7, i64 0}
176 !7 = !{!"any pointer", !8, i64 0}
177 !8 = !{!"omnipotent char", !9, i64 0}
178 !9 = !{!"Simple C/C++ TBAA"}
179 !10 = !{!11, !11, i64 0}
180 !11 = !{!"int", !8, i64 0}