2 ; RUN: opt -passes='print<access-info>' -debug-only=loop-accesses -disable-output < %s 2>&1 | FileCheck %s
4 ; void negative_step(int *A) {
5 ; for (int i = 1022; i >= 0; i--)
9 ; CHECK: LAA: Found a loop in negative_step: loop
10 ; CHECK: LAA: Checking memory dependencies
11 ; CHECK-NEXT: LAA: Src Scev: {(4092 + %A),+,-4}<nw><%loop>Sink Scev: {(4088 + %A)<nuw>,+,-4}<nw><%loop>(Induction step: -1)
12 ; CHECK-NEXT: LAA: Distance for store i32 %add, ptr %gep.A.plus.1, align 4 to %l = load i32, ptr %gep.A, align 4: -4
13 ; CHECK-NEXT: LAA: Dependence is negative
15 define void @negative_step(ptr nocapture %A) {
17 %A.plus.1 = getelementptr i32, ptr %A, i64 1
21 %iv = phi i64 [ 1022, %entry ], [ %iv.next, %loop ]
22 %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
23 %l = load i32, ptr %gep.A, align 4
24 %add = add nsw i32 %l, 1
25 %gep.A.plus.1 = getelementptr i32, ptr %A.plus.1, i64 %iv
26 store i32 %add, ptr %gep.A.plus.1, align 4
27 %iv.next = add nsw i64 %iv, -1
28 %cmp.not = icmp eq i64 %iv, 0
29 br i1 %cmp.not, label %exit, label %loop
35 ; void positive_step(int *A) {
36 ; for (int i = 1; i < 1024; i++)
40 ; CHECK: LAA: Found a loop in positive_step: loop
41 ; CHECK: LAA: Checking memory dependencies
42 ; CHECK-NEXT: LAA: Src Scev: {(4 + %A)<nuw>,+,4}<nuw><%loop>Sink Scev: {%A,+,4}<nw><%loop>(Induction step: 1)
43 ; CHECK-NEXT: LAA: Distance for %l = load i32, ptr %gep.A, align 4 to store i32 %add, ptr %gep.A.minus.1, align 4: -4
44 ; CHECK-NEXT: LAA: Dependence is negative
46 define void @positive_step(ptr nocapture %A) {
48 %A.minus.1 = getelementptr i32, ptr %A, i64 -1
52 %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]
53 %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
54 %l = load i32, ptr %gep.A, align 4
55 %add = add nsw i32 %l, 1
56 %gep.A.minus.1 = getelementptr i32, ptr %A.minus.1, i64 %iv
57 store i32 %add, ptr %gep.A.minus.1, align 4
58 %iv.next = add nsw i64 %iv, 1
59 %cmp.not = icmp eq i64 %iv, 1024
60 br i1 %cmp.not, label %exit, label %loop