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 3; 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) } 8; CHECK-NEXT: } 9; CHECK: Invalid Context: 10; CHECK-NEXT: [N, tmp1] -> { : tmp1 = 42 and N > 0 } 11; 12; IR: polly.preload.begin: 13; IR-NEXT: br i1 false, label %polly.start, label %for.cond 14; 15; void f(int *A, int *I, int N) { 16; for (int i = 0; i < N; i++) { 17; if (*I == 42) 18; *I = 0; 19; else 20; A[i]++; 21; } 22; } 23; 24target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 25 26define void @f(i32* %A, i32* %I, i32 %N) { 27entry: 28 %tmp = sext i32 %N to i64 29 br label %for.cond 30 31for.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 35 36for.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 40 41if.then: ; preds = %for.body 42 store i32 0, i32* %I, align 4 43 br label %if.end 44 45if.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 50 br label %if.end 51 52if.end: ; preds = %if.else, %if.then 53 br label %for.inc 54 55for.inc: ; preds = %if.end 56 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 57 br label %for.cond 58 59for.end: ; preds = %for.cond 60 ret void 61} 62