1f31811f2SFangrui Song; RUN: opt < %s  -basic-aa -loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -dce -instcombine -S | FileCheck %s
2f31811f2SFangrui Song; RUN: opt < %s  -basic-aa -loop-vectorize -force-vector-width=4 -force-vector-interleave=4 -dce -instcombine -S | FileCheck %s -check-prefix=UNROLL
3cee313d2SEric Christopher
4cee313d2SEric Christophertarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
5cee313d2SEric Christopher
6cee313d2SEric Christopher@b = common global [2048 x i32] zeroinitializer, align 16
7cee313d2SEric Christopher@c = common global [2048 x i32] zeroinitializer, align 16
8cee313d2SEric Christopher@a = common global [2048 x i32] zeroinitializer, align 16
9cee313d2SEric Christopher@G = common global [32 x [1024 x i32]] zeroinitializer, align 16
10cee313d2SEric Christopher@ub = common global [1024 x i32] zeroinitializer, align 16
11cee313d2SEric Christopher@uc = common global [1024 x i32] zeroinitializer, align 16
12cee313d2SEric Christopher@d = common global [2048 x i32] zeroinitializer, align 16
13cee313d2SEric Christopher@fa = common global [1024 x float] zeroinitializer, align 16
14cee313d2SEric Christopher@fb = common global [1024 x float] zeroinitializer, align 16
15cee313d2SEric Christopher@ic = common global [1024 x i32] zeroinitializer, align 16
16cee313d2SEric Christopher@da = common global [1024 x float] zeroinitializer, align 16
17cee313d2SEric Christopher@db = common global [1024 x float] zeroinitializer, align 16
18cee313d2SEric Christopher@dc = common global [1024 x float] zeroinitializer, align 16
19cee313d2SEric Christopher@dd = common global [1024 x float] zeroinitializer, align 16
20cee313d2SEric Christopher@dj = common global [1024 x i32] zeroinitializer, align 16
21cee313d2SEric Christopher
22cee313d2SEric Christopher;CHECK-LABEL: @example1(
23cee313d2SEric Christopher;CHECK: load <4 x i32>
24cee313d2SEric Christopher;CHECK: add nsw <4 x i32>
25cee313d2SEric Christopher;CHECK: store <4 x i32>
26cee313d2SEric Christopher;CHECK: ret void
27cee313d2SEric Christopher;UNROLL-LABEL: @example1(
28cee313d2SEric Christopher;UNROLL: load <4 x i32>
29cee313d2SEric Christopher;UNROLL: load <4 x i32>
30cee313d2SEric Christopher;UNROLL: load <4 x i32>
31cee313d2SEric Christopher;UNROLL: load <4 x i32>
32cee313d2SEric Christopher;UNROLL: add nsw <4 x i32>
33cee313d2SEric Christopher;UNROLL: add nsw <4 x i32>
34cee313d2SEric Christopher;UNROLL: add nsw <4 x i32>
35cee313d2SEric Christopher;UNROLL: add nsw <4 x i32>
36cee313d2SEric Christopher;UNROLL: store <4 x i32>
37cee313d2SEric Christopher;UNROLL: store <4 x i32>
38cee313d2SEric Christopher;UNROLL: store <4 x i32>
39cee313d2SEric Christopher;UNROLL: store <4 x i32>
40cee313d2SEric Christopher;UNROLL: ret void
41cee313d2SEric Christopherdefine void @example1() nounwind uwtable ssp {
42cee313d2SEric Christopher  br label %1
43cee313d2SEric Christopher
44cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
45cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
46cee313d2SEric Christopher  %2 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %indvars.iv
47cee313d2SEric Christopher  %3 = load i32, i32* %2, align 4
48cee313d2SEric Christopher  %4 = getelementptr inbounds [2048 x i32], [2048 x i32]* @c, i64 0, i64 %indvars.iv
49cee313d2SEric Christopher  %5 = load i32, i32* %4, align 4
50cee313d2SEric Christopher  %6 = add nsw i32 %5, %3
51cee313d2SEric Christopher  %7 = getelementptr inbounds [2048 x i32], [2048 x i32]* @a, i64 0, i64 %indvars.iv
52cee313d2SEric Christopher  store i32 %6, i32* %7, align 4
53cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
54cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
55cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 256
56cee313d2SEric Christopher  br i1 %exitcond, label %8, label %1
57cee313d2SEric Christopher
58cee313d2SEric Christopher; <label>:8                                       ; preds = %1
59cee313d2SEric Christopher  ret void
60cee313d2SEric Christopher}
61cee313d2SEric Christopher
62cee313d2SEric Christopher;CHECK-LABEL: @example2(
63cee313d2SEric Christopher;CHECK: store <4 x i32>
64cee313d2SEric Christopher;CHECK: ret void
65cee313d2SEric Christopher;UNROLL-LABEL: @example2(
66cee313d2SEric Christopher;UNROLL: store <4 x i32>
67cee313d2SEric Christopher;UNROLL: store <4 x i32>
68cee313d2SEric Christopher;UNROLL: store <4 x i32>
69cee313d2SEric Christopher;UNROLL: store <4 x i32>
70cee313d2SEric Christopher;UNROLL: ret void
71cee313d2SEric Christopherdefine void @example2(i32 %n, i32 %x) nounwind uwtable ssp {
72cee313d2SEric Christopher  %1 = icmp sgt i32 %n, 0
73cee313d2SEric Christopher  br i1 %1, label %.lr.ph5, label %.preheader
74cee313d2SEric Christopher
75cee313d2SEric Christopher..preheader_crit_edge:                            ; preds = %.lr.ph5
76cee313d2SEric Christopher  %phitmp = sext i32 %n to i64
77cee313d2SEric Christopher  br label %.preheader
78cee313d2SEric Christopher
79cee313d2SEric Christopher.preheader:                                       ; preds = %..preheader_crit_edge, %0
80cee313d2SEric Christopher  %i.0.lcssa = phi i64 [ %phitmp, %..preheader_crit_edge ], [ 0, %0 ]
81cee313d2SEric Christopher  %2 = icmp eq i32 %n, 0
82cee313d2SEric Christopher  br i1 %2, label %._crit_edge, label %.lr.ph
83cee313d2SEric Christopher
84cee313d2SEric Christopher.lr.ph5:                                          ; preds = %0, %.lr.ph5
85cee313d2SEric Christopher  %indvars.iv6 = phi i64 [ %indvars.iv.next7, %.lr.ph5 ], [ 0, %0 ]
86cee313d2SEric Christopher  %3 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %indvars.iv6
87cee313d2SEric Christopher  store i32 %x, i32* %3, align 4
88cee313d2SEric Christopher  %indvars.iv.next7 = add i64 %indvars.iv6, 1
89cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next7 to i32
90cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, %n
91cee313d2SEric Christopher  br i1 %exitcond, label %..preheader_crit_edge, label %.lr.ph5
92cee313d2SEric Christopher
93cee313d2SEric Christopher.lr.ph:                                           ; preds = %.preheader, %.lr.ph
94cee313d2SEric Christopher  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %i.0.lcssa, %.preheader ]
95cee313d2SEric Christopher  %.02 = phi i32 [ %4, %.lr.ph ], [ %n, %.preheader ]
96cee313d2SEric Christopher  %4 = add nsw i32 %.02, -1
97cee313d2SEric Christopher  %5 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %indvars.iv
98cee313d2SEric Christopher  %6 = load i32, i32* %5, align 4
99cee313d2SEric Christopher  %7 = getelementptr inbounds [2048 x i32], [2048 x i32]* @c, i64 0, i64 %indvars.iv
100cee313d2SEric Christopher  %8 = load i32, i32* %7, align 4
101cee313d2SEric Christopher  %9 = and i32 %8, %6
102cee313d2SEric Christopher  %10 = getelementptr inbounds [2048 x i32], [2048 x i32]* @a, i64 0, i64 %indvars.iv
103cee313d2SEric Christopher  store i32 %9, i32* %10, align 4
104cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
105cee313d2SEric Christopher  %11 = icmp eq i32 %4, 0
106cee313d2SEric Christopher  br i1 %11, label %._crit_edge, label %.lr.ph
107cee313d2SEric Christopher
108cee313d2SEric Christopher._crit_edge:                                      ; preds = %.lr.ph, %.preheader
109cee313d2SEric Christopher  ret void
110cee313d2SEric Christopher}
111cee313d2SEric Christopher
112cee313d2SEric Christopher;CHECK-LABEL: @example3(
113cee313d2SEric Christopher;CHECK: <4 x i32>
114cee313d2SEric Christopher;CHECK: ret void
115cee313d2SEric Christopher;UNROLL-LABEL: @example3(
116cee313d2SEric Christopher;UNROLL: <4 x i32>
117cee313d2SEric Christopher;UNROLL: <4 x i32>
118cee313d2SEric Christopher;UNROLL: <4 x i32>
119cee313d2SEric Christopher;UNROLL: <4 x i32>
120cee313d2SEric Christopher;UNROLL: ret void
121cee313d2SEric Christopherdefine void @example3(i32 %n, i32* noalias nocapture %p, i32* noalias nocapture %q) nounwind uwtable ssp {
122cee313d2SEric Christopher  %1 = icmp eq i32 %n, 0
123cee313d2SEric Christopher  br i1 %1, label %._crit_edge, label %.lr.ph
124cee313d2SEric Christopher
125cee313d2SEric Christopher.lr.ph:                                           ; preds = %0, %.lr.ph
126cee313d2SEric Christopher  %.05 = phi i32 [ %2, %.lr.ph ], [ %n, %0 ]
127cee313d2SEric Christopher  %.014 = phi i32* [ %5, %.lr.ph ], [ %p, %0 ]
128cee313d2SEric Christopher  %.023 = phi i32* [ %3, %.lr.ph ], [ %q, %0 ]
129cee313d2SEric Christopher  %2 = add nsw i32 %.05, -1
130cee313d2SEric Christopher  %3 = getelementptr inbounds i32, i32* %.023, i64 1
131cee313d2SEric Christopher  %4 = load i32, i32* %.023, align 16
132cee313d2SEric Christopher  %5 = getelementptr inbounds i32, i32* %.014, i64 1
133cee313d2SEric Christopher  store i32 %4, i32* %.014, align 16
134cee313d2SEric Christopher  %6 = icmp eq i32 %2, 0
135cee313d2SEric Christopher  br i1 %6, label %._crit_edge, label %.lr.ph
136cee313d2SEric Christopher
137cee313d2SEric Christopher._crit_edge:                                      ; preds = %.lr.ph, %0
138cee313d2SEric Christopher  ret void
139cee313d2SEric Christopher}
140cee313d2SEric Christopher
141cee313d2SEric Christopher;CHECK-LABEL: @example4(
142cee313d2SEric Christopher;CHECK: load <4 x i32>
143cee313d2SEric Christopher;CHECK: ret void
144cee313d2SEric Christopher;UNROLL-LABEL: @example4(
145cee313d2SEric Christopher;UNROLL: load <4 x i32>
146cee313d2SEric Christopher;UNROLL: load <4 x i32>
147cee313d2SEric Christopher;UNROLL: load <4 x i32>
148cee313d2SEric Christopher;UNROLL: load <4 x i32>
149cee313d2SEric Christopher;UNROLL: ret void
150cee313d2SEric Christopherdefine void @example4(i32 %n, i32* noalias nocapture %p, i32* noalias nocapture %q) nounwind uwtable ssp {
151cee313d2SEric Christopher  %1 = add nsw i32 %n, -1
152cee313d2SEric Christopher  %2 = icmp eq i32 %n, 0
153cee313d2SEric Christopher  br i1 %2, label %.preheader4, label %.lr.ph10
154cee313d2SEric Christopher
155cee313d2SEric Christopher.preheader4:                                      ; preds = %0
156cee313d2SEric Christopher  %3 = icmp sgt i32 %1, 0
157cee313d2SEric Christopher  br i1 %3, label %.lr.ph6, label %._crit_edge
158cee313d2SEric Christopher
159cee313d2SEric Christopher.lr.ph10:                                         ; preds = %0, %.lr.ph10
160cee313d2SEric Christopher  %4 = phi i32 [ %9, %.lr.ph10 ], [ %1, %0 ]
161cee313d2SEric Christopher  %.018 = phi i32* [ %8, %.lr.ph10 ], [ %p, %0 ]
162cee313d2SEric Christopher  %.027 = phi i32* [ %5, %.lr.ph10 ], [ %q, %0 ]
163cee313d2SEric Christopher  %5 = getelementptr inbounds i32, i32* %.027, i64 1
164cee313d2SEric Christopher  %6 = load i32, i32* %.027, align 16
165cee313d2SEric Christopher  %7 = add nsw i32 %6, 5
166cee313d2SEric Christopher  %8 = getelementptr inbounds i32, i32* %.018, i64 1
167cee313d2SEric Christopher  store i32 %7, i32* %.018, align 16
168cee313d2SEric Christopher  %9 = add nsw i32 %4, -1
169cee313d2SEric Christopher  %10 = icmp eq i32 %4, 0
170cee313d2SEric Christopher  br i1 %10, label %._crit_edge, label %.lr.ph10
171cee313d2SEric Christopher
172cee313d2SEric Christopher.preheader:                                       ; preds = %.lr.ph6
173cee313d2SEric Christopher  br i1 %3, label %.lr.ph, label %._crit_edge
174cee313d2SEric Christopher
175cee313d2SEric Christopher.lr.ph6:                                          ; preds = %.preheader4, %.lr.ph6
176cee313d2SEric Christopher  %indvars.iv11 = phi i64 [ %indvars.iv.next12, %.lr.ph6 ], [ 0, %.preheader4 ]
177cee313d2SEric Christopher  %indvars.iv.next12 = add i64 %indvars.iv11, 1
178cee313d2SEric Christopher  %11 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %indvars.iv.next12
179cee313d2SEric Christopher  %12 = load i32, i32* %11, align 4
180cee313d2SEric Christopher  %13 = add nsw i64 %indvars.iv11, 3
181cee313d2SEric Christopher  %14 = getelementptr inbounds [2048 x i32], [2048 x i32]* @c, i64 0, i64 %13
182cee313d2SEric Christopher  %15 = load i32, i32* %14, align 4
183cee313d2SEric Christopher  %16 = add nsw i32 %15, %12
184cee313d2SEric Christopher  %17 = getelementptr inbounds [2048 x i32], [2048 x i32]* @a, i64 0, i64 %indvars.iv11
185cee313d2SEric Christopher  store i32 %16, i32* %17, align 4
186cee313d2SEric Christopher  %lftr.wideiv13 = trunc i64 %indvars.iv.next12 to i32
187cee313d2SEric Christopher  %exitcond14 = icmp eq i32 %lftr.wideiv13, %1
188cee313d2SEric Christopher  br i1 %exitcond14, label %.preheader, label %.lr.ph6
189cee313d2SEric Christopher
190cee313d2SEric Christopher.lr.ph:                                           ; preds = %.preheader, %.lr.ph
191cee313d2SEric Christopher  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader ]
192cee313d2SEric Christopher  %18 = getelementptr inbounds [2048 x i32], [2048 x i32]* @a, i64 0, i64 %indvars.iv
193cee313d2SEric Christopher  %19 = load i32, i32* %18, align 4
194cee313d2SEric Christopher  %20 = icmp sgt i32 %19, 4
195cee313d2SEric Christopher  %21 = select i1 %20, i32 4, i32 0
196cee313d2SEric Christopher  %22 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %indvars.iv
197cee313d2SEric Christopher  store i32 %21, i32* %22, align 4
198cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
199cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
200cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, %1
201cee313d2SEric Christopher  br i1 %exitcond, label %._crit_edge, label %.lr.ph
202cee313d2SEric Christopher
203cee313d2SEric Christopher._crit_edge:                                      ; preds = %.lr.ph10, %.preheader4, %.lr.ph, %.preheader
204cee313d2SEric Christopher  ret void
205cee313d2SEric Christopher}
206cee313d2SEric Christopher
207cee313d2SEric Christopher;CHECK-LABEL: @example8(
208cee313d2SEric Christopher;CHECK: store <4 x i32>
209cee313d2SEric Christopher;CHECK: ret void
210cee313d2SEric Christopher;UNROLL-LABEL: @example8(
211cee313d2SEric Christopher;UNROLL: store <4 x i32>
212cee313d2SEric Christopher;UNROLL: store <4 x i32>
213cee313d2SEric Christopher;UNROLL: store <4 x i32>
214cee313d2SEric Christopher;UNROLL: store <4 x i32>
215cee313d2SEric Christopher;UNROLL: ret void
216cee313d2SEric Christopherdefine void @example8(i32 %x) nounwind uwtable ssp {
217cee313d2SEric Christopher  br label %.preheader
218cee313d2SEric Christopher
219cee313d2SEric Christopher.preheader:                                       ; preds = %3, %0
220cee313d2SEric Christopher  %indvars.iv3 = phi i64 [ 0, %0 ], [ %indvars.iv.next4, %3 ]
221cee313d2SEric Christopher  br label %1
222cee313d2SEric Christopher
223cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %.preheader
224cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %1 ]
225cee313d2SEric Christopher  %2 = getelementptr inbounds [32 x [1024 x i32]], [32 x [1024 x i32]]* @G, i64 0, i64 %indvars.iv3, i64 %indvars.iv
226cee313d2SEric Christopher  store i32 %x, i32* %2, align 4
227cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
228cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
229cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
230cee313d2SEric Christopher  br i1 %exitcond, label %3, label %1
231cee313d2SEric Christopher
232cee313d2SEric Christopher; <label>:3                                       ; preds = %1
233cee313d2SEric Christopher  %indvars.iv.next4 = add i64 %indvars.iv3, 1
234cee313d2SEric Christopher  %lftr.wideiv5 = trunc i64 %indvars.iv.next4 to i32
235cee313d2SEric Christopher  %exitcond6 = icmp eq i32 %lftr.wideiv5, 32
236cee313d2SEric Christopher  br i1 %exitcond6, label %4, label %.preheader
237cee313d2SEric Christopher
238cee313d2SEric Christopher; <label>:4                                       ; preds = %3
239cee313d2SEric Christopher  ret void
240cee313d2SEric Christopher}
241cee313d2SEric Christopher
242cee313d2SEric Christopher;CHECK-LABEL: @example9(
243cee313d2SEric Christopher;CHECK: phi <4 x i32>
244cee313d2SEric Christopher;CHECK: ret i32
245cee313d2SEric Christopherdefine i32 @example9() nounwind uwtable readonly ssp {
246cee313d2SEric Christopher  br label %1
247cee313d2SEric Christopher
248cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
249cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
250cee313d2SEric Christopher  %diff.01 = phi i32 [ 0, %0 ], [ %7, %1 ]
251cee313d2SEric Christopher  %2 = getelementptr inbounds [1024 x i32], [1024 x i32]* @ub, i64 0, i64 %indvars.iv
252cee313d2SEric Christopher  %3 = load i32, i32* %2, align 4
253cee313d2SEric Christopher  %4 = getelementptr inbounds [1024 x i32], [1024 x i32]* @uc, i64 0, i64 %indvars.iv
254cee313d2SEric Christopher  %5 = load i32, i32* %4, align 4
255cee313d2SEric Christopher  %6 = add i32 %3, %diff.01
256cee313d2SEric Christopher  %7 = sub i32 %6, %5
257cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
258cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
259cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
260cee313d2SEric Christopher  br i1 %exitcond, label %8, label %1
261cee313d2SEric Christopher
262cee313d2SEric Christopher; <label>:8                                       ; preds = %1
263cee313d2SEric Christopher  ret i32 %7
264cee313d2SEric Christopher}
265cee313d2SEric Christopher
266cee313d2SEric Christopher;CHECK-LABEL: @example10a(
267cee313d2SEric Christopher;CHECK: load <4 x i32>
268cee313d2SEric Christopher;CHECK: add nsw <4 x i32>
269cee313d2SEric Christopher;CHECK: load <4 x i16>
270cee313d2SEric Christopher;CHECK: add <4 x i16>
271cee313d2SEric Christopher;CHECK: store <4 x i16>
272cee313d2SEric Christopher;CHECK: ret void
273cee313d2SEric Christopherdefine void @example10a(i16* noalias nocapture %sa, i16* noalias nocapture %sb, i16* noalias nocapture %sc, i32* noalias nocapture %ia, i32* noalias nocapture %ib, i32* noalias nocapture %ic) nounwind uwtable ssp {
274cee313d2SEric Christopher  br label %1
275cee313d2SEric Christopher
276cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
277cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
278cee313d2SEric Christopher  %2 = getelementptr inbounds i32, i32* %ib, i64 %indvars.iv
279cee313d2SEric Christopher  %3 = load i32, i32* %2, align 4
280cee313d2SEric Christopher  %4 = getelementptr inbounds i32, i32* %ic, i64 %indvars.iv
281cee313d2SEric Christopher  %5 = load i32, i32* %4, align 4
282cee313d2SEric Christopher  %6 = add nsw i32 %5, %3
283cee313d2SEric Christopher  %7 = getelementptr inbounds i32, i32* %ia, i64 %indvars.iv
284cee313d2SEric Christopher  store i32 %6, i32* %7, align 4
285cee313d2SEric Christopher  %8 = getelementptr inbounds i16, i16* %sb, i64 %indvars.iv
286cee313d2SEric Christopher  %9 = load i16, i16* %8, align 2
287cee313d2SEric Christopher  %10 = getelementptr inbounds i16, i16* %sc, i64 %indvars.iv
288cee313d2SEric Christopher  %11 = load i16, i16* %10, align 2
289cee313d2SEric Christopher  %12 = add i16 %11, %9
290cee313d2SEric Christopher  %13 = getelementptr inbounds i16, i16* %sa, i64 %indvars.iv
291cee313d2SEric Christopher  store i16 %12, i16* %13, align 2
292cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
293cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
294cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
295cee313d2SEric Christopher  br i1 %exitcond, label %14, label %1
296cee313d2SEric Christopher
297cee313d2SEric Christopher; <label>:14                                      ; preds = %1
298cee313d2SEric Christopher  ret void
299cee313d2SEric Christopher}
300cee313d2SEric Christopher
301cee313d2SEric Christopher;CHECK-LABEL: @example10b(
302cee313d2SEric Christopher;CHECK: load <4 x i16>
303cee313d2SEric Christopher;CHECK: sext <4 x i16>
304cee313d2SEric Christopher;CHECK: store <4 x i32>
305cee313d2SEric Christopher;CHECK: ret void
306cee313d2SEric Christopherdefine void @example10b(i16* noalias nocapture %sa, i16* noalias nocapture %sb, i16* noalias nocapture %sc, i32* noalias nocapture %ia, i32* noalias nocapture %ib, i32* noalias nocapture %ic) nounwind uwtable ssp {
307cee313d2SEric Christopher  br label %1
308cee313d2SEric Christopher
309cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
310cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
311cee313d2SEric Christopher  %2 = getelementptr inbounds i16, i16* %sb, i64 %indvars.iv
312cee313d2SEric Christopher  %3 = load i16, i16* %2, align 2
313cee313d2SEric Christopher  %4 = sext i16 %3 to i32
314cee313d2SEric Christopher  %5 = getelementptr inbounds i32, i32* %ia, i64 %indvars.iv
315cee313d2SEric Christopher  store i32 %4, i32* %5, align 4
316cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
317cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
318cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
319cee313d2SEric Christopher  br i1 %exitcond, label %6, label %1
320cee313d2SEric Christopher
321cee313d2SEric Christopher; <label>:6                                       ; preds = %1
322cee313d2SEric Christopher  ret void
323cee313d2SEric Christopher}
324cee313d2SEric Christopher
325cee313d2SEric Christopher;CHECK-LABEL: @example11(
326cee313d2SEric Christopher;CHECK: load i32
327cee313d2SEric Christopher;CHECK: load i32
328cee313d2SEric Christopher;CHECK: load i32
329cee313d2SEric Christopher;CHECK: load i32
330cee313d2SEric Christopher;CHECK: insertelement
331cee313d2SEric Christopher;CHECK: insertelement
332cee313d2SEric Christopher;CHECK: insertelement
333cee313d2SEric Christopher;CHECK: insertelement
334cee313d2SEric Christopher;CHECK: ret void
335cee313d2SEric Christopherdefine void @example11() nounwind uwtable ssp {
336cee313d2SEric Christopher  br label %1
337cee313d2SEric Christopher
338cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
339cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
340cee313d2SEric Christopher  %2 = shl nsw i64 %indvars.iv, 1
341cee313d2SEric Christopher  %3 = or i64 %2, 1
342cee313d2SEric Christopher  %4 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %3
343cee313d2SEric Christopher  %5 = load i32, i32* %4, align 4
344cee313d2SEric Christopher  %6 = getelementptr inbounds [2048 x i32], [2048 x i32]* @c, i64 0, i64 %3
345cee313d2SEric Christopher  %7 = load i32, i32* %6, align 4
346cee313d2SEric Christopher  %8 = mul nsw i32 %7, %5
347cee313d2SEric Christopher  %9 = getelementptr inbounds [2048 x i32], [2048 x i32]* @b, i64 0, i64 %2
348cee313d2SEric Christopher  %10 = load i32, i32* %9, align 8
349cee313d2SEric Christopher  %11 = getelementptr inbounds [2048 x i32], [2048 x i32]* @c, i64 0, i64 %2
350cee313d2SEric Christopher  %12 = load i32, i32* %11, align 8
351cee313d2SEric Christopher  %13 = mul nsw i32 %12, %10
352cee313d2SEric Christopher  %14 = sub nsw i32 %8, %13
353cee313d2SEric Christopher  %15 = getelementptr inbounds [2048 x i32], [2048 x i32]* @a, i64 0, i64 %indvars.iv
354cee313d2SEric Christopher  store i32 %14, i32* %15, align 4
355cee313d2SEric Christopher  %16 = mul nsw i32 %7, %10
356cee313d2SEric Christopher  %17 = mul nsw i32 %12, %5
357cee313d2SEric Christopher  %18 = add nsw i32 %17, %16
358cee313d2SEric Christopher  %19 = getelementptr inbounds [2048 x i32], [2048 x i32]* @d, i64 0, i64 %indvars.iv
359cee313d2SEric Christopher  store i32 %18, i32* %19, align 4
360cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
361cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
362cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 512
363cee313d2SEric Christopher  br i1 %exitcond, label %20, label %1
364cee313d2SEric Christopher
365cee313d2SEric Christopher; <label>:20                                      ; preds = %1
366cee313d2SEric Christopher  ret void
367cee313d2SEric Christopher}
368cee313d2SEric Christopher
369cee313d2SEric Christopher;CHECK-LABEL: @example12(
370*3b7b1a75SFlorian Hahn;CHECK: vector.body:
371*3b7b1a75SFlorian Hahn;CHECK: [[VEC_IV_TRUNC:%.+]] = phi <4 x i32>
372*3b7b1a75SFlorian Hahn;CHECK: store <4 x i32> [[VEC_IV_TRUNC]]
373cee313d2SEric Christopher;CHECK: ret void
374*3b7b1a75SFlorian Hahndefine void @example12() {
375cee313d2SEric Christopher  br label %1
376cee313d2SEric Christopher
377cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
378cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
379cee313d2SEric Christopher  %2 = getelementptr inbounds [2048 x i32], [2048 x i32]* @a, i64 0, i64 %indvars.iv
380cee313d2SEric Christopher  %3 = trunc i64 %indvars.iv to i32
381cee313d2SEric Christopher  store i32 %3, i32* %2, align 4
382cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
383cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
384cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
385cee313d2SEric Christopher  br i1 %exitcond, label %4, label %1
386cee313d2SEric Christopher
387cee313d2SEric Christopher; <label>:4                                       ; preds = %1
388cee313d2SEric Christopher  ret void
389cee313d2SEric Christopher}
390cee313d2SEric Christopher
391cee313d2SEric Christopher;CHECK-LABEL: @example13(
392cee313d2SEric Christopher;CHECK: <4 x i32>
393cee313d2SEric Christopher;CHECK: ret void
394cee313d2SEric Christopherdefine void @example13(i32** nocapture %A, i32** nocapture %B, i32* nocapture %out) nounwind uwtable ssp {
395cee313d2SEric Christopher  br label %.preheader
396cee313d2SEric Christopher
397cee313d2SEric Christopher.preheader:                                       ; preds = %14, %0
398cee313d2SEric Christopher  %indvars.iv4 = phi i64 [ 0, %0 ], [ %indvars.iv.next5, %14 ]
399cee313d2SEric Christopher  %1 = getelementptr inbounds i32*, i32** %A, i64 %indvars.iv4
400cee313d2SEric Christopher  %2 = load i32*, i32** %1, align 8
401cee313d2SEric Christopher  %3 = getelementptr inbounds i32*, i32** %B, i64 %indvars.iv4
402cee313d2SEric Christopher  %4 = load i32*, i32** %3, align 8
403cee313d2SEric Christopher  br label %5
404cee313d2SEric Christopher
405cee313d2SEric Christopher; <label>:5                                       ; preds = %.preheader, %5
406cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %5 ]
407cee313d2SEric Christopher  %diff.02 = phi i32 [ 0, %.preheader ], [ %11, %5 ]
408cee313d2SEric Christopher  %6 = getelementptr inbounds i32, i32* %2, i64 %indvars.iv
409cee313d2SEric Christopher  %7 = load i32, i32* %6, align 4
410cee313d2SEric Christopher  %8 = getelementptr inbounds i32, i32* %4, i64 %indvars.iv
411cee313d2SEric Christopher  %9 = load i32, i32* %8, align 4
412cee313d2SEric Christopher  %10 = add i32 %7, %diff.02
413cee313d2SEric Christopher  %11 = sub i32 %10, %9
414cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 8
415cee313d2SEric Christopher  %12 = trunc i64 %indvars.iv.next to i32
416cee313d2SEric Christopher  %13 = icmp slt i32 %12, 1024
417cee313d2SEric Christopher  br i1 %13, label %5, label %14
418cee313d2SEric Christopher
419cee313d2SEric Christopher; <label>:14                                      ; preds = %5
420cee313d2SEric Christopher  %15 = getelementptr inbounds i32, i32* %out, i64 %indvars.iv4
421cee313d2SEric Christopher  store i32 %11, i32* %15, align 4
422cee313d2SEric Christopher  %indvars.iv.next5 = add i64 %indvars.iv4, 1
423cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next5 to i32
424cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 32
425cee313d2SEric Christopher  br i1 %exitcond, label %16, label %.preheader
426cee313d2SEric Christopher
427cee313d2SEric Christopher; <label>:16                                      ; preds = %14
428cee313d2SEric Christopher  ret void
429cee313d2SEric Christopher}
430cee313d2SEric Christopher
431cee313d2SEric Christopher; Can vectorize.
432cee313d2SEric Christopher;CHECK-LABEL: @example14(
433cee313d2SEric Christopher;CHECK: <4 x i32>
434cee313d2SEric Christopher;CHECK: ret void
435cee313d2SEric Christopherdefine void @example14(i32** nocapture %in, i32** nocapture %coeff, i32* nocapture %out) nounwind uwtable ssp {
436cee313d2SEric Christopher.preheader3:
437cee313d2SEric Christopher  br label %.preheader
438cee313d2SEric Christopher
439cee313d2SEric Christopher.preheader:                                       ; preds = %11, %.preheader3
440cee313d2SEric Christopher  %indvars.iv7 = phi i64 [ 0, %.preheader3 ], [ %indvars.iv.next8, %11 ]
441cee313d2SEric Christopher  %sum.05 = phi i32 [ 0, %.preheader3 ], [ %10, %11 ]
442cee313d2SEric Christopher  br label %0
443cee313d2SEric Christopher
444cee313d2SEric Christopher; <label>:0                                       ; preds = %0, %.preheader
445cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %0 ]
446cee313d2SEric Christopher  %sum.12 = phi i32 [ %sum.05, %.preheader ], [ %10, %0 ]
447cee313d2SEric Christopher  %1 = getelementptr inbounds i32*, i32** %in, i64 %indvars.iv
448cee313d2SEric Christopher  %2 = load i32*, i32** %1, align 8
449cee313d2SEric Christopher  %3 = getelementptr inbounds i32, i32* %2, i64 %indvars.iv7
450cee313d2SEric Christopher  %4 = load i32, i32* %3, align 4
451cee313d2SEric Christopher  %5 = getelementptr inbounds i32*, i32** %coeff, i64 %indvars.iv
452cee313d2SEric Christopher  %6 = load i32*, i32** %5, align 8
453cee313d2SEric Christopher  %7 = getelementptr inbounds i32, i32* %6, i64 %indvars.iv7
454cee313d2SEric Christopher  %8 = load i32, i32* %7, align 4
455cee313d2SEric Christopher  %9 = mul nsw i32 %8, %4
456cee313d2SEric Christopher  %10 = add nsw i32 %9, %sum.12
457cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
458cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
459cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
460cee313d2SEric Christopher  br i1 %exitcond, label %11, label %0
461cee313d2SEric Christopher
462cee313d2SEric Christopher; <label>:11                                      ; preds = %0
463cee313d2SEric Christopher  %indvars.iv.next8 = add i64 %indvars.iv7, 1
464cee313d2SEric Christopher  %lftr.wideiv9 = trunc i64 %indvars.iv.next8 to i32
465cee313d2SEric Christopher  %exitcond10 = icmp eq i32 %lftr.wideiv9, 32
466cee313d2SEric Christopher  br i1 %exitcond10, label %.preheader3.1, label %.preheader
467cee313d2SEric Christopher
468cee313d2SEric Christopher.preheader3.1:                                    ; preds = %11
469cee313d2SEric Christopher  store i32 %10, i32* %out, align 4
470cee313d2SEric Christopher  br label %.preheader.1
471cee313d2SEric Christopher
472cee313d2SEric Christopher.preheader.1:                                     ; preds = %24, %.preheader3.1
473cee313d2SEric Christopher  %indvars.iv7.1 = phi i64 [ 0, %.preheader3.1 ], [ %indvars.iv.next8.1, %24 ]
474cee313d2SEric Christopher  %sum.05.1 = phi i32 [ 0, %.preheader3.1 ], [ %23, %24 ]
475cee313d2SEric Christopher  br label %12
476cee313d2SEric Christopher
477cee313d2SEric Christopher; <label>:12                                      ; preds = %12, %.preheader.1
478cee313d2SEric Christopher  %indvars.iv.1 = phi i64 [ 0, %.preheader.1 ], [ %13, %12 ]
479cee313d2SEric Christopher  %sum.12.1 = phi i32 [ %sum.05.1, %.preheader.1 ], [ %23, %12 ]
480cee313d2SEric Christopher  %13 = add nsw i64 %indvars.iv.1, 1
481cee313d2SEric Christopher  %14 = getelementptr inbounds i32*, i32** %in, i64 %13
482cee313d2SEric Christopher  %15 = load i32*, i32** %14, align 8
483cee313d2SEric Christopher  %16 = getelementptr inbounds i32, i32* %15, i64 %indvars.iv7.1
484cee313d2SEric Christopher  %17 = load i32, i32* %16, align 4
485cee313d2SEric Christopher  %18 = getelementptr inbounds i32*, i32** %coeff, i64 %indvars.iv.1
486cee313d2SEric Christopher  %19 = load i32*, i32** %18, align 8
487cee313d2SEric Christopher  %20 = getelementptr inbounds i32, i32* %19, i64 %indvars.iv7.1
488cee313d2SEric Christopher  %21 = load i32, i32* %20, align 4
489cee313d2SEric Christopher  %22 = mul nsw i32 %21, %17
490cee313d2SEric Christopher  %23 = add nsw i32 %22, %sum.12.1
491cee313d2SEric Christopher  %lftr.wideiv.1 = trunc i64 %13 to i32
492cee313d2SEric Christopher  %exitcond.1 = icmp eq i32 %lftr.wideiv.1, 1024
493cee313d2SEric Christopher  br i1 %exitcond.1, label %24, label %12
494cee313d2SEric Christopher
495cee313d2SEric Christopher; <label>:24                                      ; preds = %12
496cee313d2SEric Christopher  %indvars.iv.next8.1 = add i64 %indvars.iv7.1, 1
497cee313d2SEric Christopher  %lftr.wideiv9.1 = trunc i64 %indvars.iv.next8.1 to i32
498cee313d2SEric Christopher  %exitcond10.1 = icmp eq i32 %lftr.wideiv9.1, 32
499cee313d2SEric Christopher  br i1 %exitcond10.1, label %.preheader3.2, label %.preheader.1
500cee313d2SEric Christopher
501cee313d2SEric Christopher.preheader3.2:                                    ; preds = %24
502cee313d2SEric Christopher  %25 = getelementptr inbounds i32, i32* %out, i64 1
503cee313d2SEric Christopher  store i32 %23, i32* %25, align 4
504cee313d2SEric Christopher  br label %.preheader.2
505cee313d2SEric Christopher
506cee313d2SEric Christopher.preheader.2:                                     ; preds = %38, %.preheader3.2
507cee313d2SEric Christopher  %indvars.iv7.2 = phi i64 [ 0, %.preheader3.2 ], [ %indvars.iv.next8.2, %38 ]
508cee313d2SEric Christopher  %sum.05.2 = phi i32 [ 0, %.preheader3.2 ], [ %37, %38 ]
509cee313d2SEric Christopher  br label %26
510cee313d2SEric Christopher
511cee313d2SEric Christopher; <label>:26                                      ; preds = %26, %.preheader.2
512cee313d2SEric Christopher  %indvars.iv.2 = phi i64 [ 0, %.preheader.2 ], [ %indvars.iv.next.2, %26 ]
513cee313d2SEric Christopher  %sum.12.2 = phi i32 [ %sum.05.2, %.preheader.2 ], [ %37, %26 ]
514cee313d2SEric Christopher  %27 = add nsw i64 %indvars.iv.2, 2
515cee313d2SEric Christopher  %28 = getelementptr inbounds i32*, i32** %in, i64 %27
516cee313d2SEric Christopher  %29 = load i32*, i32** %28, align 8
517cee313d2SEric Christopher  %30 = getelementptr inbounds i32, i32* %29, i64 %indvars.iv7.2
518cee313d2SEric Christopher  %31 = load i32, i32* %30, align 4
519cee313d2SEric Christopher  %32 = getelementptr inbounds i32*, i32** %coeff, i64 %indvars.iv.2
520cee313d2SEric Christopher  %33 = load i32*, i32** %32, align 8
521cee313d2SEric Christopher  %34 = getelementptr inbounds i32, i32* %33, i64 %indvars.iv7.2
522cee313d2SEric Christopher  %35 = load i32, i32* %34, align 4
523cee313d2SEric Christopher  %36 = mul nsw i32 %35, %31
524cee313d2SEric Christopher  %37 = add nsw i32 %36, %sum.12.2
525cee313d2SEric Christopher  %indvars.iv.next.2 = add i64 %indvars.iv.2, 1
526cee313d2SEric Christopher  %lftr.wideiv.2 = trunc i64 %indvars.iv.next.2 to i32
527cee313d2SEric Christopher  %exitcond.2 = icmp eq i32 %lftr.wideiv.2, 1024
528cee313d2SEric Christopher  br i1 %exitcond.2, label %38, label %26
529cee313d2SEric Christopher
530cee313d2SEric Christopher; <label>:38                                      ; preds = %26
531cee313d2SEric Christopher  %indvars.iv.next8.2 = add i64 %indvars.iv7.2, 1
532cee313d2SEric Christopher  %lftr.wideiv9.2 = trunc i64 %indvars.iv.next8.2 to i32
533cee313d2SEric Christopher  %exitcond10.2 = icmp eq i32 %lftr.wideiv9.2, 32
534cee313d2SEric Christopher  br i1 %exitcond10.2, label %.preheader3.3, label %.preheader.2
535cee313d2SEric Christopher
536cee313d2SEric Christopher.preheader3.3:                                    ; preds = %38
537cee313d2SEric Christopher  %39 = getelementptr inbounds i32, i32* %out, i64 2
538cee313d2SEric Christopher  store i32 %37, i32* %39, align 4
539cee313d2SEric Christopher  br label %.preheader.3
540cee313d2SEric Christopher
541cee313d2SEric Christopher.preheader.3:                                     ; preds = %52, %.preheader3.3
542cee313d2SEric Christopher  %indvars.iv7.3 = phi i64 [ 0, %.preheader3.3 ], [ %indvars.iv.next8.3, %52 ]
543cee313d2SEric Christopher  %sum.05.3 = phi i32 [ 0, %.preheader3.3 ], [ %51, %52 ]
544cee313d2SEric Christopher  br label %40
545cee313d2SEric Christopher
546cee313d2SEric Christopher; <label>:40                                      ; preds = %40, %.preheader.3
547cee313d2SEric Christopher  %indvars.iv.3 = phi i64 [ 0, %.preheader.3 ], [ %indvars.iv.next.3, %40 ]
548cee313d2SEric Christopher  %sum.12.3 = phi i32 [ %sum.05.3, %.preheader.3 ], [ %51, %40 ]
549cee313d2SEric Christopher  %41 = add nsw i64 %indvars.iv.3, 3
550cee313d2SEric Christopher  %42 = getelementptr inbounds i32*, i32** %in, i64 %41
551cee313d2SEric Christopher  %43 = load i32*, i32** %42, align 8
552cee313d2SEric Christopher  %44 = getelementptr inbounds i32, i32* %43, i64 %indvars.iv7.3
553cee313d2SEric Christopher  %45 = load i32, i32* %44, align 4
554cee313d2SEric Christopher  %46 = getelementptr inbounds i32*, i32** %coeff, i64 %indvars.iv.3
555cee313d2SEric Christopher  %47 = load i32*, i32** %46, align 8
556cee313d2SEric Christopher  %48 = getelementptr inbounds i32, i32* %47, i64 %indvars.iv7.3
557cee313d2SEric Christopher  %49 = load i32, i32* %48, align 4
558cee313d2SEric Christopher  %50 = mul nsw i32 %49, %45
559cee313d2SEric Christopher  %51 = add nsw i32 %50, %sum.12.3
560cee313d2SEric Christopher  %indvars.iv.next.3 = add i64 %indvars.iv.3, 1
561cee313d2SEric Christopher  %lftr.wideiv.3 = trunc i64 %indvars.iv.next.3 to i32
562cee313d2SEric Christopher  %exitcond.3 = icmp eq i32 %lftr.wideiv.3, 1024
563cee313d2SEric Christopher  br i1 %exitcond.3, label %52, label %40
564cee313d2SEric Christopher
565cee313d2SEric Christopher; <label>:52                                      ; preds = %40
566cee313d2SEric Christopher  %indvars.iv.next8.3 = add i64 %indvars.iv7.3, 1
567cee313d2SEric Christopher  %lftr.wideiv9.3 = trunc i64 %indvars.iv.next8.3 to i32
568cee313d2SEric Christopher  %exitcond10.3 = icmp eq i32 %lftr.wideiv9.3, 32
569cee313d2SEric Christopher  br i1 %exitcond10.3, label %53, label %.preheader.3
570cee313d2SEric Christopher
571cee313d2SEric Christopher; <label>:53                                      ; preds = %52
572cee313d2SEric Christopher  %54 = getelementptr inbounds i32, i32* %out, i64 3
573cee313d2SEric Christopher  store i32 %51, i32* %54, align 4
574cee313d2SEric Christopher  ret void
575cee313d2SEric Christopher}
576cee313d2SEric Christopher
577cee313d2SEric Christopher;CHECK-LABEL: @example21(
578cee313d2SEric Christopher;CHECK: load <4 x i32>
579cee313d2SEric Christopher;CHECK: shufflevector {{.*}} <i32 3, i32 2, i32 1, i32 0>
580cee313d2SEric Christopher;CHECK: ret i32
581cee313d2SEric Christopherdefine i32 @example21(i32* nocapture %b, i32 %n) nounwind uwtable readonly ssp {
582cee313d2SEric Christopher  %1 = icmp sgt i32 %n, 0
583cee313d2SEric Christopher  br i1 %1, label %.lr.ph, label %._crit_edge
584cee313d2SEric Christopher
585cee313d2SEric Christopher.lr.ph:                                           ; preds = %0
586cee313d2SEric Christopher  %2 = sext i32 %n to i64
587cee313d2SEric Christopher  br label %3
588cee313d2SEric Christopher
589cee313d2SEric Christopher; <label>:3                                       ; preds = %.lr.ph, %3
590cee313d2SEric Christopher  %indvars.iv = phi i64 [ %2, %.lr.ph ], [ %indvars.iv.next, %3 ]
591cee313d2SEric Christopher  %a.02 = phi i32 [ 0, %.lr.ph ], [ %6, %3 ]
592cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, -1
593cee313d2SEric Christopher  %4 = getelementptr inbounds i32, i32* %b, i64 %indvars.iv.next
594cee313d2SEric Christopher  %5 = load i32, i32* %4, align 4
595cee313d2SEric Christopher  %6 = add nsw i32 %5, %a.02
596cee313d2SEric Christopher  %7 = trunc i64 %indvars.iv.next to i32
597cee313d2SEric Christopher  %8 = icmp sgt i32 %7, 0
598cee313d2SEric Christopher  br i1 %8, label %3, label %._crit_edge
599cee313d2SEric Christopher
600cee313d2SEric Christopher._crit_edge:                                      ; preds = %3, %0
601cee313d2SEric Christopher  %a.0.lcssa = phi i32 [ 0, %0 ], [ %6, %3 ]
602cee313d2SEric Christopher  ret i32 %a.0.lcssa
603cee313d2SEric Christopher}
604cee313d2SEric Christopher
605cee313d2SEric Christopher;CHECK-LABEL: @example23(
606cee313d2SEric Christopher;CHECK: <4 x i32>
607cee313d2SEric Christopher;CHECK: ret void
608cee313d2SEric Christopherdefine void @example23(i16* nocapture %src, i32* nocapture %dst) nounwind uwtable ssp {
609cee313d2SEric Christopher  br label %1
610cee313d2SEric Christopher
611cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
612cee313d2SEric Christopher  %.04 = phi i16* [ %src, %0 ], [ %2, %1 ]
613cee313d2SEric Christopher  %.013 = phi i32* [ %dst, %0 ], [ %6, %1 ]
614cee313d2SEric Christopher  %i.02 = phi i32 [ 0, %0 ], [ %7, %1 ]
615cee313d2SEric Christopher  %2 = getelementptr inbounds i16, i16* %.04, i64 1
616cee313d2SEric Christopher  %3 = load i16, i16* %.04, align 2
617cee313d2SEric Christopher  %4 = zext i16 %3 to i32
618cee313d2SEric Christopher  %5 = shl nuw nsw i32 %4, 7
619cee313d2SEric Christopher  %6 = getelementptr inbounds i32, i32* %.013, i64 1
620cee313d2SEric Christopher  store i32 %5, i32* %.013, align 4
621cee313d2SEric Christopher  %7 = add nsw i32 %i.02, 1
622cee313d2SEric Christopher  %exitcond = icmp eq i32 %7, 256
623cee313d2SEric Christopher  br i1 %exitcond, label %8, label %1
624cee313d2SEric Christopher
625cee313d2SEric Christopher; <label>:8                                       ; preds = %1
626cee313d2SEric Christopher  ret void
627cee313d2SEric Christopher}
628cee313d2SEric Christopher
629cee313d2SEric Christopher;CHECK-LABEL: @example24(
630cee313d2SEric Christopher;CHECK: shufflevector <4 x i16>
631cee313d2SEric Christopher;CHECK: ret void
632cee313d2SEric Christopherdefine void @example24(i16 signext %x, i16 signext %y) nounwind uwtable ssp {
633cee313d2SEric Christopher  br label %1
634cee313d2SEric Christopher
635cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
636cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
637cee313d2SEric Christopher  %2 = getelementptr inbounds [1024 x float], [1024 x float]* @fa, i64 0, i64 %indvars.iv
638cee313d2SEric Christopher  %3 = load float, float* %2, align 4
639cee313d2SEric Christopher  %4 = getelementptr inbounds [1024 x float], [1024 x float]* @fb, i64 0, i64 %indvars.iv
640cee313d2SEric Christopher  %5 = load float, float* %4, align 4
641cee313d2SEric Christopher  %6 = fcmp olt float %3, %5
642cee313d2SEric Christopher  %x.y = select i1 %6, i16 %x, i16 %y
643cee313d2SEric Christopher  %7 = sext i16 %x.y to i32
644cee313d2SEric Christopher  %8 = getelementptr inbounds [1024 x i32], [1024 x i32]* @ic, i64 0, i64 %indvars.iv
645cee313d2SEric Christopher  store i32 %7, i32* %8, align 4
646cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
647cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
648cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
649cee313d2SEric Christopher  br i1 %exitcond, label %9, label %1
650cee313d2SEric Christopher
651cee313d2SEric Christopher; <label>:9                                       ; preds = %1
652cee313d2SEric Christopher  ret void
653cee313d2SEric Christopher}
654cee313d2SEric Christopher
655cee313d2SEric Christopher;CHECK-LABEL: @example25(
656cee313d2SEric Christopher;CHECK: and <4 x i1>
657cee313d2SEric Christopher;CHECK: zext <4 x i1>
658cee313d2SEric Christopher;CHECK: ret void
659cee313d2SEric Christopherdefine void @example25() nounwind uwtable ssp {
660cee313d2SEric Christopher  br label %1
661cee313d2SEric Christopher
662cee313d2SEric Christopher; <label>:1                                       ; preds = %1, %0
663cee313d2SEric Christopher  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %1 ]
664cee313d2SEric Christopher  %2 = getelementptr inbounds [1024 x float], [1024 x float]* @da, i64 0, i64 %indvars.iv
665cee313d2SEric Christopher  %3 = load float, float* %2, align 4
666cee313d2SEric Christopher  %4 = getelementptr inbounds [1024 x float], [1024 x float]* @db, i64 0, i64 %indvars.iv
667cee313d2SEric Christopher  %5 = load float, float* %4, align 4
668cee313d2SEric Christopher  %6 = fcmp olt float %3, %5
669cee313d2SEric Christopher  %7 = getelementptr inbounds [1024 x float], [1024 x float]* @dc, i64 0, i64 %indvars.iv
670cee313d2SEric Christopher  %8 = load float, float* %7, align 4
671cee313d2SEric Christopher  %9 = getelementptr inbounds [1024 x float], [1024 x float]* @dd, i64 0, i64 %indvars.iv
672cee313d2SEric Christopher  %10 = load float, float* %9, align 4
673cee313d2SEric Christopher  %11 = fcmp olt float %8, %10
674cee313d2SEric Christopher  %12 = and i1 %6, %11
675cee313d2SEric Christopher  %13 = zext i1 %12 to i32
676cee313d2SEric Christopher  %14 = getelementptr inbounds [1024 x i32], [1024 x i32]* @dj, i64 0, i64 %indvars.iv
677cee313d2SEric Christopher  store i32 %13, i32* %14, align 4
678cee313d2SEric Christopher  %indvars.iv.next = add i64 %indvars.iv, 1
679cee313d2SEric Christopher  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
680cee313d2SEric Christopher  %exitcond = icmp eq i32 %lftr.wideiv, 1024
681cee313d2SEric Christopher  br i1 %exitcond, label %15, label %1
682cee313d2SEric Christopher
683cee313d2SEric Christopher; <label>:15                                      ; preds = %1
684cee313d2SEric Christopher  ret void
685cee313d2SEric Christopher}
686cee313d2SEric Christopher
687