Tobias Grosser | ad61c17 | 2016-08-15 13:58:16 +0000 | [diff] [blame] | 1 | ; RUN: opt %loadPolly -polly-scops -analyze \ |
| 2 | ; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s |
Johannes Doerfert | 09e3697 | 2015-10-07 20:17:36 +0000 | [diff] [blame] | 3 | ; |
| 4 | ; CHECK: Invariant Accesses: { |
| 5 | ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] |
| 6 | ; CHECK-NEXT: MemRef_bounds[0] |
Johannes Doerfert | af3e301 | 2015-10-18 12:39:19 +0000 | [diff] [blame] | 7 | ; CHECK-NEXT: Execution Context: [bounds0, bounds1] -> { : } |
Johannes Doerfert | 09e3697 | 2015-10-07 20:17:36 +0000 | [diff] [blame] | 8 | ; CHECK-NEXT: ReadAccess := [Reduction Type: NONE] [Scalar: 0] |
| 9 | ; CHECK-NEXT: MemRef_bounds[1] |
Johannes Doerfert | 1dc12af | 2016-04-23 12:59:18 +0000 | [diff] [blame] | 10 | ; CHECK-NEXT: Execution Context: [bounds0, bounds1] -> { : } |
Johannes Doerfert | 09e3697 | 2015-10-07 20:17:36 +0000 | [diff] [blame] | 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 | ; |
| 23 | target 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 | |
| 28 | define void @foo() { |
| 29 | entry: |
| 30 | br label %for.cond |
| 31 | |
| 32 | for.cond: ; preds = %for.inc.6, %entry |
| 33 | %i.0 = phi i64 [ 0, %entry ], [ %inc7, %for.inc.6 ] |
Johannes Doerfert | af3e301 | 2015-10-18 12:39:19 +0000 | [diff] [blame] | 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 |
Johannes Doerfert | 09e3697 | 2015-10-07 20:17:36 +0000 | [diff] [blame] | 36 | br i1 %cmp, label %for.end.8, label %for.body |
| 37 | |
| 38 | for.body: ; preds = %for.cond |
| 39 | br label %for.cond.1 |
| 40 | |
| 41 | for.cond.1: ; preds = %for.inc, %for.body |
| 42 | %j.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ] |
Johannes Doerfert | af3e301 | 2015-10-18 12:39:19 +0000 | [diff] [blame] | 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 |
Johannes Doerfert | 09e3697 | 2015-10-07 20:17:36 +0000 | [diff] [blame] | 45 | br i1 %cmp2, label %for.end, label %for.body.3 |
| 46 | |
| 47 | for.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 | |
| 56 | for.inc: ; preds = %for.body.3 |
| 57 | %inc = add nuw nsw i64 %j.0, 1 |
| 58 | br label %for.cond.1 |
| 59 | |
| 60 | for.end: ; preds = %for.cond.1 |
| 61 | br label %for.inc.6 |
| 62 | |
| 63 | for.inc.6: ; preds = %for.end |
| 64 | %inc7 = add nuw nsw i64 %i.0, 1 |
| 65 | br label %for.cond |
| 66 | |
| 67 | for.end.8: ; preds = %for.cond |
| 68 | ret void |
| 69 | } |