• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s --check-prefix=SCOP
2; RUN: opt %loadPolly -polly-codegen -polly-invariant-load-hoisting=true -S < %s | FileCheck %s
3;
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 }
8; SCOP-NEXT:    p0: (%N * %M)
9; SCOP-NEXT:    p1: %tmp4
10;
11; CHECK:      polly.preload.merge:
12;
13;    void f(int *restrict A, int *restrict B, int N, int M) {
14;
15;      for (int i = 0; i < N * M; i++)
16;        for (int j = 0; j < A[N * M] / 2; j++)
17;          B[i + j]++;
18;    }
19;
20target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21
22define void @f(i32* noalias %A, i32* noalias %B, i32 %N, i32 %M) {
23entry:
24  br label %for.cond
25
26for.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
32
33for.body:                                         ; preds = %for.cond
34  br label %for.cond.1
35
36for.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
46
47for.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
53  br label %for.inc
54
55for.inc:                                          ; preds = %for.body.4
56  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
57  br label %for.cond.1
58
59for.end:                                          ; preds = %for.cond.1
60  br label %for.inc.8
61
62for.inc.8:                                        ; preds = %for.end
63  %indvars.iv.next3 = add nuw nsw i64 %indvars.iv2, 1
64  br label %for.cond
65
66for.end.10:                                       ; preds = %for.cond
67  ret void
68}
69