1283015SdimPull in r223170 from upstream llvm trunk (by Michael Zolotukhin):
2283015Sdim
3283015Sdim  Apply loop-rotate to several vectorizer tests.
4283015Sdim
5283015Sdim  Such loops shouldn't be vectorized due to the loops form.
6283015Sdim  After applying loop-rotate (+simplifycfg) the tests again start to check
7283015Sdim  what they are intended to check.
8283015Sdim
9275651SdimPull in r223171 from upstream llvm trunk (by Michael Zolotukhin):
10275651Sdim
11275651Sdim  PR21302. Vectorize only bottom-tested loops.
12275651Sdim
13275651Sdim  rdar://problem/18886083
14275651Sdim
15275651SdimThis fixes a bug in the llvm vectorizer, which could sometimes cause
16275651Sdimvectorized loops to perform an additional iteration, leading to possible
17275651Sdimbuffer overruns.  Symptoms of this, which are usually segfaults, were
18275651Sdimfirst noticed when building gcc ports, here:
19275651Sdim
20275651Sdimhttps://lists.freebsd.org/pipermail/freebsd-ports/2014-September/095466.html
21275651Sdimhttps://lists.freebsd.org/pipermail/freebsd-toolchain/2014-September/001211.html
22275651Sdim
23275651SdimIntroduced here: http://svnweb.freebsd.org/changeset/base/275633
24275651Sdim
25275651SdimIndex: lib/Transforms/Vectorize/LoopVectorize.cpp
26275651Sdim===================================================================
27283015Sdim--- lib/Transforms/Vectorize/LoopVectorize.cpp
28283015Sdim+++ lib/Transforms/Vectorize/LoopVectorize.cpp
29275651Sdim@@ -2864,6 +2864,14 @@ bool LoopVectorizationLegality::canVectorize() {
30275651Sdim   if (!TheLoop->getExitingBlock())
31275651Sdim     return false;
32275651Sdim 
33275651Sdim+  // We only handle bottom-tested loops, i.e. loop in which the condition is
34275651Sdim+  // checked at the end of each iteration. With that we can assume that all
35275651Sdim+  // instructions in the loop are executed the same number of times.
36275651Sdim+  if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) {
37275651Sdim+    DEBUG(dbgs() << "LV: loop control flow is not understood by vectorizer\n");
38275651Sdim+    return false;
39275651Sdim+  }
40275651Sdim+
41275651Sdim   // We need to have a loop header.
42275651Sdim   DEBUG(dbgs() << "LV: Found a loop: " <<
43275651Sdim         TheLoop->getHeader()->getName() << '\n');
44275651SdimIndex: test/Transforms/LoopVectorize/loop-form.ll
45275651Sdim===================================================================
46283015Sdim--- test/Transforms/LoopVectorize/loop-form.ll
47283015Sdim+++ test/Transforms/LoopVectorize/loop-form.ll
48275651Sdim@@ -0,0 +1,31 @@
49275651Sdim+; RUN: opt -S -loop-vectorize < %s | FileCheck %s
50283015Sdim+target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
51275651Sdim+
52275651Sdim+; Check that we vectorize only bottom-tested loops.
53275651Sdim+; This is a reduced testcase from PR21302.
54275651Sdim+;
55275651Sdim+; rdar://problem/18886083
56275651Sdim+
57275651Sdim+%struct.X = type { i32, i16 }
58275651Sdim+; CHECK-LABEL: @foo(
59275651Sdim+; CHECK-NOT: vector.body
60275651Sdim+
61275651Sdim+define void @foo(i32 %n) {
62275651Sdim+entry:
63275651Sdim+  br label %for.cond
64275651Sdim+
65275651Sdim+for.cond:
66275651Sdim+  %i = phi i32 [ 0, %entry ], [ %inc, %for.body ]
67275651Sdim+  %cmp = icmp slt i32 %i, %n
68275651Sdim+  br i1 %cmp, label %for.body, label %if.end
69275651Sdim+
70275651Sdim+for.body:
71275651Sdim+  %iprom = sext i32 %i to i64
72275651Sdim+  %b = getelementptr inbounds %struct.X* undef, i64 %iprom, i32 1
73275651Sdim+  store i16 0, i16* %b, align 4
74275651Sdim+  %inc = add nsw i32 %i, 1
75275651Sdim+  br label %for.cond
76275651Sdim+
77275651Sdim+if.end:
78275651Sdim+  ret void
79275651Sdim+}
80283015SdimIndex: test/Transforms/LoopVectorize/runtime-check-address-space.ll
81283015Sdim===================================================================
82283015Sdim--- test/Transforms/LoopVectorize/runtime-check-address-space.ll
83283015Sdim+++ test/Transforms/LoopVectorize/runtime-check-address-space.ll
84283015Sdim@@ -31,25 +31,23 @@ define void @foo(i32 addrspace(1)* %a, i32 addrspa
85283015Sdim ; CHECK: ret
86283015Sdim 
87283015Sdim entry:
88283015Sdim-  br label %for.cond
89283015Sdim+  %cmp1 = icmp slt i32 0, %n
90283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
91283015Sdim 
92283015Sdim-for.cond:                                         ; preds = %for.body, %entry
93283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
94283015Sdim-  %cmp = icmp slt i32 %i.0, %n
95283015Sdim-  br i1 %cmp, label %for.body, label %for.end
96283015Sdim-
97283015Sdim-for.body:                                         ; preds = %for.cond
98283015Sdim-  %idxprom = sext i32 %i.0 to i64
99283015Sdim+for.body:                                         ; preds = %entry, %for.body
100283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
101283015Sdim+  %idxprom = sext i32 %i.02 to i64
102283015Sdim   %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom
103283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
104283015Sdim   %mul = mul nsw i32 %0, 3
105283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
106283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
107283015Sdim   %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %idxprom1
108283015Sdim   store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
109283015Sdim-  %inc = add nsw i32 %i.0, 1
110283015Sdim-  br label %for.cond
111283015Sdim+  %inc = add nsw i32 %i.02, 1
112283015Sdim+  %cmp = icmp slt i32 %inc, %n
113283015Sdim+  br i1 %cmp, label %for.body, label %for.end
114283015Sdim 
115283015Sdim-for.end:                                          ; preds = %for.cond
116283015Sdim+for.end:                                          ; preds = %for.body, %entry
117283015Sdim   ret void
118283015Sdim }
119283015Sdim 
120283015Sdim@@ -60,25 +58,23 @@ define void @bar0(i32* %a, i32 addrspace(1)* %b, i
121283015Sdim ; CHECK: ret
122283015Sdim 
123283015Sdim entry:
124283015Sdim-  br label %for.cond
125283015Sdim+  %cmp1 = icmp slt i32 0, %n
126283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
127283015Sdim 
128283015Sdim-for.cond:                                         ; preds = %for.body, %entry
129283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
130283015Sdim-  %cmp = icmp slt i32 %i.0, %n
131283015Sdim-  br i1 %cmp, label %for.body, label %for.end
132283015Sdim-
133283015Sdim-for.body:                                         ; preds = %for.cond
134283015Sdim-  %idxprom = sext i32 %i.0 to i64
135283015Sdim+for.body:                                         ; preds = %entry, %for.body
136283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
137283015Sdim+  %idxprom = sext i32 %i.02 to i64
138283015Sdim   %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom
139283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
140283015Sdim   %mul = mul nsw i32 %0, 3
141283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
142283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
143283015Sdim   %arrayidx2 = getelementptr inbounds i32* %a, i64 %idxprom1
144283015Sdim   store i32 %mul, i32* %arrayidx2, align 4
145283015Sdim-  %inc = add nsw i32 %i.0, 1
146283015Sdim-  br label %for.cond
147283015Sdim+  %inc = add nsw i32 %i.02, 1
148283015Sdim+  %cmp = icmp slt i32 %inc, %n
149283015Sdim+  br i1 %cmp, label %for.body, label %for.end
150283015Sdim 
151283015Sdim-for.end:                                          ; preds = %for.cond
152283015Sdim+for.end:                                          ; preds = %for.body, %entry
153283015Sdim   ret void
154283015Sdim }
155283015Sdim 
156283015Sdim@@ -89,25 +85,23 @@ define void @bar1(i32 addrspace(1)* %a, i32* %b, i
157283015Sdim ; CHECK: ret
158283015Sdim 
159283015Sdim entry:
160283015Sdim-  br label %for.cond
161283015Sdim+  %cmp1 = icmp slt i32 0, %n
162283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
163283015Sdim 
164283015Sdim-for.cond:                                         ; preds = %for.body, %entry
165283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
166283015Sdim-  %cmp = icmp slt i32 %i.0, %n
167283015Sdim-  br i1 %cmp, label %for.body, label %for.end
168283015Sdim-
169283015Sdim-for.body:                                         ; preds = %for.cond
170283015Sdim-  %idxprom = sext i32 %i.0 to i64
171283015Sdim+for.body:                                         ; preds = %entry, %for.body
172283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
173283015Sdim+  %idxprom = sext i32 %i.02 to i64
174283015Sdim   %arrayidx = getelementptr inbounds i32* %b, i64 %idxprom
175283015Sdim   %0 = load i32* %arrayidx, align 4
176283015Sdim   %mul = mul nsw i32 %0, 3
177283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
178283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
179283015Sdim   %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %idxprom1
180283015Sdim   store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
181283015Sdim-  %inc = add nsw i32 %i.0, 1
182283015Sdim-  br label %for.cond
183283015Sdim+  %inc = add nsw i32 %i.02, 1
184283015Sdim+  %cmp = icmp slt i32 %inc, %n
185283015Sdim+  br i1 %cmp, label %for.body, label %for.end
186283015Sdim 
187283015Sdim-for.end:                                          ; preds = %for.cond
188283015Sdim+for.end:                                          ; preds = %for.body, %entry
189283015Sdim   ret void
190283015Sdim }
191283015Sdim 
192283015Sdim@@ -119,25 +113,23 @@ define void @bar2(i32* noalias %a, i32 addrspace(1
193283015Sdim ; CHECK: ret
194283015Sdim 
195283015Sdim entry:
196283015Sdim-  br label %for.cond
197283015Sdim+  %cmp1 = icmp slt i32 0, %n
198283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
199283015Sdim 
200283015Sdim-for.cond:                                         ; preds = %for.body, %entry
201283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
202283015Sdim-  %cmp = icmp slt i32 %i.0, %n
203283015Sdim-  br i1 %cmp, label %for.body, label %for.end
204283015Sdim-
205283015Sdim-for.body:                                         ; preds = %for.cond
206283015Sdim-  %idxprom = sext i32 %i.0 to i64
207283015Sdim+for.body:                                         ; preds = %entry, %for.body
208283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
209283015Sdim+  %idxprom = sext i32 %i.02 to i64
210283015Sdim   %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %idxprom
211283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
212283015Sdim   %mul = mul nsw i32 %0, 3
213283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
214283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
215283015Sdim   %arrayidx2 = getelementptr inbounds i32* %a, i64 %idxprom1
216283015Sdim   store i32 %mul, i32* %arrayidx2, align 4
217283015Sdim-  %inc = add nsw i32 %i.0, 1
218283015Sdim-  br label %for.cond
219283015Sdim+  %inc = add nsw i32 %i.02, 1
220283015Sdim+  %cmp = icmp slt i32 %inc, %n
221283015Sdim+  br i1 %cmp, label %for.body, label %for.end
222283015Sdim 
223283015Sdim-for.end:                                          ; preds = %for.cond
224283015Sdim+for.end:                                          ; preds = %for.body, %entry
225283015Sdim   ret void
226283015Sdim }
227283015Sdim 
228283015Sdim@@ -149,25 +141,23 @@ define void @arst0(i32* %b, i32 %n) #0 {
229283015Sdim ; CHECK: ret
230283015Sdim 
231283015Sdim entry:
232283015Sdim-  br label %for.cond
233283015Sdim+  %cmp1 = icmp slt i32 0, %n
234283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
235283015Sdim 
236283015Sdim-for.cond:                                         ; preds = %for.body, %entry
237283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
238283015Sdim-  %cmp = icmp slt i32 %i.0, %n
239283015Sdim-  br i1 %cmp, label %for.body, label %for.end
240283015Sdim-
241283015Sdim-for.body:                                         ; preds = %for.cond
242283015Sdim-  %idxprom = sext i32 %i.0 to i64
243283015Sdim+for.body:                                         ; preds = %entry, %for.body
244283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
245283015Sdim+  %idxprom = sext i32 %i.02 to i64
246283015Sdim   %arrayidx = getelementptr inbounds i32* %b, i64 %idxprom
247283015Sdim   %0 = load i32* %arrayidx, align 4
248283015Sdim   %mul = mul nsw i32 %0, 3
249283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
250283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
251283015Sdim   %arrayidx2 = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom1
252283015Sdim   store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
253283015Sdim-  %inc = add nsw i32 %i.0, 1
254283015Sdim-  br label %for.cond
255283015Sdim+  %inc = add nsw i32 %i.02, 1
256283015Sdim+  %cmp = icmp slt i32 %inc, %n
257283015Sdim+  br i1 %cmp, label %for.body, label %for.end
258283015Sdim 
259283015Sdim-for.end:                                          ; preds = %for.cond
260283015Sdim+for.end:                                          ; preds = %for.body, %entry
261283015Sdim   ret void
262283015Sdim }
263283015Sdim 
264283015Sdim@@ -180,25 +170,23 @@ define void @arst1(i32* %b, i32 %n) #0 {
265283015Sdim ; CHECK: ret
266283015Sdim 
267283015Sdim entry:
268283015Sdim-  br label %for.cond
269283015Sdim+  %cmp1 = icmp slt i32 0, %n
270283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
271283015Sdim 
272283015Sdim-for.cond:                                         ; preds = %for.body, %entry
273283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
274283015Sdim-  %cmp = icmp slt i32 %i.0, %n
275283015Sdim-  br i1 %cmp, label %for.body, label %for.end
276283015Sdim-
277283015Sdim-for.body:                                         ; preds = %for.cond
278283015Sdim-  %idxprom = sext i32 %i.0 to i64
279283015Sdim+for.body:                                         ; preds = %entry, %for.body
280283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
281283015Sdim+  %idxprom = sext i32 %i.02 to i64
282283015Sdim   %arrayidx = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom
283283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
284283015Sdim   %mul = mul nsw i32 %0, 3
285283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
286283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
287283015Sdim   %arrayidx2 = getelementptr inbounds i32* %b, i64 %idxprom1
288283015Sdim   store i32 %mul, i32* %arrayidx2, align 4
289283015Sdim-  %inc = add nsw i32 %i.0, 1
290283015Sdim-  br label %for.cond
291283015Sdim+  %inc = add nsw i32 %i.02, 1
292283015Sdim+  %cmp = icmp slt i32 %inc, %n
293283015Sdim+  br i1 %cmp, label %for.body, label %for.end
294283015Sdim 
295283015Sdim-for.end:                                          ; preds = %for.cond
296283015Sdim+for.end:                                          ; preds = %for.body, %entry
297283015Sdim   ret void
298283015Sdim }
299283015Sdim 
300283015Sdim@@ -210,25 +198,23 @@ define void @aoeu(i32 %n) #0 {
301283015Sdim ; CHECK: ret
302283015Sdim 
303283015Sdim entry:
304283015Sdim-  br label %for.cond
305283015Sdim+  %cmp1 = icmp slt i32 0, %n
306283015Sdim+  br i1 %cmp1, label %for.body, label %for.end
307283015Sdim 
308283015Sdim-for.cond:                                         ; preds = %for.body, %entry
309283015Sdim-  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
310283015Sdim-  %cmp = icmp slt i32 %i.0, %n
311283015Sdim-  br i1 %cmp, label %for.body, label %for.end
312283015Sdim-
313283015Sdim-for.body:                                         ; preds = %for.cond
314283015Sdim-  %idxprom = sext i32 %i.0 to i64
315283015Sdim+for.body:                                         ; preds = %entry, %for.body
316283015Sdim+  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
317283015Sdim+  %idxprom = sext i32 %i.02 to i64
318283015Sdim   %arrayidx = getelementptr inbounds [1024 x i32] addrspace(2)* @q_as2, i64 0, i64 %idxprom
319283015Sdim   %0 = load i32 addrspace(2)* %arrayidx, align 4
320283015Sdim   %mul = mul nsw i32 %0, 3
321283015Sdim-  %idxprom1 = sext i32 %i.0 to i64
322283015Sdim+  %idxprom1 = sext i32 %i.02 to i64
323283015Sdim   %arrayidx2 = getelementptr inbounds [1024 x i32] addrspace(1)* @g_as1, i64 0, i64 %idxprom1
324283015Sdim   store i32 %mul, i32 addrspace(1)* %arrayidx2, align 4
325283015Sdim-  %inc = add nsw i32 %i.0, 1
326283015Sdim-  br label %for.cond
327283015Sdim+  %inc = add nsw i32 %i.02, 1
328283015Sdim+  %cmp = icmp slt i32 %inc, %n
329283015Sdim+  br i1 %cmp, label %for.body, label %for.end
330283015Sdim 
331283015Sdim-for.end:                                          ; preds = %for.cond
332283015Sdim+for.end:                                          ; preds = %for.body, %entry
333283015Sdim   ret void
334283015Sdim }
335283015Sdim 
336283015SdimIndex: test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll
337283015Sdim===================================================================
338283015Sdim--- test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll
339283015Sdim+++ test/Transforms/LoopVectorize/runtime-check-readonly-address-space.ll
340283015Sdim@@ -8,26 +8,24 @@ define void @add_ints_1_1_1(i32 addrspace(1)* %a,
341283015Sdim ; CHECK-LABEL: @add_ints_1_1_1(
342283015Sdim ; CHECK: <4 x i32>
343283015Sdim ; CHECK: ret
344283015Sdim+
345283015Sdim entry:
346283015Sdim-  br label %for.cond
347283015Sdim+  br label %for.body
348283015Sdim 
349283015Sdim-for.cond:                                         ; preds = %for.body, %entry
350283015Sdim-  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
351283015Sdim-  %cmp = icmp ult i64 %i.0, 200
352283015Sdim-  br i1 %cmp, label %for.body, label %for.end
353283015Sdim-
354283015Sdim-for.body:                                         ; preds = %for.cond
355283015Sdim-  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
356283015Sdim+for.body:                                         ; preds = %entry, %for.body
357283015Sdim+  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
358283015Sdim+  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
359283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
360283015Sdim-  %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.0
361283015Sdim+  %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.01
362283015Sdim   %1 = load i32 addrspace(1)* %arrayidx1, align 4
363283015Sdim   %add = add nsw i32 %0, %1
364283015Sdim-  %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.0
365283015Sdim+  %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.01
366283015Sdim   store i32 %add, i32 addrspace(1)* %arrayidx2, align 4
367283015Sdim-  %inc = add i64 %i.0, 1
368283015Sdim-  br label %for.cond
369283015Sdim+  %inc = add i64 %i.01, 1
370283015Sdim+  %cmp = icmp ult i64 %inc, 200
371283015Sdim+  br i1 %cmp, label %for.body, label %for.end
372283015Sdim 
373283015Sdim-for.end:                                          ; preds = %for.cond
374283015Sdim+for.end:                                          ; preds = %for.body
375283015Sdim   ret void
376283015Sdim }
377283015Sdim 
378283015Sdim@@ -35,26 +33,24 @@ define void @add_ints_as_1_0_0(i32 addrspace(1)* %
379283015Sdim ; CHECK-LABEL: @add_ints_as_1_0_0(
380283015Sdim ; CHECK-NOT: <4 x i32>
381283015Sdim ; CHECK: ret
382283015Sdim+
383283015Sdim entry:
384283015Sdim-  br label %for.cond
385283015Sdim+  br label %for.body
386283015Sdim 
387283015Sdim-for.cond:                                         ; preds = %for.body, %entry
388283015Sdim-  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
389283015Sdim-  %cmp = icmp ult i64 %i.0, 200
390283015Sdim-  br i1 %cmp, label %for.body, label %for.end
391283015Sdim-
392283015Sdim-for.body:                                         ; preds = %for.cond
393283015Sdim-  %arrayidx = getelementptr inbounds i32* %b, i64 %i.0
394283015Sdim+for.body:                                         ; preds = %entry, %for.body
395283015Sdim+  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
396283015Sdim+  %arrayidx = getelementptr inbounds i32* %b, i64 %i.01
397283015Sdim   %0 = load i32* %arrayidx, align 4
398283015Sdim-  %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.0
399283015Sdim+  %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.01
400283015Sdim   %1 = load i32* %arrayidx1, align 4
401283015Sdim   %add = add nsw i32 %0, %1
402283015Sdim-  %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.0
403283015Sdim+  %arrayidx2 = getelementptr inbounds i32 addrspace(1)* %a, i64 %i.01
404283015Sdim   store i32 %add, i32 addrspace(1)* %arrayidx2, align 4
405283015Sdim-  %inc = add i64 %i.0, 1
406283015Sdim-  br label %for.cond
407283015Sdim+  %inc = add i64 %i.01, 1
408283015Sdim+  %cmp = icmp ult i64 %inc, 200
409283015Sdim+  br i1 %cmp, label %for.body, label %for.end
410283015Sdim 
411283015Sdim-for.end:                                          ; preds = %for.cond
412283015Sdim+for.end:                                          ; preds = %for.body
413283015Sdim   ret void
414283015Sdim }
415283015Sdim 
416283015Sdim@@ -62,26 +58,24 @@ define void @add_ints_as_0_1_0(i32* %a, i32 addrsp
417283015Sdim ; CHECK-LABEL: @add_ints_as_0_1_0(
418283015Sdim ; CHECK-NOT: <4 x i32>
419283015Sdim ; CHECK: ret
420283015Sdim+
421283015Sdim entry:
422283015Sdim-  br label %for.cond
423283015Sdim+  br label %for.body
424283015Sdim 
425283015Sdim-for.cond:                                         ; preds = %for.body, %entry
426283015Sdim-  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
427283015Sdim-  %cmp = icmp ult i64 %i.0, 200
428283015Sdim-  br i1 %cmp, label %for.body, label %for.end
429283015Sdim-
430283015Sdim-for.body:                                         ; preds = %for.cond
431283015Sdim-  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
432283015Sdim+for.body:                                         ; preds = %entry, %for.body
433283015Sdim+  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
434283015Sdim+  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
435283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
436283015Sdim-  %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.0
437283015Sdim+  %arrayidx1 = getelementptr inbounds i32* %c, i64 %i.01
438283015Sdim   %1 = load i32* %arrayidx1, align 4
439283015Sdim   %add = add nsw i32 %0, %1
440283015Sdim-  %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0
441283015Sdim+  %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01
442283015Sdim   store i32 %add, i32* %arrayidx2, align 4
443283015Sdim-  %inc = add i64 %i.0, 1
444283015Sdim-  br label %for.cond
445283015Sdim+  %inc = add i64 %i.01, 1
446283015Sdim+  %cmp = icmp ult i64 %inc, 200
447283015Sdim+  br i1 %cmp, label %for.body, label %for.end
448283015Sdim 
449283015Sdim-for.end:                                          ; preds = %for.cond
450283015Sdim+for.end:                                          ; preds = %for.body
451283015Sdim   ret void
452283015Sdim }
453283015Sdim 
454283015Sdim@@ -89,26 +83,24 @@ define void @add_ints_as_0_1_1(i32* %a, i32 addrsp
455283015Sdim ; CHECK-LABEL: @add_ints_as_0_1_1(
456283015Sdim ; CHECK-NOT: <4 x i32>
457283015Sdim ; CHECK: ret
458283015Sdim+
459283015Sdim entry:
460283015Sdim-  br label %for.cond
461283015Sdim+  br label %for.body
462283015Sdim 
463283015Sdim-for.cond:                                         ; preds = %for.body, %entry
464283015Sdim-  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
465283015Sdim-  %cmp = icmp ult i64 %i.0, 200
466283015Sdim-  br i1 %cmp, label %for.body, label %for.end
467283015Sdim-
468283015Sdim-for.body:                                         ; preds = %for.cond
469283015Sdim-  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
470283015Sdim+for.body:                                         ; preds = %entry, %for.body
471283015Sdim+  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
472283015Sdim+  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
473283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
474283015Sdim-  %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.0
475283015Sdim+  %arrayidx1 = getelementptr inbounds i32 addrspace(1)* %c, i64 %i.01
476283015Sdim   %1 = load i32 addrspace(1)* %arrayidx1, align 4
477283015Sdim   %add = add nsw i32 %0, %1
478283015Sdim-  %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0
479283015Sdim+  %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01
480283015Sdim   store i32 %add, i32* %arrayidx2, align 4
481283015Sdim-  %inc = add i64 %i.0, 1
482283015Sdim-  br label %for.cond
483283015Sdim+  %inc = add i64 %i.01, 1
484283015Sdim+  %cmp = icmp ult i64 %inc, 200
485283015Sdim+  br i1 %cmp, label %for.body, label %for.end
486283015Sdim 
487283015Sdim-for.end:                                          ; preds = %for.cond
488283015Sdim+for.end:                                          ; preds = %for.body
489283015Sdim   ret void
490283015Sdim }
491283015Sdim 
492283015Sdim@@ -116,26 +108,24 @@ define void @add_ints_as_0_1_2(i32* %a, i32 addrsp
493283015Sdim ; CHECK-LABEL: @add_ints_as_0_1_2(
494283015Sdim ; CHECK-NOT: <4 x i32>
495283015Sdim ; CHECK: ret
496283015Sdim+
497283015Sdim entry:
498283015Sdim-  br label %for.cond
499283015Sdim+  br label %for.body
500283015Sdim 
501283015Sdim-for.cond:                                         ; preds = %for.body, %entry
502283015Sdim-  %i.0 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
503283015Sdim-  %cmp = icmp ult i64 %i.0, 200
504283015Sdim-  br i1 %cmp, label %for.body, label %for.end
505283015Sdim-
506283015Sdim-for.body:                                         ; preds = %for.cond
507283015Sdim-  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.0
508283015Sdim+for.body:                                         ; preds = %entry, %for.body
509283015Sdim+  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
510283015Sdim+  %arrayidx = getelementptr inbounds i32 addrspace(1)* %b, i64 %i.01
511283015Sdim   %0 = load i32 addrspace(1)* %arrayidx, align 4
512283015Sdim-  %arrayidx1 = getelementptr inbounds i32 addrspace(2)* %c, i64 %i.0
513283015Sdim+  %arrayidx1 = getelementptr inbounds i32 addrspace(2)* %c, i64 %i.01
514283015Sdim   %1 = load i32 addrspace(2)* %arrayidx1, align 4
515283015Sdim   %add = add nsw i32 %0, %1
516283015Sdim-  %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.0
517283015Sdim+  %arrayidx2 = getelementptr inbounds i32* %a, i64 %i.01
518283015Sdim   store i32 %add, i32* %arrayidx2, align 4
519283015Sdim-  %inc = add i64 %i.0, 1
520283015Sdim-  br label %for.cond
521283015Sdim+  %inc = add i64 %i.01, 1
522283015Sdim+  %cmp = icmp ult i64 %inc, 200
523283015Sdim+  br i1 %cmp, label %for.body, label %for.end
524283015Sdim 
525283015Sdim-for.end:                                          ; preds = %for.cond
526283015Sdim+for.end:                                          ; preds = %for.body
527283015Sdim   ret void
528283015Sdim }
529283015Sdim 
530