77 lines · plain
1; RUN: opt %loadNPMPolly '-passes=polly-custom<scops>' -polly-print-scops -disable-output -polly-invariant-load-hoisting < %s 2>&1 | FileCheck %s2 3; Verify that nested arrays with invariant base pointers are handled correctly.4; Specifically, we currently do not canonicalize arrays where some accesses are5; hoisted as invariant loads. If we would, we need to update the access function6; of the invariant loads as well. However, as this is not a very common7; situation, we leave this for now to avoid further complexity increases.8;9; In this test case the arrays baseA1 and baseA2 could be canonicalized to a10; single array, but there is also an invariant access to baseA1[0] through11; "%v0 = load float, float* %ptr" which prevents the canonicalization.12 13; CHECK: Invariant Accesses: {14; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]15; CHECK-NEXT: { Stmt_body2[i0] -> MemRef_A[0] };16; CHECK-NEXT: Execution Context: { : }17; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]18; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_baseA1[0] };19; CHECK-NEXT: Execution Context: { : }20; CHECK-NEXT: }21 22; CHECK: Statements {23; CHECK-NEXT: Stmt_body124; CHECK-NEXT: Domain :=25; CHECK-NEXT: { Stmt_body1[i0] : 0 <= i0 <= 1021 };26; CHECK-NEXT: Schedule :=27; CHECK-NEXT: { Stmt_body1[i0] -> [i0, 0] };28; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]29; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_baseA1[1 + i0] };30; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]31; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_B[0] };32; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]33; CHECK-NEXT: { Stmt_body1[i0] -> MemRef_B[0] };34; CHECK-NEXT: Stmt_body235; CHECK-NEXT: Domain :=36; CHECK-NEXT: { Stmt_body2[i0] : 0 <= i0 <= 1021 };37; CHECK-NEXT: Schedule :=38; CHECK-NEXT: { Stmt_body2[i0] -> [i0, 1] };39; CHECK-NEXT: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]40; CHECK-NEXT: { Stmt_body2[i0] -> MemRef_baseA2[0] };41; CHECK-NEXT: }42 43define void @foo(ptr %A, ptr %B) {44start:45 br label %loop46 47loop:48 %indvar = phi i64 [1, %start], [%indvar.next, %latch]49 %indvar.next = add nsw i64 %indvar, 150 %icmp = icmp slt i64 %indvar.next, 102451 br i1 %icmp, label %body1, label %exit52 53body1:54 %baseA1 = load ptr, ptr %A55 %ptr = getelementptr inbounds float, ptr %baseA1, i64 %indvar56 %v0 = load float, ptr %ptr57 %v1 = load float, ptr %baseA158 store float %v0, ptr %B59 store float %v1, ptr %B60 br label %body261 62body2:63 %baseA2 = load ptr, ptr %A64 store float undef, ptr %baseA265 br label %body366 67body3:68 br label %latch69 70latch:71 br label %loop72 73exit:74 ret void75 76}77