• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt %loadPolly -scalar-evolution-max-value-compare-depth=3 -polly-scops -polly-invariant-load-hoisting=true -analyze < %s | FileCheck %s
2; RUN: opt %loadPolly -scalar-evolution-max-value-compare-depth=3 -polly-codegen -polly-invariant-load-hoisting=true -analyze < %s
3;
4; Stress test for the code generation of invariant accesses.
5;
6;    void f(int *I0, int *I1, int *I2, int *V, long p0, long p1, long p2, long p3) {
7;      *V = *I1;
8;      for (int i = 0; i < 1000; i++) {
9;        long n0 = p0 * *I1 + p1 * *I1;
10;        V[i] = I0[n0];
11;        long m0 = p0 * (I2[0]);
12;        long m1 = p1 * (I2[1]);
13;        long m2 = p2 * (I2[2]);
14;        long m3 = p3 * (I2[3]);
15;        int j = 0;
16;        do {
17;          if (j > 0) {
18;            V[i] += I1[m0 + m2];
19;            V[i] += I1[n0];
20;          }
21;        } while (j++ < m1 + m3 * n0);
22;      }
23;    }
24;
25; CHECK: p0: ((sext i32 %tmp6 to i64) * %p1)
26; CHECK: p1: ((sext i32 %tmp3 to i64) * (sext i32 %tmp8 to i64) * (%p0 + %p1) * %p3)
27; CHECK: p2: ((sext i32 %tmp3 to i64) * (%p0 + %p1))
28; CHECK: p3: ((sext i32 %tmp5 to i64) * %p0)
29; CHECK: p4: ((sext i32 %tmp7 to i64) * %p2)
30;
31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
32
33define void @f(i32* %I0, i32* %I1, i32* %I2, i32* %V, i64 %p0, i64 %p1, i64 %p2, i64 %p3) {
34entry:
35  %tmp = load i32, i32* %I1, align 4
36  store i32 %tmp, i32* %V, align 4
37  br label %for.cond
38
39for.cond:                                         ; preds = %for.inc, %entry
40  %indvars.iv1 = phi i64 [ %indvars.iv.next2, %for.inc ], [ 0, %entry ]
41  %exitcond = icmp ne i64 %indvars.iv1, 1000
42  br i1 %exitcond, label %for.body, label %for.end
43
44for.body:                                         ; preds = %for.cond
45  %tmp3 = load i32, i32* %I1, align 4
46  %conv = sext i32 %tmp3 to i64
47  %mul = mul nsw i64 %conv, %p0
48  %conv1 = sext i32 %tmp3 to i64
49  %mul2 = mul nsw i64 %conv1, %p1
50  %add = add nsw i64 %mul, %mul2
51  %arrayidx = getelementptr inbounds i32, i32* %I0, i64 %add
52  %tmp4 = load i32, i32* %arrayidx, align 4
53  %arrayidx3 = getelementptr inbounds i32, i32* %V, i64 %indvars.iv1
54  store i32 %tmp4, i32* %arrayidx3, align 4
55  %tmp5 = load i32, i32* %I2, align 4
56  %conv5 = sext i32 %tmp5 to i64
57  %mul6 = mul nsw i64 %conv5, %p0
58  %arrayidx7 = getelementptr inbounds i32, i32* %I2, i64 1
59  %tmp6 = load i32, i32* %arrayidx7, align 4
60  %conv8 = sext i32 %tmp6 to i64
61  %mul9 = mul nsw i64 %conv8, %p1
62  %arrayidx10 = getelementptr inbounds i32, i32* %I2, i64 2
63  %tmp7 = load i32, i32* %arrayidx10, align 4
64  %conv11 = sext i32 %tmp7 to i64
65  %mul12 = mul nsw i64 %conv11, %p2
66  %arrayidx13 = getelementptr inbounds i32, i32* %I2, i64 3
67  %tmp8 = load i32, i32* %arrayidx13, align 4
68  %conv14 = sext i32 %tmp8 to i64
69  %mul15 = mul nsw i64 %conv14, %p3
70  br label %do.body
71
72do.body:                                          ; preds = %do.cond, %for.body
73  %indvars.iv = phi i64 [ %indvars.iv.next, %do.cond ], [ 0, %for.body ]
74  %cmp16 = icmp sgt i64 %indvars.iv, 0
75  br i1 %cmp16, label %if.then, label %if.end
76
77if.then:                                          ; preds = %do.body
78  %add18 = add nsw i64 %mul6, %mul12
79  %arrayidx19 = getelementptr inbounds i32, i32* %I1, i64 %add18
80  %tmp9 = load i32, i32* %arrayidx19, align 4
81  %arrayidx21 = getelementptr inbounds i32, i32* %V, i64 %indvars.iv1
82  %tmp10 = load i32, i32* %arrayidx21, align 4
83  %add22 = add nsw i32 %tmp10, %tmp9
84  store i32 %add22, i32* %arrayidx21, align 4
85  %arrayidx23 = getelementptr inbounds i32, i32* %I1, i64 %add
86  %tmp11 = load i32, i32* %arrayidx23, align 4
87  %arrayidx25 = getelementptr inbounds i32, i32* %V, i64 %indvars.iv1
88  %tmp12 = load i32, i32* %arrayidx25, align 4
89  %add26 = add nsw i32 %tmp12, %tmp11
90  store i32 %add26, i32* %arrayidx25, align 4
91  br label %if.end
92
93if.end:                                           ; preds = %if.then, %do.body
94  br label %do.cond
95
96do.cond:                                          ; preds = %if.end
97  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
98  %mul28 = mul nsw i64 %mul15, %add
99  %add29 = add nsw i64 %mul9, %mul28
100  %cmp30 = icmp slt i64 %indvars.iv, %add29
101  br i1 %cmp30, label %do.body, label %do.end
102
103do.end:                                           ; preds = %do.cond
104  br label %for.inc
105
106for.inc:                                          ; preds = %do.end
107  %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
108  br label %for.cond
109
110for.end:                                          ; preds = %for.cond
111  ret void
112}
113