1 ; RUN: opt %loadPolly -polly-print-scops -disable-output < %s \
2 ; RUN: -polly-invariant-load-hoisting \
5 ; Verify that nested arrays with invariant base pointers are handled correctly.
6 ; Specifically, we currently do not canonicalize arrays where some accesses are
7 ; hoisted as invariant loads. If we would, we need to update the access function
8 ; of the invariant loads as well. However, as this is not a very common
9 ; situation, we leave this for now to avoid further complexity increases.
11 ; In this test case the arrays baseA1 and baseA2 could be canonicalized to a
12 ; single array, but there is also an invariant access to baseA1[0] through
13 ; "%v0 = load float, float* %ptr" which prevents the canonicalization.
15 ; CHECK: Invariant Accesses: {
16 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
17 ; CHECK-NEXT: { Stmt_body2[i0] -> MemRef_A[0] };
18 ; CHECK-NEXT: Execution Context: { : }
19 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
20 ; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_baseA1[0] };
21 ; CHECK-NEXT: Execution Context: { : }
25 ; CHECK-NEXT: Stmt_body1
26 ; CHECK-NEXT: Domain :=
27 ; CHECK-NEXT: { Stmt_body1[i0] : 0 <= i0 <= 1021 };
28 ; CHECK-NEXT: Schedule :=
29 ; CHECK-NEXT: { Stmt_body1[i0] -> [i0, 0] };
30 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
31 ; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_baseA1[1 + i0] };
32 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
33 ; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_B[0] };
34 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
35 ; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_B[0] };
36 ; CHECK-NEXT: Stmt_body2
37 ; CHECK-NEXT: Domain :=
38 ; CHECK-NEXT: { Stmt_body2[i0] : 0 <= i0 <= 1021 };
39 ; CHECK-NEXT: Schedule :=
40 ; CHECK-NEXT: { Stmt_body2[i0] -> [i0, 1] };
41 ; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
42 ; CHECK-NEXT: { Stmt_body2[i0] -> MemRef_baseA2[0] };
45 define void @foo(ptr %A, ptr %B) {
50 %indvar = phi i64 [1, %start], [%indvar.next, %latch]
51 %indvar.next = add nsw i64 %indvar, 1
52 %icmp = icmp slt i64 %indvar.next, 1024
53 br i1 %icmp, label %body1, label %exit
56 %baseA1 = load ptr, ptr %A
57 %ptr = getelementptr inbounds float, ptr %baseA1, i64 %indvar
58 %v0 = load float, ptr %ptr
59 %v1 = load float, ptr %baseA1
60 store float %v0, ptr %B
61 store float %v1, ptr %B
65 %baseA2 = load ptr, ptr %A
66 store float undef, ptr %baseA2