xref: /llvm-project/polly/test/ScopInfo/invariant_load_canonicalize_array_baseptrs_3.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 \
2; RUN:  -polly-invariant-load-hoisting \
3; RUN:  | FileCheck %s
4
5; Verify that we canonicalize accesses even tough one of the accesses (even
6; the canonical base) has a partial execution context. This is correct as
7; the combined execution context still covers both accesses.
8
9; CHECK:      Invariant Accesses: {
10; CHECK-NEXT:         ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
11; CHECK-NEXT:             { Stmt_body2[i0] -> MemRef_A[0] };
12; CHECK-NEXT:         Execution Context: {  :  }
13; CHECK-NEXT: }
14
15; CHECK:      Stmt_body1
16; CHECK-NEXT:   Domain :=
17; CHECK-NEXT:       { Stmt_body1[i0] : 0 <= i0 <= 1022 };
18; CHECK-NEXT:   Schedule :=
19; CHECK-NEXT:       { Stmt_body1[i0] -> [i0, 0] };
20; CHECK-NEXT:   MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
21; CHECK-NEXT:       { Stmt_body1[i0] -> MemRef_baseB[0] };
22; CHECK-NEXT: Stmt_body2
23; CHECK-NEXT:   Domain :=
24; CHECK-NEXT:       { Stmt_body2[i0] : 0 <= i0 <= 510 };
25; CHECK-NEXT:   Schedule :=
26; CHECK-NEXT:       { Stmt_body2[i0] -> [i0, 1] };
27; CHECK-NEXT:   MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
28; CHECK-NEXT:       { Stmt_body2[i0] -> MemRef_baseB[0] };
29
30
31define void @foo(ptr %A) {
32start:
33  br label %loop
34
35loop:
36  %indvar = phi i64 [0, %start], [%indvar.next, %latch]
37  %indvar.next = add nsw i64 %indvar, 1
38  %icmp = icmp slt i64 %indvar.next, 1024
39  br i1 %icmp, label %body1, label %exit
40
41body1:
42  %baseA = load ptr, ptr %A
43  store float 42.0, ptr %baseA
44  %cmp = icmp slt i64 %indvar.next, 512
45  br i1 %cmp, label %body2, label %latch
46
47body2:
48  %baseB = load ptr, ptr %A
49  store float 42.0, ptr %baseB
50  br label %latch
51
52latch:
53  br label %loop
54
55exit:
56  ret void
57
58}
59