1 ; RUN: opt %loadPolly -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s | FileCheck %s --check-prefix=SCOP
2 ; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -S < %s | FileCheck %s
4 ; SCOP: Assumed Context:
5 ; SCOP-NEXT: [p_0, tmp4] -> { : }
6 ; SCOP-NEXT: Invalid Context:
7 ; SCOP-NEXT: [p_0, tmp4] -> { : p_0 > 0 and tmp4 < 0 }
11 ; CHECK: polly.preload.merge:
13 ; void f(int *restrict A, int *restrict B, int N, int M) {
15 ; for (int i = 0; i < N * M; i++)
16 ; for (int j = 0; j < A[N * M] / 2; j++)
20 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22 define void @f(i32* noalias %A, i32* noalias %B, i32 %N, i32 %M) {
26 for.cond: ; preds = %for.inc.8, %entry
27 %indvars.iv2 = phi i64 [ %indvars.iv.next3, %for.inc.8 ], [ 0, %entry ]
28 %mul = mul nsw i32 %N, %M
29 %tmp = sext i32 %mul to i64
30 %cmp = icmp slt i64 %indvars.iv2, %tmp
31 br i1 %cmp, label %for.body, label %for.end.10
33 for.body: ; preds = %for.cond
36 for.cond.1: ; preds = %for.inc, %for.body
37 %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %for.body ]
38 %mul2 = mul nsw i32 %N, %M
39 %idxprom = sext i32 %mul2 to i64
40 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
41 %tmp4 = load i32, i32* %arrayidx, align 4
42 %div = udiv i32 %tmp4, 2
43 %tmp5 = sext i32 %div to i64
44 %cmp3 = icmp slt i64 %indvars.iv, %tmp5
45 br i1 %cmp3, label %for.body.4, label %for.end
47 for.body.4: ; preds = %for.cond.1
48 %tmp6 = add nsw i64 %indvars.iv2, %indvars.iv
49 %arrayidx6 = getelementptr inbounds i32, i32* %B, i64 %tmp6
50 %tmp7 = load i32, i32* %arrayidx6, align 4
51 %inc = add nsw i32 %tmp7, 1
52 store i32 %inc, i32* %arrayidx6, align 4
55 for.inc: ; preds = %for.body.4
56 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
59 for.end: ; preds = %for.cond.1
62 for.inc.8: ; preds = %for.end
63 %indvars.iv.next3 = add nuw nsw i64 %indvars.iv2, 1
66 for.end.10: ; preds = %for.cond