1 ; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s
2 ; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -S < %s | FileCheck %s --check-prefix=IR
4 ; CHECK: Invariant Accesses: {
5 ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
6 ; CHECK-NEXT: [N, tmp1] -> { Stmt_for_body[i0] -> MemRef_I[0] };
7 ; CHECK-NEXT: Execution Context: [N, tmp1] -> { : N > 0 and (tmp1 >= 43 or tmp1 <= 41) }
9 ; CHECK: Invalid Context:
10 ; CHECK-NEXT: [N, tmp1] -> { : tmp1 = 42 and N > 0 }
12 ; IR: polly.preload.begin:
13 ; IR-NEXT: br i1 false, label %polly.start, label %for.cond
15 ; void f(int *A, int *I, int N) {
16 ; for (int i = 0; i < N; i++) {
24 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
26 define void @f(i32* %A, i32* %I, i32 %N) {
28 %tmp = sext i32 %N to i64
31 for.cond: ; preds = %for.inc, %entry
32 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
33 %cmp = icmp slt i64 %indvars.iv, %tmp
34 br i1 %cmp, label %for.body, label %for.end
36 for.body: ; preds = %for.cond
37 %tmp1 = load i32, i32* %I, align 4
38 %cmp1 = icmp eq i32 %tmp1, 42
39 br i1 %cmp1, label %if.then, label %if.else
41 if.then: ; preds = %for.body
42 store i32 0, i32* %I, align 4
45 if.else: ; preds = %for.body
46 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
47 %tmp2 = load i32, i32* %arrayidx, align 4
48 %inc = add nsw i32 %tmp2, 1
49 store i32 %inc, i32* %arrayidx, align 4
52 if.end: ; preds = %if.else, %if.then
55 for.inc: ; preds = %if.end
56 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 for.end: ; preds = %for.cond