1; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s 2; 3; Check that we do not try to preload *I and assume p != 42. 4; 5; CHECK: Invariant Accesses: { 6; CHECK-NEXT: } 7; 8; CHECK: Invalid Context: 9; CHECK-NEXT: [N, p] -> { : false } 10; 11; CHECK: Stmt_if_then__TO__if_end 12; CHECK-NEXT: Domain := 13; CHECK-NEXT: [N, p] -> { Stmt_if_then__TO__if_end[i0] : p = 42 and 0 <= i0 < N }; 14; 15; void f(int *A, int *I, int N, int p, int q) { 16; for (int i = 0; i < N; i++) { 17; if (p == 42) { 18; *I = 0; 19; if (*I == q) 20; A[i] *= 2; 21; } 22; A[i]++; 23; } 24; } 25; 26target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 27 28define void @f(i32* %A, i32* %I, i32 %N, i32 %p, i32 %q) { 29entry: 30 %tmp = sext i32 %N to i64 31 br label %for.cond 32 33for.cond: ; preds = %for.inc, %entry 34 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ] 35 %cmp = icmp slt i64 %indvars.iv, %tmp 36 br i1 %cmp, label %for.body, label %for.end 37 38for.body: ; preds = %for.cond 39 %cmp1 = icmp eq i32 %p, 42 40 br i1 %cmp1, label %if.then, label %if.end4 41 42if.then: ; preds = %for.body 43 store i32 0, i32* %I, align 4 44 %tmp1 = load i32, i32* %I, align 4 45 %cmp2 = icmp eq i32 %tmp1, %q 46 br i1 %cmp2, label %if.then3, label %if.end 47 48if.then3: ; preds = %if.then 49 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv 50 %tmp2 = load i32, i32* %arrayidx, align 4 51 %mul = shl nsw i32 %tmp2, 1 52 store i32 %mul, i32* %arrayidx, align 4 53 br label %if.end 54 55if.end: ; preds = %if.then3, %if.then 56 br label %if.end4 57 58if.end4: ; preds = %if.end, %for.body 59 %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv 60 %tmp3 = load i32, i32* %arrayidx6, align 4 61 %inc = add nsw i32 %tmp3, 1 62 store i32 %inc, i32* %arrayidx6, align 4 63 br label %for.inc 64 65for.inc: ; preds = %if.end4 66 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 67 br label %for.cond 68 69for.end: ; preds = %for.cond 70 ret void 71} 72