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