xref: /llvm-project/polly/test/ScopInfo/multidim_gep_pointercast.ll (revision e1f056f692d869708c1898d9d65a69ac5584a0ed)
1; RUN: opt %loadNPMPolly '-passes=print<polly-function-scops>' -disable-output < %s 2>&1 | FileCheck %s
2;
3; The load access to A has a pointer-bitcast to another elements size before the
4; GetElementPtr. Verify that we do not the GEP delinearization because it
5; mismatches with the size of the loaded element type.
6;
7;    void f(short A[][4], int N, int P) {
8;      short(*B)[4] = &A[P][0];
9;      for (int i = 0; i < N; i++)
10;        *((<4 x short> *)&A[7 * i][0]) = *((<4 x short>)&B[7 * i][0]);
11;    }
12;
13define void @f(ptr %A, i32 %N, i32 %P) {
14entry:
15  %arrayidx1 = getelementptr inbounds [4 x i16], ptr %A, i32 %P, i64 0
16  br label %for.cond
17
18for.cond:
19  %indvars.iv = phi i32 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
20  %cmp = icmp slt i32 %indvars.iv, %N
21  br i1 %cmp, label %for.body, label %for.end
22
23for.body:
24  %mul = mul nsw i32 %indvars.iv, 7
25  %arrayidx4 = getelementptr inbounds [4 x i16], ptr %arrayidx1, i32 %mul, i64 0
26  %tmp3 = load <4 x i16>, ptr %arrayidx4
27  %arrayidx8 = getelementptr inbounds [4 x i16], ptr %A, i32 %mul, i64 0
28  store <4 x i16> %tmp3, ptr %arrayidx8
29  br label %for.inc
30
31for.inc:
32  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
33  br label %for.cond
34
35for.end:
36  ret void
37}
38
39
40; CHECK:      Arrays {
41; CHECK-NEXT:     <4 x i16> MemRef_A[*]; // Element size 8
42; CHECK-NEXT: }
43; CHECK:      Statements {
44; CHECK-NEXT:     Stmt_for_body
45; CHECK-NEXT:         Domain :=
46; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] : 0 <= i0 < N };
47; CHECK-NEXT:         Schedule :=
48; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] -> [i0] };
49; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
50; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] -> MemRef_A[P + 7i0] };
51; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
52; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] -> MemRef_A[7i0] };
53; CHECK-NEXT: }
54