1; RUN: opt %loadPolly -analyze -polly-scops \
2; RUN: -polly-invariant-load-hoisting=true < %s | FileCheck %s
3;
4; Check that propagation of domains from A(X) to A(X+1) will keep the
5; domains small and concise.
6;
7; CHECK:         Assumed Context:
8; CHECK-NEXT:    [tmp5, tmp, tmp8, tmp11, tmp14, tmp17, tmp20, tmp23, tmp26] -> {  :  }
9; CHECK-NEXT:    Invalid Context:
10; CHECK-NEXT:    [tmp5, tmp, tmp8, tmp11, tmp14, tmp17, tmp20, tmp23, tmp26] -> {  : false }
11;
12; CHECK:         Stmt_FINAL
13; CHECK-NEXT:            Domain :=
14; CHECK-NEXT:                [tmp5, tmp, tmp8, tmp11, tmp14, tmp17, tmp20, tmp23, tmp26] -> { Stmt_FINAL[] };
15; CHECK-NEXT:            Schedule :=
16; CHECK-NEXT:                [tmp5, tmp, tmp8, tmp11, tmp14, tmp17, tmp20, tmp23, tmp26] -> { Stmt_FINAL[] -> [16] };
17;
18;
19;    void f(short *restrict In, int *restrict Out) {
20;      int InV, V, Idx;
21;      Idx = 0;
22;      V = 999;
23;
24;    A0:
25;      InV = In[Idx++];
26;      if (InV < V + 42) {
27;      B0:
28;        V = V + 42;
29;        Out[V]++;
30;      } else {
31;      C0:
32;        V = InV;
33;        Out[V]--;
34;      }
35;
36;    A1:
37;      InV = In[Idx++];
38;      if (InV < V + 42) {
39;      B1:
40;        V = V + 42;
41;        Out[V]++;
42;      } else {
43;      C1:
44;        V = InV;
45;        Out[V]--;
46;      }
47;      V = 999;
48;
49;    A2:
50;      InV = In[Idx++];
51;      if (InV < V + 42) {
52;      B2:
53;        V = V + 42;
54;        Out[V]++;
55;      } else {
56;      C2:
57;        V = InV;
58;        Out[V]--;
59;      }
60;
61;    A3:
62;      InV = In[Idx++];
63;      if (InV < V + 42) {
64;      B3:
65;        V = V + 42;
66;        Out[V]++;
67;      } else {
68;      C3:
69;        V = InV;
70;        Out[V]--;
71;      }
72;      V = 999;
73;
74;    A4:
75;      InV = In[Idx++];
76;      if (InV < V + 42) {
77;      B4:
78;        V = V + 42;
79;        Out[V]++;
80;      } else {
81;      C4:
82;        V = InV;
83;        Out[V]--;
84;      }
85;
86;    A5:
87;      InV = In[Idx++];
88;      if (InV < V + 42) {
89;      B5:
90;        V = V + 42;
91;        Out[V]++;
92;      } else {
93;      C5:
94;        V = InV;
95;        Out[V]--;
96;      }
97;      V = 999;
98;
99;    A6:
100;      InV = In[Idx++];
101;      if (InV < V + 42) {
102;      B6:
103;        V = V + 42;
104;        Out[V]++;
105;      } else {
106;      C6:
107;        V = InV;
108;        Out[V]--;
109;      }
110;
111;    A7:
112;      InV = In[Idx++];
113;      if (InV < V + 42) {
114;      B7:
115;        V = V + 42;
116;        Out[V]++;
117;      } else {
118;      C7:
119;        V = InV;
120;        Out[V]--;
121;      }
122;      V = 999;
123;
124;    A8:
125;      InV = In[Idx++];
126;      if (InV < V + 42) {
127;      B8:
128;        V = V + 42;
129;        Out[V]++;
130;      } else {
131;      C8:
132;        V = InV;
133;        Out[V]--;
134;      }
135;    FINAL:
136;      Out[V]++;
137;
138;    ScopExit:
139;      return;
140;    }
141;
142target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
143
144define void @f(i16* noalias %In, i32* noalias %Out) {
145entry:
146  %tmp = load i16, i16* %In, align 2
147  %conv = sext i16 %tmp to i32
148  %cmp = icmp slt i16 %tmp, 1041
149  br i1 %cmp, label %B0, label %C0
150
151B0:                                               ; preds = %entry
152  %arrayidx4 = getelementptr inbounds i32, i32* %Out, i64 1041
153  %tmp3 = load i32, i32* %arrayidx4, align 4
154  %inc5 = add nsw i32 %tmp3, 1
155  store i32 %inc5, i32* %arrayidx4, align 4
156  br label %A1
157
158C0:                                               ; preds = %entry
159  %idxprom6 = sext i16 %tmp to i64
160  %arrayidx7 = getelementptr inbounds i32, i32* %Out, i64 %idxprom6
161  %tmp4 = load i32, i32* %arrayidx7, align 4
162  %dec = add nsw i32 %tmp4, -1
163  store i32 %dec, i32* %arrayidx7, align 4
164  br label %A1
165
166A1:                                               ; preds = %B0, %C0
167  %V.0 = phi i32 [ 1041, %B0 ], [ %conv, %C0 ]
168  %arrayidx10 = getelementptr inbounds i16, i16* %In, i64 1
169  %tmp5 = load i16, i16* %arrayidx10, align 2
170  %conv11 = sext i16 %tmp5 to i32
171  %add12 = add nsw i32 %V.0, 42
172  %cmp13 = icmp slt i32 %conv11, %add12
173  br i1 %cmp13, label %B1, label %C1
174
175B1:                                               ; preds = %A1
176  %add16 = add nsw i32 %V.0, 42
177  %idxprom17 = sext i32 %add16 to i64
178  %arrayidx18 = getelementptr inbounds i32, i32* %Out, i64 %idxprom17
179  %tmp6 = load i32, i32* %arrayidx18, align 4
180  %inc19 = add nsw i32 %tmp6, 1
181  store i32 %inc19, i32* %arrayidx18, align 4
182  br label %A2
183
184C1:                                               ; preds = %A1
185  %idxprom21 = sext i16 %tmp5 to i64
186  %arrayidx22 = getelementptr inbounds i32, i32* %Out, i64 %idxprom21
187  %tmp7 = load i32, i32* %arrayidx22, align 4
188  %dec23 = add nsw i32 %tmp7, -1
189  store i32 %dec23, i32* %arrayidx22, align 4
190  br label %A2
191
192A2:                                               ; preds = %B1, %C1
193  %arrayidx27 = getelementptr inbounds i16, i16* %In, i64 2
194  %tmp8 = load i16, i16* %arrayidx27, align 2
195  %conv28 = sext i16 %tmp8 to i32
196  %cmp30 = icmp slt i16 %tmp8, 1041
197  br i1 %cmp30, label %B2, label %C2
198
199B2:                                               ; preds = %A2
200  %arrayidx35 = getelementptr inbounds i32, i32* %Out, i64 1041
201  %tmp9 = load i32, i32* %arrayidx35, align 4
202  %inc36 = add nsw i32 %tmp9, 1
203  store i32 %inc36, i32* %arrayidx35, align 4
204  br label %A3
205
206C2:                                               ; preds = %A2
207  %idxprom38 = sext i16 %tmp8 to i64
208  %arrayidx39 = getelementptr inbounds i32, i32* %Out, i64 %idxprom38
209  %tmp10 = load i32, i32* %arrayidx39, align 4
210  %dec40 = add nsw i32 %tmp10, -1
211  store i32 %dec40, i32* %arrayidx39, align 4
212  br label %A3
213
214A3:                                               ; preds = %B2, %C2
215  %V.1 = phi i32 [ 1041, %B2 ], [ %conv28, %C2 ]
216  %arrayidx44 = getelementptr inbounds i16, i16* %In, i64 3
217  %tmp11 = load i16, i16* %arrayidx44, align 2
218  %conv45 = sext i16 %tmp11 to i32
219  %add46 = add nsw i32 %V.1, 42
220  %cmp47 = icmp slt i32 %conv45, %add46
221  br i1 %cmp47, label %B3, label %C3
222
223B3:                                               ; preds = %A3
224  %add50 = add nsw i32 %V.1, 42
225  %idxprom51 = sext i32 %add50 to i64
226  %arrayidx52 = getelementptr inbounds i32, i32* %Out, i64 %idxprom51
227  %tmp12 = load i32, i32* %arrayidx52, align 4
228  %inc53 = add nsw i32 %tmp12, 1
229  store i32 %inc53, i32* %arrayidx52, align 4
230  br label %A4
231
232C3:                                               ; preds = %A3
233  %idxprom55 = sext i16 %tmp11 to i64
234  %arrayidx56 = getelementptr inbounds i32, i32* %Out, i64 %idxprom55
235  %tmp13 = load i32, i32* %arrayidx56, align 4
236  %dec57 = add nsw i32 %tmp13, -1
237  store i32 %dec57, i32* %arrayidx56, align 4
238  br label %A4
239
240A4:                                               ; preds = %B3, %C3
241  %arrayidx61 = getelementptr inbounds i16, i16* %In, i64 4
242  %tmp14 = load i16, i16* %arrayidx61, align 2
243  %conv62 = sext i16 %tmp14 to i32
244  %cmp64 = icmp slt i16 %tmp14, 1041
245  br i1 %cmp64, label %B4, label %C4
246
247B4:                                               ; preds = %A4
248  %arrayidx69 = getelementptr inbounds i32, i32* %Out, i64 1041
249  %tmp15 = load i32, i32* %arrayidx69, align 4
250  %inc70 = add nsw i32 %tmp15, 1
251  store i32 %inc70, i32* %arrayidx69, align 4
252  br label %A5
253
254C4:                                               ; preds = %A4
255  %idxprom72 = sext i16 %tmp14 to i64
256  %arrayidx73 = getelementptr inbounds i32, i32* %Out, i64 %idxprom72
257  %tmp16 = load i32, i32* %arrayidx73, align 4
258  %dec74 = add nsw i32 %tmp16, -1
259  store i32 %dec74, i32* %arrayidx73, align 4
260  %phitmp = add nsw i32 %conv62, 42
261  br label %A5
262
263A5:                                               ; preds = %B4, %C4
264  %V.2 = phi i32 [ 1083, %B4 ], [ %phitmp, %C4 ]
265  %arrayidx78 = getelementptr inbounds i16, i16* %In, i64 5
266  %tmp17 = load i16, i16* %arrayidx78, align 2
267  %conv79 = sext i16 %tmp17 to i32
268  %cmp81 = icmp slt i32 %conv79, %V.2
269  br i1 %cmp81, label %B5, label %C5
270
271B5:                                               ; preds = %A5
272  %idxprom85 = sext i32 %V.2 to i64
273  %arrayidx86 = getelementptr inbounds i32, i32* %Out, i64 %idxprom85
274  %tmp18 = load i32, i32* %arrayidx86, align 4
275  %inc87 = add nsw i32 %tmp18, 1
276  store i32 %inc87, i32* %arrayidx86, align 4
277  br label %A6
278
279C5:                                               ; preds = %A5
280  %idxprom89 = sext i16 %tmp17 to i64
281  %arrayidx90 = getelementptr inbounds i32, i32* %Out, i64 %idxprom89
282  %tmp19 = load i32, i32* %arrayidx90, align 4
283  %dec91 = add nsw i32 %tmp19, -1
284  store i32 %dec91, i32* %arrayidx90, align 4
285  br label %A6
286
287A6:                                               ; preds = %B5, %C5
288  %arrayidx95 = getelementptr inbounds i16, i16* %In, i64 6
289  %tmp20 = load i16, i16* %arrayidx95, align 2
290  %conv96 = sext i16 %tmp20 to i32
291  %cmp98 = icmp slt i16 %tmp20, 1041
292  br i1 %cmp98, label %B6, label %C6
293
294B6:                                               ; preds = %A6
295  %arrayidx103 = getelementptr inbounds i32, i32* %Out, i64 1041
296  %tmp21 = load i32, i32* %arrayidx103, align 4
297  %inc104 = add nsw i32 %tmp21, 1
298  store i32 %inc104, i32* %arrayidx103, align 4
299  br label %A7
300
301C6:                                               ; preds = %A6
302  %idxprom106 = sext i16 %tmp20 to i64
303  %arrayidx107 = getelementptr inbounds i32, i32* %Out, i64 %idxprom106
304  %tmp22 = load i32, i32* %arrayidx107, align 4
305  %dec108 = add nsw i32 %tmp22, -1
306  store i32 %dec108, i32* %arrayidx107, align 4
307  %phitmp1 = add nsw i32 %conv96, 42
308  br label %A7
309
310A7:                                               ; preds = %B6, %C6
311  %V.3 = phi i32 [ 1083, %B6 ], [ %phitmp1, %C6 ]
312  %arrayidx112 = getelementptr inbounds i16, i16* %In, i64 7
313  %tmp23 = load i16, i16* %arrayidx112, align 2
314  %conv113 = sext i16 %tmp23 to i32
315  %cmp115 = icmp slt i32 %conv113, %V.3
316  br i1 %cmp115, label %B7, label %C7
317
318B7:                                               ; preds = %A7
319  %idxprom119 = sext i32 %V.3 to i64
320  %arrayidx120 = getelementptr inbounds i32, i32* %Out, i64 %idxprom119
321  %tmp24 = load i32, i32* %arrayidx120, align 4
322  %inc121 = add nsw i32 %tmp24, 1
323  store i32 %inc121, i32* %arrayidx120, align 4
324  br label %A8
325
326C7:                                               ; preds = %A7
327  %idxprom123 = sext i16 %tmp23 to i64
328  %arrayidx124 = getelementptr inbounds i32, i32* %Out, i64 %idxprom123
329  %tmp25 = load i32, i32* %arrayidx124, align 4
330  %dec125 = add nsw i32 %tmp25, -1
331  store i32 %dec125, i32* %arrayidx124, align 4
332  br label %A8
333
334A8:                                               ; preds = %B7, %C7
335  %arrayidx129 = getelementptr inbounds i16, i16* %In, i64 8
336  %tmp26 = load i16, i16* %arrayidx129, align 2
337  %cmp132 = icmp slt i16 %tmp26, 1041
338  br i1 %cmp132, label %B8, label %C8
339
340B8:                                               ; preds = %A8
341  %arrayidx137 = getelementptr inbounds i32, i32* %Out, i64 1041
342  %tmp27 = load i32, i32* %arrayidx137, align 4
343  %inc138 = add nsw i32 %tmp27, 1
344  store i32 %inc138, i32* %arrayidx137, align 4
345  br label %FINAL
346
347C8:                                               ; preds = %A8
348  %idxprom140 = sext i16 %tmp26 to i64
349  %arrayidx141 = getelementptr inbounds i32, i32* %Out, i64 %idxprom140
350  %tmp28 = load i32, i32* %arrayidx141, align 4
351  %dec142 = add nsw i32 %tmp28, -1
352  store i32 %dec142, i32* %arrayidx141, align 4
353  %phitmp2 = sext i16 %tmp26 to i64
354  br label %FINAL
355
356FINAL:                                        ; preds = %C8, %B8
357  %V.4 = phi i64 [ 1041, %B8 ], [ %phitmp2, %C8 ]
358  %arrayidx145 = getelementptr inbounds i32, i32* %Out, i64 %V.4
359  %tmp29 = load i32, i32* %arrayidx145, align 4
360  %inc146 = add nsw i32 %tmp29, 1
361  store i32 %inc146, i32* %arrayidx145, align 4
362  br label %ScopExit
363
364ScopExit:
365  ret void
366}
367