1; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s 2; 3; Verify we do not hoist I[c] without execution context because it 4; is executed in a statement with an invalid domain and it depends 5; on a parameter that was specialized by the domain. 6; 7; CHECK: Invariant Accesses: { 8; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] 9; CHECK-NEXT: [c] -> { Stmt_if_then[i0] -> MemRef_I[-129] }; 10; CHECK-NEXT: Execution Context: [c] -> { : false } 11; CHECK-NEXT: } 12; 13; TODO: FIXME: We should remove the statement as it has an empty domain. 14; CHECK: Stmt_if_then 15; CHECK-NEXT: Domain := 16; CHECK-NEXT: [c] -> { Stmt_if_then[i0] : false }; 17; 18; int I[1024]; 19; void f(int *A, unsigned char c) { 20; for (int i = 0; i < 10; i++) 21; if ((signed char)(c + (unsigned char)1) == 127) 22; A[i] += I[c]; 23; else 24; A[i] = 0; 25; } 26; 27target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 28 29@I = common global [1024 x i32] zeroinitializer, align 16 30 31define void @f(i32* %A, i8 zeroext %c) { 32entry: 33 br label %for.cond 34 35for.cond: ; preds = %for.inc, %entry 36 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ] 37 %exitcond = icmp ne i64 %indvars.iv, 10 38 br i1 %exitcond, label %for.body, label %for.end 39 40for.body: ; preds = %for.cond 41 %add = add i8 %c, 1 42 %cmp3 = icmp eq i8 %add, 128 43 %arrayidx6 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv 44 br i1 %cmp3, label %if.then, label %if.else 45 46if.then: ; preds = %for.body 47 %arrayidx = getelementptr inbounds [1024 x i32], [1024 x i32]* @I, i64 0, i8 %c 48 %tmp = load i32, i32* %arrayidx, align 4 49 %tmp1 = load i32, i32* %arrayidx6, align 4 50 %add7 = add nsw i32 %tmp1, %tmp 51 store i32 %add7, i32* %arrayidx6, align 4 52 br label %for.inc 53 54if.else: ; preds = %if.then, %for.body 55 store i32 0, i32* %arrayidx6, align 4 56 br label %for.inc 57 58for.inc: ; preds = %if.else, if.then 59 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 60 br label %for.cond 61 62for.end: ; preds = %for.cond 63 ret void 64} 65