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