1; RUN: opt %loadPolly -polly-scops -analyze < %s | 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([4 x i16]* %A, i32 %N, i32 %P) {
14entry:
15  %arrayidx1 = getelementptr inbounds [4 x i16], [4 x i16]* %A, i32 %P, i64 0
16  %tmp = bitcast i16* %arrayidx1 to [4 x i16]*
17  br label %for.cond
18
19for.cond:
20  %indvars.iv = phi i32 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
21  %cmp = icmp slt i32 %indvars.iv, %N
22  br i1 %cmp, label %for.body, label %for.end
23
24for.body:
25  %mul = mul nsw i32 %indvars.iv, 7
26  %arrayidx4 = getelementptr inbounds [4 x i16], [4 x i16]* %tmp, i32 %mul, i64 0
27  %bc4 = bitcast i16* %arrayidx4 to <4 x i16>*
28  %tmp3 = load <4 x i16>, <4 x i16>* %bc4
29  %arrayidx8 = getelementptr inbounds [4 x i16], [4 x i16]* %A, i32 %mul, i64 0
30  %bc8 = bitcast i16* %arrayidx8 to <4 x i16>*
31  store <4 x i16> %tmp3, <4 x i16>* %bc8
32  br label %for.inc
33
34for.inc:
35  %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
36  br label %for.cond
37
38for.end:
39  ret void
40}
41
42
43; CHECK:      Arrays {
44; CHECK-NEXT:     <4 x i16> MemRef_A[*]; // Element size 8
45; CHECK-NEXT: }
46; CHECK:      Statements {
47; CHECK-NEXT:     Stmt_for_body
48; CHECK-NEXT:         Domain :=
49; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] : 0 <= i0 < N };
50; CHECK-NEXT:         Schedule :=
51; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] -> [i0] };
52; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
53; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] -> MemRef_A[P + 7i0] };
54; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
55; CHECK-NEXT:             [N, P] -> { Stmt_for_body[i0] -> MemRef_A[7i0] };
56; CHECK-NEXT: }
57