1*35f70200SMichael Kruse; RUN: opt %loadPolly -S -polly-codegen < %s | FileCheck %s
2*35f70200SMichael Kruse;
3*35f70200SMichael Kruse; We should only access (or compute the address of) "the first element" of %S
4*35f70200SMichael Kruse; as it is a single struct not a struct array. The maximal access to S, thus
5*35f70200SMichael Kruse; S->B[1023] is for ScalarEvolution an access with offset of 1423, 1023 for the
6*35f70200SMichael Kruse; index inside the B part of S and 400 to skip the Dummy array in S. Note that
7*35f70200SMichael Kruse; these numbers are relative to the actual type of &S->B[i] (char*) not to the
8*35f70200SMichael Kruse; type of S (struct st *) or something else.
9*35f70200SMichael Kruse;
10*35f70200SMichael Kruse; Verify that we do not use the offset 1423 into a non existent S array when we
11*35f70200SMichael Kruse; compute runtime alias checks but treat it as if it was a char array.
12*35f70200SMichael Kruse;
13*35f70200SMichael Kruse; CHECK: %polly.access.cast.S = bitcast %struct.st* %S to i8*
14*35f70200SMichael Kruse; CHECK: %polly.access.S = getelementptr i8, i8* %polly.access.cast.S, i64 1424
15*35f70200SMichael Kruse;
16*35f70200SMichael Kruse;    struct st {
17*35f70200SMichael Kruse;      int Dummy[100];
18*35f70200SMichael Kruse;      char B[100];
19*35f70200SMichael Kruse;    };
20*35f70200SMichael Kruse;
21*35f70200SMichael Kruse;    void jd(int *A, struct st *S) {
22*35f70200SMichael Kruse;      for (int i = 0; i < 1024; i++)
23*35f70200SMichael Kruse;        A[i] = S->B[i];
24*35f70200SMichael Kruse;    }
25*35f70200SMichael Kruse;
26*35f70200SMichael Krusetarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27*35f70200SMichael Kruse
28*35f70200SMichael Kruse%struct.st = type { [100 x i32], [100 x i8] }
29*35f70200SMichael Kruse
30*35f70200SMichael Krusedefine void @jd(i32* %A, %struct.st* %S) {
31*35f70200SMichael Kruseentry:
32*35f70200SMichael Kruse  br label %for.cond
33*35f70200SMichael Kruse
34*35f70200SMichael Krusefor.cond:                                         ; preds = %for.inc, %entry
35*35f70200SMichael Kruse  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
36*35f70200SMichael Kruse  %exitcond = icmp ne i64 %indvars.iv, 1024
37*35f70200SMichael Kruse  br i1 %exitcond, label %for.body, label %for.end
38*35f70200SMichael Kruse
39*35f70200SMichael Krusefor.body:                                         ; preds = %for.cond
40*35f70200SMichael Kruse  %arrayidx = getelementptr inbounds %struct.st, %struct.st* %S, i64 0, i32 1, i64 %indvars.iv
41*35f70200SMichael Kruse  %tmp = load i8, i8* %arrayidx, align 1
42*35f70200SMichael Kruse  %conv = sext i8 %tmp to i32
43*35f70200SMichael Kruse  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
44*35f70200SMichael Kruse  store i32 %conv, i32* %arrayidx2, align 4
45*35f70200SMichael Kruse  br label %for.inc
46*35f70200SMichael Kruse
47*35f70200SMichael Krusefor.inc:                                          ; preds = %for.body
48*35f70200SMichael Kruse  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
49*35f70200SMichael Kruse  br label %for.cond
50*35f70200SMichael Kruse
51*35f70200SMichael Krusefor.end:                                          ; preds = %for.cond
52*35f70200SMichael Kruse  ret void
53*35f70200SMichael Kruse}
54