1; RUN: opt %loadPolly -polly-scops -analyze \
2; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s
3;
4; CHECK:      Invariant Accesses: {
5; CHECK-NEXT:       ReadAccess := [Reduction Type: NONE] [Scalar: 0]
6; CHECK-NEXT:         MemRef_bounds[0]
7; CHECK-NEXT: Execution Context: [bounds0, bounds1] -> {  :  }
8; CHECK-NEXT:       ReadAccess := [Reduction Type: NONE] [Scalar: 0]
9; CHECK-NEXT:         MemRef_bounds[1]
10; CHECK-NEXT: Execution Context: [bounds0, bounds1] -> {  :  }
11; CHECK:      }
12
13;    double A[1000][1000];
14;    long bounds[2];
15;
16;    void foo() {
17;
18;      for (long i = 0; i <= bounds[0]; i++)
19;        for (long j = 0; j <= bounds[1]; j++)
20;          A[i][j] += i + j;
21;    }
22;
23target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
24
25@bounds = common global [2 x i64] zeroinitializer, align 16
26@A = common global [1000 x [1000 x double]] zeroinitializer, align 16
27
28define void @foo() {
29entry:
30  br label %for.cond
31
32for.cond:                                         ; preds = %for.inc.6, %entry
33  %i.0 = phi i64 [ 0, %entry ], [ %inc7, %for.inc.6 ]
34  %bounds0 = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @bounds, i64 0, i64 0), align 16
35  %cmp = icmp sgt i64 %i.0, %bounds0
36  br i1 %cmp, label %for.end.8, label %for.body
37
38for.body:                                         ; preds = %for.cond
39  br label %for.cond.1
40
41for.cond.1:                                       ; preds = %for.inc, %for.body
42  %j.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ]
43  %bounds1 = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @bounds, i64 0, i64 1), align 8
44  %cmp2 = icmp sgt i64 %j.0, %bounds1
45  br i1 %cmp2, label %for.end, label %for.body.3
46
47for.body.3:                                       ; preds = %for.cond.1
48  %add = add nsw i64 %i.0, %j.0
49  %conv = sitofp i64 %add to double
50  %arrayidx4 = getelementptr inbounds [1000 x [1000 x double]], [1000 x [1000 x double]]* @A, i64 0, i64 %i.0, i64 %j.0
51  %tmp2 = load double, double* %arrayidx4, align 8
52  %add5 = fadd double %tmp2, %conv
53  store double %add5, double* %arrayidx4, align 8
54  br label %for.inc
55
56for.inc:                                          ; preds = %for.body.3
57  %inc = add nuw nsw i64 %j.0, 1
58  br label %for.cond.1
59
60for.end:                                          ; preds = %for.cond.1
61  br label %for.inc.6
62
63for.inc.6:                                        ; preds = %for.end
64  %inc7 = add nuw nsw i64 %i.0, 1
65  br label %for.cond
66
67for.end.8:                                        ; preds = %for.cond
68  ret void
69}
70