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