236
|
1 ; RUN: opt %loadPolly -scalar-evolution-max-value-compare-depth=3 -polly-print-scops -polly-invariant-load-hoisting=true -disable-output < %s | FileCheck %s
|
|
2 ; RUN: opt %loadPolly -scalar-evolution-max-value-compare-depth=3 -polly-codegen -polly-invariant-load-hoisting=true -disable-output < %s
|
150
|
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 ;
|
|
31 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
32
|
252
|
33 define void @f(ptr %I0, ptr %I1, ptr %I2, ptr %V, i64 %p0, i64 %p1, i64 %p2, i64 %p3) {
|
150
|
34 entry:
|
252
|
35 %tmp = load i32, ptr %I1, align 4
|
|
36 store i32 %tmp, ptr %V, align 4
|
150
|
37 br label %for.cond
|
|
38
|
|
39 for.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
|
|
44 for.body: ; preds = %for.cond
|
252
|
45 %tmp3 = load i32, ptr %I1, align 4
|
150
|
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
|
252
|
51 %arrayidx = getelementptr inbounds i32, ptr %I0, i64 %add
|
|
52 %tmp4 = load i32, ptr %arrayidx, align 4
|
|
53 %arrayidx3 = getelementptr inbounds i32, ptr %V, i64 %indvars.iv1
|
|
54 store i32 %tmp4, ptr %arrayidx3, align 4
|
|
55 %tmp5 = load i32, ptr %I2, align 4
|
150
|
56 %conv5 = sext i32 %tmp5 to i64
|
|
57 %mul6 = mul nsw i64 %conv5, %p0
|
252
|
58 %arrayidx7 = getelementptr inbounds i32, ptr %I2, i64 1
|
|
59 %tmp6 = load i32, ptr %arrayidx7, align 4
|
150
|
60 %conv8 = sext i32 %tmp6 to i64
|
|
61 %mul9 = mul nsw i64 %conv8, %p1
|
252
|
62 %arrayidx10 = getelementptr inbounds i32, ptr %I2, i64 2
|
|
63 %tmp7 = load i32, ptr %arrayidx10, align 4
|
150
|
64 %conv11 = sext i32 %tmp7 to i64
|
|
65 %mul12 = mul nsw i64 %conv11, %p2
|
252
|
66 %arrayidx13 = getelementptr inbounds i32, ptr %I2, i64 3
|
|
67 %tmp8 = load i32, ptr %arrayidx13, align 4
|
150
|
68 %conv14 = sext i32 %tmp8 to i64
|
|
69 %mul15 = mul nsw i64 %conv14, %p3
|
|
70 br label %do.body
|
|
71
|
|
72 do.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
|
|
77 if.then: ; preds = %do.body
|
|
78 %add18 = add nsw i64 %mul6, %mul12
|
252
|
79 %arrayidx19 = getelementptr inbounds i32, ptr %I1, i64 %add18
|
|
80 %tmp9 = load i32, ptr %arrayidx19, align 4
|
|
81 %arrayidx21 = getelementptr inbounds i32, ptr %V, i64 %indvars.iv1
|
|
82 %tmp10 = load i32, ptr %arrayidx21, align 4
|
150
|
83 %add22 = add nsw i32 %tmp10, %tmp9
|
252
|
84 store i32 %add22, ptr %arrayidx21, align 4
|
|
85 %arrayidx23 = getelementptr inbounds i32, ptr %I1, i64 %add
|
|
86 %tmp11 = load i32, ptr %arrayidx23, align 4
|
|
87 %arrayidx25 = getelementptr inbounds i32, ptr %V, i64 %indvars.iv1
|
|
88 %tmp12 = load i32, ptr %arrayidx25, align 4
|
150
|
89 %add26 = add nsw i32 %tmp12, %tmp11
|
252
|
90 store i32 %add26, ptr %arrayidx25, align 4
|
150
|
91 br label %if.end
|
|
92
|
|
93 if.end: ; preds = %if.then, %do.body
|
|
94 br label %do.cond
|
|
95
|
|
96 do.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
|
|
103 do.end: ; preds = %do.cond
|
|
104 br label %for.inc
|
|
105
|
|
106 for.inc: ; preds = %do.end
|
|
107 %indvars.iv.next2 = add nuw nsw i64 %indvars.iv1, 1
|
|
108 br label %for.cond
|
|
109
|
|
110 for.end: ; preds = %for.cond
|
|
111 ret void
|
|
112 }
|