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 ; Check that loop-independent forward dependences are discovered properly.
6 ; FIXME: This does not actually always work which is pretty confusing. Right
7 ; now there is hack in LAA that tries to figure out loop-independent forward
8 ; dependeces *outside* of the MemoryDepChecker logic (i.e. proper dependence
11 ; Therefore if there is only loop-independent dependences for an array
12 ; (i.e. the same index is used), we don't discover the forward dependence.
13 ; So, at ***, we add another non-I-based access of A to trigger
14 ; MemoryDepChecker analysis for accesses of A.
16 ; for (unsigned i = 0; i < 100; i++) {
17 ; A[i + 1] = B[i] + 1; // ***
22 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
24 define void @f(ptr noalias %A, ptr noalias %B, ptr noalias %C, i64 %N) {
26 ; CHECK-NEXT: for.body:
27 ; 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
28 ; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
29 ; CHECK-NEXT: Dependences:
30 ; CHECK-NEXT: Forward:
31 ; CHECK-NEXT: store i32 %b_p1, ptr %Aidx, align 4 ->
32 ; CHECK-NEXT: %a = load i32, ptr %Aidx, align 4
34 ; CHECK-NEXT: ForwardButPreventsForwarding:
35 ; CHECK-NEXT: store i32 %b_p2, ptr %Aidx_next, align 4 ->
36 ; CHECK-NEXT: %a = load i32, ptr %Aidx, align 4
38 ; CHECK-NEXT: Forward:
39 ; CHECK-NEXT: store i32 %b_p2, ptr %Aidx_next, align 4 ->
40 ; CHECK-NEXT: store i32 %b_p1, ptr %Aidx, align 4
42 ; CHECK-NEXT: Run-time memory checks:
43 ; CHECK-NEXT: Grouped accesses:
45 ; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
46 ; CHECK-NEXT: SCEV assumptions:
48 ; CHECK-NEXT: Expressions re-written:
54 for.body: ; preds = %for.body, %entry
55 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
56 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
58 %Bidx = getelementptr inbounds i32, ptr %B, i64 %indvars.iv
59 %Cidx = getelementptr inbounds i32, ptr %C, i64 %indvars.iv
60 %Aidx_next = getelementptr inbounds i32, ptr %A, i64 %indvars.iv.next
61 %Aidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
63 %b = load i32, ptr %Bidx, align 4
65 store i32 %b_p2, ptr %Aidx_next, align 4
68 store i32 %b_p1, ptr %Aidx, align 4
70 %a = load i32, ptr %Aidx, align 4
72 store i32 %c, ptr %Cidx, align 4
74 %exitcond = icmp eq i64 %indvars.iv.next, %N
75 br i1 %exitcond, label %for.end, label %for.body
77 for.end: ; preds = %for.body