1; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s
2;
3;
4; CHECK:       Invariant Accesses: {
5; CHECK-NEXT:    ReadAccess := [Reduction Type: NONE] [Scalar: 0]
6; CHECK-NEXT:    [c] -> { Stmt_for_body[i0] -> MemRef_I[-1 + c] };
7; CHECK-NEXT:    Execution Context: [c] -> {  : c > 0 }
8; CHECK-NEXT:  }
9; CHECK-NEXT:  Context:
10; CHECK-NEXT:  [c] -> {  : -128 <= c <= 127 }
11; CHECK-NEXT:  Assumed Context:
12; CHECK-NEXT:  [c] -> {  :  }
13; CHECK-NEXT:  Invalid Context:
14; CHECK-NEXT:  [c] -> {  : c <= 0 }
15;
16;    void f(int *A, int *I, unsigned char c) {
17;      for (int i = 0; i < 10; i++)
18;        A[i] += I[c - (char)1];
19;    }
20;
21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22
23define void @f(i32* %A, i32* %I, i8 zeroext %c) {
24entry:
25  br label %for.cond
26
27for.cond:                                         ; preds = %for.inc, %entry
28  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
29  %exitcond = icmp ne i64 %indvars.iv, 10
30  br i1 %exitcond, label %for.body, label %for.end
31
32for.body:                                         ; preds = %for.cond
33  %sub = add i8 %c, -1
34  %conv = zext i8 %sub to i64
35  %arrayidx = getelementptr inbounds i32, i32* %I, i64 %conv
36  %tmp = load i32, i32* %arrayidx, align 4
37  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
38  %tmp1 = load i32, i32* %arrayidx2, align 4
39  %add = add nsw i32 %tmp1, %tmp
40  store i32 %add, i32* %arrayidx2, align 4
41  br label %for.inc
42
43for.inc:                                          ; preds = %for.body
44  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
45  br label %for.cond
46
47for.end:                                          ; preds = %for.cond
48  ret void
49}
50