1 ; RUN: opt -S -disable-output -passes='print<access-info>' %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6 ; A forwarding in the presence of symbolic strides.
7 define void @single_stride(ptr noalias %A, ptr noalias %B, i64 %N, i64 %stride) {
8 ; CHECK-LABEL: Loop access info in function 'single_stride':
10 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop.
11 ; CHECK-NEXT: Backward loop carried data dependence.
12 ; CHECK-NEXT: Dependences:
13 ; CHECK-NEXT: Backward:
14 ; CHECK-NEXT: %load = load i32, ptr %gep.A, align 4 ->
15 ; CHECK-NEXT: store i32 %add, ptr %gep.A.next, align 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:
22 ; CHECK-NEXT: Equal predicate: %stride == 1
24 ; CHECK-NEXT: Expressions re-written:
25 ; CHECK-NEXT: [PSE] %gep.A = getelementptr inbounds i32, ptr %A, i64 %mul:
26 ; CHECK-NEXT: {%A,+,(4 * %stride)}<%loop>
27 ; CHECK-NEXT: --> {%A,+,4}<%loop>
33 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
34 %mul = mul i64 %iv, %stride
35 %gep.A = getelementptr inbounds i32, ptr %A, i64 %mul
36 %load = load i32, ptr %gep.A, align 4
37 %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
38 %load_1 = load i32, ptr %gep.B, align 4
39 %add = add i32 %load_1, %load
40 %iv.next = add nuw nsw i64 %iv, 1
41 %gep.A.next = getelementptr inbounds i32, ptr %A, i64 %iv.next
42 store i32 %add, ptr %gep.A.next, align 4
43 %exitcond = icmp eq i64 %iv.next, %N
44 br i1 %exitcond, label %exit, label %loop
50 ; Similar to @single_stride, but with struct types.
51 define void @single_stride_struct(ptr noalias %A, ptr noalias %B, i64 %N, i64 %stride) {
52 ; CHECK-LABEL: Loop access info in function 'single_stride_struct':
54 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop.
55 ; CHECK-NEXT: Backward loop carried data dependence.
56 ; CHECK-NEXT: Dependences:
57 ; CHECK-NEXT: Backward:
58 ; CHECK-NEXT: %load = load { i32, i8 }, ptr %gep.A, align 4 ->
59 ; CHECK-NEXT: store { i32, i8 } %ins, ptr %gep.A.next, align 4
61 ; CHECK-NEXT: Run-time memory checks:
62 ; CHECK-NEXT: Grouped accesses:
64 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
65 ; CHECK-NEXT: SCEV assumptions:
66 ; CHECK-NEXT: Equal predicate: %stride == 1
68 ; CHECK-NEXT: Expressions re-written:
69 ; CHECK-NEXT: [PSE] %gep.A = getelementptr inbounds { i32, i8 }, ptr %A, i64 %mul:
70 ; CHECK-NEXT: {%A,+,(8 * %stride)}<%loop>
71 ; CHECK-NEXT: --> {%A,+,8}<%loop>
77 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
78 %mul = mul i64 %iv, %stride
79 %gep.A = getelementptr inbounds { i32, i8 }, ptr %A, i64 %mul
80 %load = load { i32, i8 }, ptr %gep.A, align 4
81 %gep.B = getelementptr inbounds { i32, i8 }, ptr %B, i64 %iv
82 %load_1 = load { i32, i8 }, ptr %gep.B, align 4
83 %v1 = extractvalue { i32, i8 } %load, 0
84 %v2 = extractvalue { i32, i8} %load_1, 0
85 %add = add i32 %v1, %v2
86 %ins = insertvalue { i32, i8 } undef, i32 %add, 0
87 %iv.next = add nuw nsw i64 %iv, 1
88 %gep.A.next = getelementptr inbounds { i32, i8 }, ptr %A, i64 %iv.next
89 store { i32, i8 } %ins, ptr %gep.A.next, align 4
90 %exitcond = icmp eq i64 %iv.next, %N
91 br i1 %exitcond, label %exit, label %loop
97 ; A loop with two symbolic strides.
98 define void @two_strides(ptr noalias %A, ptr noalias %B, i64 %N, i64 %stride.1, i64 %stride.2) {
99 ; CHECK-LABEL: Loop access info in function 'two_strides':
101 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop.
102 ; CHECK-NEXT: Backward loop carried data dependence.
103 ; CHECK-NEXT: Dependences:
104 ; CHECK-NEXT: Backward:
105 ; CHECK-NEXT: %load = load i32, ptr %gep.A, align 4 ->
106 ; CHECK-NEXT: store i32 %add, ptr %gep.A.next, align 4
108 ; CHECK-NEXT: Run-time memory checks:
109 ; CHECK-NEXT: Grouped accesses:
111 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
112 ; CHECK-NEXT: SCEV assumptions:
113 ; CHECK-NEXT: Equal predicate: %stride.2 == 1
114 ; CHECK-NEXT: Equal predicate: %stride.1 == 1
116 ; CHECK-NEXT: Expressions re-written:
117 ; CHECK-NEXT: [PSE] %gep.A = getelementptr inbounds i32, ptr %A, i64 %mul:
118 ; CHECK-NEXT: {%A,+,(4 * %stride.1)}<%loop>
119 ; CHECK-NEXT: --> {%A,+,4}<%loop>
120 ; CHECK-NEXT: [PSE] %gep.A.next = getelementptr inbounds i32, ptr %A, i64 %mul.2:
121 ; CHECK-NEXT: {((4 * %stride.2) + %A),+,(4 * %stride.2)}<%loop>
122 ; CHECK-NEXT: --> {(4 + %A),+,4}<%loop>
128 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
129 %mul = mul i64 %iv, %stride.1
130 %gep.A = getelementptr inbounds i32, ptr %A, i64 %mul
131 %load = load i32, ptr %gep.A, align 4
132 %gep.B = getelementptr inbounds i32, ptr %B, i64 %iv
133 %load_1 = load i32, ptr %gep.B, align 4
134 %add = add i32 %load_1, %load
135 %iv.next = add nuw nsw i64 %iv, 1
136 %mul.2 = mul i64 %iv.next, %stride.2
137 %gep.A.next = getelementptr inbounds i32, ptr %A, i64 %mul.2
138 store i32 %add, ptr %gep.A.next, align 4
139 %exitcond = icmp eq i64 %iv.next, %N
140 br i1 %exitcond, label %exit, label %loop