1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -loop-versioning -S < %s | FileCheck %s -check-prefix=LV
3
4target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5
6; For this loop:
7;   unsigned index = 0;
8;   for (int i = 0; i < n; i++) {
9;    A[2 * index] = A[2 * index] + B[i];
10;    index++;
11;   }
12;
13; SCEV is unable to prove that A[2 * i] does not overflow.
14;
15; Analyzing the IR does not help us because the GEPs are not
16; affine AddRecExprs. However, we can turn them into AddRecExprs
17; using SCEV Predicates.
18;
19; Once we have an affine expression we need to add an additional NUSW
20; to check that the pointers don't wrap since the GEPs are not
21; inbound.
22
23; The expression for %mul_ext as analyzed by SCEV is
24;    (zext i32 {0,+,2}<%for.body> to i64)
25; We have added the nusw flag to turn this expression into the SCEV expression:
26;    i64 {0,+,2}<%for.body>
27
28define void @f1(i16* noalias %a,
29; LV-LABEL: @f1(
30; LV-NEXT:  for.body.lver.check:
31; LV-NEXT:    [[A2:%.*]] = ptrtoint i16* [[A:%.*]] to i64
32; LV-NEXT:    [[TMP0:%.*]] = add i64 [[N:%.*]], -1
33; LV-NEXT:    [[TMP1:%.*]] = trunc i64 [[TMP0]] to i32
34; LV-NEXT:    [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP1]])
35; LV-NEXT:    [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
36; LV-NEXT:    [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
37; LV-NEXT:    [[TMP2:%.*]] = add i32 0, [[MUL_RESULT]]
38; LV-NEXT:    [[TMP3:%.*]] = sub i32 0, [[MUL_RESULT]]
39; LV-NEXT:    [[TMP4:%.*]] = icmp ugt i32 [[TMP3]], 0
40; LV-NEXT:    [[TMP5:%.*]] = icmp ult i32 [[TMP2]], 0
41; LV-NEXT:    [[TMP6:%.*]] = select i1 false, i1 [[TMP4]], i1 [[TMP5]]
42; LV-NEXT:    [[TMP7:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
43; LV-NEXT:    [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
44; LV-NEXT:    [[TMP9:%.*]] = or i1 [[TMP8]], [[MUL_OVERFLOW]]
45; LV-NEXT:    [[TMP10:%.*]] = or i1 false, [[TMP9]]
46; LV-NEXT:    [[MUL3:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
47; LV-NEXT:    [[MUL_RESULT4:%.*]] = extractvalue { i64, i1 } [[MUL3]], 0
48; LV-NEXT:    [[MUL_OVERFLOW5:%.*]] = extractvalue { i64, i1 } [[MUL3]], 1
49; LV-NEXT:    [[TMP11:%.*]] = add i64 [[A2]], [[MUL_RESULT4]]
50; LV-NEXT:    [[TMP12:%.*]] = sub i64 [[A2]], [[MUL_RESULT4]]
51; LV-NEXT:    [[TMP13:%.*]] = icmp ugt i64 [[TMP12]], [[A2]]
52; LV-NEXT:    [[TMP14:%.*]] = icmp ult i64 [[TMP11]], [[A2]]
53; LV-NEXT:    [[TMP15:%.*]] = select i1 false, i1 [[TMP13]], i1 [[TMP14]]
54; LV-NEXT:    [[TMP16:%.*]] = or i1 [[TMP15]], [[MUL_OVERFLOW5]]
55; LV-NEXT:    [[TMP17:%.*]] = or i1 [[TMP10]], [[TMP16]]
56; LV-NEXT:    br i1 [[TMP17]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH:%.*]]
57; LV:       for.body.ph.lver.orig:
58; LV-NEXT:    br label [[FOR_BODY_LVER_ORIG:%.*]]
59; LV:       for.body.lver.orig:
60; LV-NEXT:    [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
61; LV-NEXT:    [[IND1_LVER_ORIG:%.*]] = phi i32 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC1_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
62; LV-NEXT:    [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
63; LV-NEXT:    [[MUL_EXT_LVER_ORIG:%.*]] = zext i32 [[MUL_LVER_ORIG]] to i64
64; LV-NEXT:    [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT_LVER_ORIG]]
65; LV-NEXT:    [[LOADA_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXA_LVER_ORIG]], align 2
66; LV-NEXT:    [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr i16, i16* [[B:%.*]], i64 [[IND_LVER_ORIG]]
67; LV-NEXT:    [[LOADB_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXB_LVER_ORIG]], align 2
68; LV-NEXT:    [[ADD_LVER_ORIG:%.*]] = mul i16 [[LOADA_LVER_ORIG]], [[LOADB_LVER_ORIG]]
69; LV-NEXT:    store i16 [[ADD_LVER_ORIG]], i16* [[ARRAYIDXA_LVER_ORIG]], align 2
70; LV-NEXT:    [[INC_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
71; LV-NEXT:    [[INC1_LVER_ORIG]] = add i32 [[IND1_LVER_ORIG]], 1
72; LV-NEXT:    [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[INC_LVER_ORIG]], [[N]]
73; LV-NEXT:    br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
74; LV:       for.body.ph:
75; LV-NEXT:    br label [[FOR_BODY:%.*]]
76; LV:       for.body:
77; LV-NEXT:    [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
78; LV-NEXT:    [[IND1:%.*]] = phi i32 [ 0, [[FOR_BODY_PH]] ], [ [[INC1:%.*]], [[FOR_BODY]] ]
79; LV-NEXT:    [[MUL:%.*]] = mul i32 [[IND1]], 2
80; LV-NEXT:    [[MUL_EXT:%.*]] = zext i32 [[MUL]] to i64
81; LV-NEXT:    [[ARRAYIDXA:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT]]
82; LV-NEXT:    [[LOADA:%.*]] = load i16, i16* [[ARRAYIDXA]], align 2
83; LV-NEXT:    [[ARRAYIDXB:%.*]] = getelementptr i16, i16* [[B]], i64 [[IND]]
84; LV-NEXT:    [[LOADB:%.*]] = load i16, i16* [[ARRAYIDXB]], align 2
85; LV-NEXT:    [[ADD:%.*]] = mul i16 [[LOADA]], [[LOADB]]
86; LV-NEXT:    store i16 [[ADD]], i16* [[ARRAYIDXA]], align 2
87; LV-NEXT:    [[INC]] = add nuw nsw i64 [[IND]], 1
88; LV-NEXT:    [[INC1]] = add i32 [[IND1]], 1
89; LV-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[N]]
90; LV-NEXT:    br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT6:%.*]], label [[FOR_BODY]]
91; LV:       for.end.loopexit:
92; LV-NEXT:    br label [[FOR_END:%.*]]
93; LV:       for.end.loopexit6:
94; LV-NEXT:    br label [[FOR_END]]
95; LV:       for.end:
96; LV-NEXT:    ret void
97;
98  i16* noalias %b, i64 %N) {
99entry:
100  br label %for.body
101
102for.body:                                         ; preds = %for.body, %entry
103  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
104  %ind1 = phi i32 [ 0, %entry ], [ %inc1, %for.body ]
105
106  %mul = mul i32 %ind1, 2
107  %mul_ext = zext i32 %mul to i64
108
109  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext
110  %loadA = load i16, i16* %arrayidxA, align 2
111
112  %arrayidxB = getelementptr i16, i16* %b, i64 %ind
113  %loadB = load i16, i16* %arrayidxB, align 2
114
115  %add = mul i16 %loadA, %loadB
116
117  store i16 %add, i16* %arrayidxA, align 2
118
119  %inc = add nuw nsw i64 %ind, 1
120  %inc1 = add i32 %ind1, 1
121
122  %exitcond = icmp eq i64 %inc, %N
123  br i1 %exitcond, label %for.end, label %for.body
124
125for.end:                                          ; preds = %for.body
126  ret void
127}
128
129; For this loop:
130;   unsigned index = n;
131;   for (int i = 0; i < n; i++) {
132;    A[2 * index] = A[2 * index] + B[i];
133;    index--;
134;   }
135;
136; the SCEV expression for 2 * index is not an AddRecExpr
137; (and implictly not affine). However, we are able to make assumptions
138; that will turn the expression into an affine one and continue the
139; analysis.
140;
141; Once we have an affine expression we need to add an additional NUSW
142; to check that the pointers don't wrap since the GEPs are not
143; inbounds.
144;
145; This loop has a negative stride for A, and the nusw flag is required in
146; order to properly extend the increment from i32 -4 to i64 -4.
147
148; The expression for %mul_ext as analyzed by SCEV is
149;     (zext i32 {(2 * (trunc i64 %N to i32)),+,-2}<%for.body> to i64)
150; We have added the nusw flag to turn this expression into the following SCEV:
151;     i64 {zext i32 (2 * (trunc i64 %N to i32)) to i64,+,-2}<%for.body>
152
153define void @f2(i16* noalias %a,
154; LV-LABEL: @f2(
155; LV-NEXT:  for.body.lver.check:
156; LV-NEXT:    [[A2:%.*]] = ptrtoint i16* [[A:%.*]] to i64
157; LV-NEXT:    [[TRUNCN:%.*]] = trunc i64 [[N:%.*]] to i32
158; LV-NEXT:    [[TMP0:%.*]] = add i64 [[N]], -1
159; LV-NEXT:    [[TMP1:%.*]] = shl i32 [[TRUNCN]], 1
160; LV-NEXT:    [[TMP2:%.*]] = trunc i64 [[TMP0]] to i32
161; LV-NEXT:    [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]])
162; LV-NEXT:    [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
163; LV-NEXT:    [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
164; LV-NEXT:    [[TMP3:%.*]] = add i32 [[TMP1]], [[MUL_RESULT]]
165; LV-NEXT:    [[TMP4:%.*]] = sub i32 [[TMP1]], [[MUL_RESULT]]
166; LV-NEXT:    [[TMP5:%.*]] = icmp ugt i32 [[TMP4]], [[TMP1]]
167; LV-NEXT:    [[TMP6:%.*]] = icmp ult i32 [[TMP3]], [[TMP1]]
168; LV-NEXT:    [[TMP7:%.*]] = select i1 true, i1 [[TMP5]], i1 [[TMP6]]
169; LV-NEXT:    [[TMP8:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
170; LV-NEXT:    [[TMP9:%.*]] = or i1 [[TMP7]], [[TMP8]]
171; LV-NEXT:    [[TMP10:%.*]] = or i1 [[TMP9]], [[MUL_OVERFLOW]]
172; LV-NEXT:    [[TMP11:%.*]] = or i1 false, [[TMP10]]
173; LV-NEXT:    [[TMP12:%.*]] = trunc i64 [[N]] to i31
174; LV-NEXT:    [[TMP13:%.*]] = zext i31 [[TMP12]] to i64
175; LV-NEXT:    [[TMP14:%.*]] = shl nuw nsw i64 [[TMP13]], 2
176; LV-NEXT:    [[TMP15:%.*]] = add i64 [[A2]], [[TMP14]]
177; LV-NEXT:    [[MUL3:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
178; LV-NEXT:    [[MUL_RESULT4:%.*]] = extractvalue { i64, i1 } [[MUL3]], 0
179; LV-NEXT:    [[MUL_OVERFLOW5:%.*]] = extractvalue { i64, i1 } [[MUL3]], 1
180; LV-NEXT:    [[TMP16:%.*]] = add i64 [[TMP15]], [[MUL_RESULT4]]
181; LV-NEXT:    [[TMP17:%.*]] = sub i64 [[TMP15]], [[MUL_RESULT4]]
182; LV-NEXT:    [[TMP18:%.*]] = icmp ugt i64 [[TMP17]], [[TMP15]]
183; LV-NEXT:    [[TMP19:%.*]] = icmp ult i64 [[TMP16]], [[TMP15]]
184; LV-NEXT:    [[TMP20:%.*]] = select i1 true, i1 [[TMP18]], i1 [[TMP19]]
185; LV-NEXT:    [[TMP21:%.*]] = or i1 [[TMP20]], [[MUL_OVERFLOW5]]
186; LV-NEXT:    [[TMP22:%.*]] = or i1 [[TMP11]], [[TMP21]]
187; LV-NEXT:    br i1 [[TMP22]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH:%.*]]
188; LV:       for.body.ph.lver.orig:
189; LV-NEXT:    br label [[FOR_BODY_LVER_ORIG:%.*]]
190; LV:       for.body.lver.orig:
191; LV-NEXT:    [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
192; LV-NEXT:    [[IND1_LVER_ORIG:%.*]] = phi i32 [ [[TRUNCN]], [[FOR_BODY_PH_LVER_ORIG]] ], [ [[DEC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
193; LV-NEXT:    [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
194; LV-NEXT:    [[MUL_EXT_LVER_ORIG:%.*]] = zext i32 [[MUL_LVER_ORIG]] to i64
195; LV-NEXT:    [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT_LVER_ORIG]]
196; LV-NEXT:    [[LOADA_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXA_LVER_ORIG]], align 2
197; LV-NEXT:    [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr i16, i16* [[B:%.*]], i64 [[IND_LVER_ORIG]]
198; LV-NEXT:    [[LOADB_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXB_LVER_ORIG]], align 2
199; LV-NEXT:    [[ADD_LVER_ORIG:%.*]] = mul i16 [[LOADA_LVER_ORIG]], [[LOADB_LVER_ORIG]]
200; LV-NEXT:    store i16 [[ADD_LVER_ORIG]], i16* [[ARRAYIDXA_LVER_ORIG]], align 2
201; LV-NEXT:    [[INC_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
202; LV-NEXT:    [[DEC_LVER_ORIG]] = sub i32 [[IND1_LVER_ORIG]], 1
203; LV-NEXT:    [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[INC_LVER_ORIG]], [[N]]
204; LV-NEXT:    br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
205; LV:       for.body.ph:
206; LV-NEXT:    br label [[FOR_BODY:%.*]]
207; LV:       for.body:
208; LV-NEXT:    [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
209; LV-NEXT:    [[IND1:%.*]] = phi i32 [ [[TRUNCN]], [[FOR_BODY_PH]] ], [ [[DEC:%.*]], [[FOR_BODY]] ]
210; LV-NEXT:    [[MUL:%.*]] = mul i32 [[IND1]], 2
211; LV-NEXT:    [[MUL_EXT:%.*]] = zext i32 [[MUL]] to i64
212; LV-NEXT:    [[ARRAYIDXA:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT]]
213; LV-NEXT:    [[LOADA:%.*]] = load i16, i16* [[ARRAYIDXA]], align 2
214; LV-NEXT:    [[ARRAYIDXB:%.*]] = getelementptr i16, i16* [[B]], i64 [[IND]]
215; LV-NEXT:    [[LOADB:%.*]] = load i16, i16* [[ARRAYIDXB]], align 2
216; LV-NEXT:    [[ADD:%.*]] = mul i16 [[LOADA]], [[LOADB]]
217; LV-NEXT:    store i16 [[ADD]], i16* [[ARRAYIDXA]], align 2
218; LV-NEXT:    [[INC]] = add nuw nsw i64 [[IND]], 1
219; LV-NEXT:    [[DEC]] = sub i32 [[IND1]], 1
220; LV-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[N]]
221; LV-NEXT:    br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT6:%.*]], label [[FOR_BODY]]
222; LV:       for.end.loopexit:
223; LV-NEXT:    br label [[FOR_END:%.*]]
224; LV:       for.end.loopexit6:
225; LV-NEXT:    br label [[FOR_END]]
226; LV:       for.end:
227; LV-NEXT:    ret void
228;
229  i16* noalias %b, i64 %N) {
230entry:
231  %TruncN = trunc i64 %N to i32
232  br label %for.body
233
234for.body:                                         ; preds = %for.body, %entry
235  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
236  %ind1 = phi i32 [ %TruncN, %entry ], [ %dec, %for.body ]
237
238  %mul = mul i32 %ind1, 2
239  %mul_ext = zext i32 %mul to i64
240
241  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext
242  %loadA = load i16, i16* %arrayidxA, align 2
243
244  %arrayidxB = getelementptr i16, i16* %b, i64 %ind
245  %loadB = load i16, i16* %arrayidxB, align 2
246
247  %add = mul i16 %loadA, %loadB
248
249  store i16 %add, i16* %arrayidxA, align 2
250
251  %inc = add nuw nsw i64 %ind, 1
252  %dec = sub i32 %ind1, 1
253
254  %exitcond = icmp eq i64 %inc, %N
255  br i1 %exitcond, label %for.end, label %for.body
256
257for.end:                                          ; preds = %for.body
258  ret void
259}
260
261; We replicate the tests above, but this time sign extend 2 * index instead
262; of zero extending it.
263
264; The expression for %mul_ext as analyzed by SCEV is
265;     i64 (sext i32 {0,+,2}<%for.body> to i64)
266; We have added the nssw flag to turn this expression into the following SCEV:
267;     i64 {0,+,2}<%for.body>
268
269define void @f3(i16* noalias %a,
270; LV-LABEL: @f3(
271; LV-NEXT:  for.body.lver.check:
272; LV-NEXT:    [[A2:%.*]] = ptrtoint i16* [[A:%.*]] to i64
273; LV-NEXT:    [[TMP0:%.*]] = add i64 [[N:%.*]], -1
274; LV-NEXT:    [[TMP1:%.*]] = trunc i64 [[TMP0]] to i32
275; LV-NEXT:    [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP1]])
276; LV-NEXT:    [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
277; LV-NEXT:    [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
278; LV-NEXT:    [[TMP2:%.*]] = add i32 0, [[MUL_RESULT]]
279; LV-NEXT:    [[TMP3:%.*]] = sub i32 0, [[MUL_RESULT]]
280; LV-NEXT:    [[TMP4:%.*]] = icmp sgt i32 [[TMP3]], 0
281; LV-NEXT:    [[TMP5:%.*]] = icmp slt i32 [[TMP2]], 0
282; LV-NEXT:    [[TMP6:%.*]] = select i1 false, i1 [[TMP4]], i1 [[TMP5]]
283; LV-NEXT:    [[TMP7:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
284; LV-NEXT:    [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
285; LV-NEXT:    [[TMP9:%.*]] = or i1 [[TMP8]], [[MUL_OVERFLOW]]
286; LV-NEXT:    [[TMP10:%.*]] = or i1 false, [[TMP9]]
287; LV-NEXT:    [[MUL3:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
288; LV-NEXT:    [[MUL_RESULT4:%.*]] = extractvalue { i64, i1 } [[MUL3]], 0
289; LV-NEXT:    [[MUL_OVERFLOW5:%.*]] = extractvalue { i64, i1 } [[MUL3]], 1
290; LV-NEXT:    [[TMP11:%.*]] = add i64 [[A2]], [[MUL_RESULT4]]
291; LV-NEXT:    [[TMP12:%.*]] = sub i64 [[A2]], [[MUL_RESULT4]]
292; LV-NEXT:    [[TMP13:%.*]] = icmp ugt i64 [[TMP12]], [[A2]]
293; LV-NEXT:    [[TMP14:%.*]] = icmp ult i64 [[TMP11]], [[A2]]
294; LV-NEXT:    [[TMP15:%.*]] = select i1 false, i1 [[TMP13]], i1 [[TMP14]]
295; LV-NEXT:    [[TMP16:%.*]] = or i1 [[TMP15]], [[MUL_OVERFLOW5]]
296; LV-NEXT:    [[TMP17:%.*]] = or i1 [[TMP10]], [[TMP16]]
297; LV-NEXT:    br i1 [[TMP17]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH:%.*]]
298; LV:       for.body.ph.lver.orig:
299; LV-NEXT:    br label [[FOR_BODY_LVER_ORIG:%.*]]
300; LV:       for.body.lver.orig:
301; LV-NEXT:    [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
302; LV-NEXT:    [[IND1_LVER_ORIG:%.*]] = phi i32 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC1_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
303; LV-NEXT:    [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
304; LV-NEXT:    [[MUL_EXT_LVER_ORIG:%.*]] = sext i32 [[MUL_LVER_ORIG]] to i64
305; LV-NEXT:    [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT_LVER_ORIG]]
306; LV-NEXT:    [[LOADA_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXA_LVER_ORIG]], align 2
307; LV-NEXT:    [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr i16, i16* [[B:%.*]], i64 [[IND_LVER_ORIG]]
308; LV-NEXT:    [[LOADB_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXB_LVER_ORIG]], align 2
309; LV-NEXT:    [[ADD_LVER_ORIG:%.*]] = mul i16 [[LOADA_LVER_ORIG]], [[LOADB_LVER_ORIG]]
310; LV-NEXT:    store i16 [[ADD_LVER_ORIG]], i16* [[ARRAYIDXA_LVER_ORIG]], align 2
311; LV-NEXT:    [[INC_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
312; LV-NEXT:    [[INC1_LVER_ORIG]] = add i32 [[IND1_LVER_ORIG]], 1
313; LV-NEXT:    [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[INC_LVER_ORIG]], [[N]]
314; LV-NEXT:    br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
315; LV:       for.body.ph:
316; LV-NEXT:    br label [[FOR_BODY:%.*]]
317; LV:       for.body:
318; LV-NEXT:    [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
319; LV-NEXT:    [[IND1:%.*]] = phi i32 [ 0, [[FOR_BODY_PH]] ], [ [[INC1:%.*]], [[FOR_BODY]] ]
320; LV-NEXT:    [[MUL:%.*]] = mul i32 [[IND1]], 2
321; LV-NEXT:    [[MUL_EXT:%.*]] = sext i32 [[MUL]] to i64
322; LV-NEXT:    [[ARRAYIDXA:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT]]
323; LV-NEXT:    [[LOADA:%.*]] = load i16, i16* [[ARRAYIDXA]], align 2
324; LV-NEXT:    [[ARRAYIDXB:%.*]] = getelementptr i16, i16* [[B]], i64 [[IND]]
325; LV-NEXT:    [[LOADB:%.*]] = load i16, i16* [[ARRAYIDXB]], align 2
326; LV-NEXT:    [[ADD:%.*]] = mul i16 [[LOADA]], [[LOADB]]
327; LV-NEXT:    store i16 [[ADD]], i16* [[ARRAYIDXA]], align 2
328; LV-NEXT:    [[INC]] = add nuw nsw i64 [[IND]], 1
329; LV-NEXT:    [[INC1]] = add i32 [[IND1]], 1
330; LV-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[N]]
331; LV-NEXT:    br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT6:%.*]], label [[FOR_BODY]]
332; LV:       for.end.loopexit:
333; LV-NEXT:    br label [[FOR_END:%.*]]
334; LV:       for.end.loopexit6:
335; LV-NEXT:    br label [[FOR_END]]
336; LV:       for.end:
337; LV-NEXT:    ret void
338;
339  i16* noalias %b, i64 %N) {
340entry:
341  br label %for.body
342
343for.body:                                         ; preds = %for.body, %entry
344  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
345  %ind1 = phi i32 [ 0, %entry ], [ %inc1, %for.body ]
346
347  %mul = mul i32 %ind1, 2
348  %mul_ext = sext i32 %mul to i64
349
350  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext
351  %loadA = load i16, i16* %arrayidxA, align 2
352
353  %arrayidxB = getelementptr i16, i16* %b, i64 %ind
354  %loadB = load i16, i16* %arrayidxB, align 2
355
356  %add = mul i16 %loadA, %loadB
357
358  store i16 %add, i16* %arrayidxA, align 2
359
360  %inc = add nuw nsw i64 %ind, 1
361  %inc1 = add i32 %ind1, 1
362
363  %exitcond = icmp eq i64 %inc, %N
364  br i1 %exitcond, label %for.end, label %for.body
365
366for.end:                                          ; preds = %for.body
367  ret void
368}
369
370define void @f4(i16* noalias %a,
371; LV-LABEL: @f4(
372; LV-NEXT:  for.body.lver.check:
373; LV-NEXT:    [[A2:%.*]] = ptrtoint i16* [[A:%.*]] to i64
374; LV-NEXT:    [[TRUNCN:%.*]] = trunc i64 [[N:%.*]] to i32
375; LV-NEXT:    [[TMP0:%.*]] = add i64 [[N]], -1
376; LV-NEXT:    [[TMP1:%.*]] = shl i32 [[TRUNCN]], 1
377; LV-NEXT:    [[TMP2:%.*]] = trunc i64 [[TMP0]] to i32
378; LV-NEXT:    [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]])
379; LV-NEXT:    [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
380; LV-NEXT:    [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
381; LV-NEXT:    [[TMP3:%.*]] = add i32 [[TMP1]], [[MUL_RESULT]]
382; LV-NEXT:    [[TMP4:%.*]] = sub i32 [[TMP1]], [[MUL_RESULT]]
383; LV-NEXT:    [[TMP5:%.*]] = icmp sgt i32 [[TMP4]], [[TMP1]]
384; LV-NEXT:    [[TMP6:%.*]] = icmp slt i32 [[TMP3]], [[TMP1]]
385; LV-NEXT:    [[TMP7:%.*]] = select i1 true, i1 [[TMP5]], i1 [[TMP6]]
386; LV-NEXT:    [[TMP8:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
387; LV-NEXT:    [[TMP9:%.*]] = or i1 [[TMP7]], [[TMP8]]
388; LV-NEXT:    [[TMP10:%.*]] = or i1 [[TMP9]], [[MUL_OVERFLOW]]
389; LV-NEXT:    [[TMP11:%.*]] = or i1 false, [[TMP10]]
390; LV-NEXT:    [[TMP12:%.*]] = sext i32 [[TMP1]] to i64
391; LV-NEXT:    [[TMP13:%.*]] = shl nsw i64 [[TMP12]], 1
392; LV-NEXT:    [[TMP14:%.*]] = add i64 [[A2]], [[TMP13]]
393; LV-NEXT:    [[MUL3:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
394; LV-NEXT:    [[MUL_RESULT4:%.*]] = extractvalue { i64, i1 } [[MUL3]], 0
395; LV-NEXT:    [[MUL_OVERFLOW5:%.*]] = extractvalue { i64, i1 } [[MUL3]], 1
396; LV-NEXT:    [[TMP15:%.*]] = add i64 [[TMP14]], [[MUL_RESULT4]]
397; LV-NEXT:    [[TMP16:%.*]] = sub i64 [[TMP14]], [[MUL_RESULT4]]
398; LV-NEXT:    [[TMP17:%.*]] = icmp ugt i64 [[TMP16]], [[TMP14]]
399; LV-NEXT:    [[TMP18:%.*]] = icmp ult i64 [[TMP15]], [[TMP14]]
400; LV-NEXT:    [[TMP19:%.*]] = select i1 true, i1 [[TMP17]], i1 [[TMP18]]
401; LV-NEXT:    [[TMP20:%.*]] = or i1 [[TMP19]], [[MUL_OVERFLOW5]]
402; LV-NEXT:    [[TMP21:%.*]] = or i1 [[TMP11]], [[TMP20]]
403; LV-NEXT:    br i1 [[TMP21]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH:%.*]]
404; LV:       for.body.ph.lver.orig:
405; LV-NEXT:    br label [[FOR_BODY_LVER_ORIG:%.*]]
406; LV:       for.body.lver.orig:
407; LV-NEXT:    [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
408; LV-NEXT:    [[IND1_LVER_ORIG:%.*]] = phi i32 [ [[TRUNCN]], [[FOR_BODY_PH_LVER_ORIG]] ], [ [[DEC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
409; LV-NEXT:    [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
410; LV-NEXT:    [[MUL_EXT_LVER_ORIG:%.*]] = sext i32 [[MUL_LVER_ORIG]] to i64
411; LV-NEXT:    [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT_LVER_ORIG]]
412; LV-NEXT:    [[LOADA_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXA_LVER_ORIG]], align 2
413; LV-NEXT:    [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr i16, i16* [[B:%.*]], i64 [[IND_LVER_ORIG]]
414; LV-NEXT:    [[LOADB_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXB_LVER_ORIG]], align 2
415; LV-NEXT:    [[ADD_LVER_ORIG:%.*]] = mul i16 [[LOADA_LVER_ORIG]], [[LOADB_LVER_ORIG]]
416; LV-NEXT:    store i16 [[ADD_LVER_ORIG]], i16* [[ARRAYIDXA_LVER_ORIG]], align 2
417; LV-NEXT:    [[INC_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
418; LV-NEXT:    [[DEC_LVER_ORIG]] = sub i32 [[IND1_LVER_ORIG]], 1
419; LV-NEXT:    [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[INC_LVER_ORIG]], [[N]]
420; LV-NEXT:    br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
421; LV:       for.body.ph:
422; LV-NEXT:    br label [[FOR_BODY:%.*]]
423; LV:       for.body:
424; LV-NEXT:    [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
425; LV-NEXT:    [[IND1:%.*]] = phi i32 [ [[TRUNCN]], [[FOR_BODY_PH]] ], [ [[DEC:%.*]], [[FOR_BODY]] ]
426; LV-NEXT:    [[MUL:%.*]] = mul i32 [[IND1]], 2
427; LV-NEXT:    [[MUL_EXT:%.*]] = sext i32 [[MUL]] to i64
428; LV-NEXT:    [[ARRAYIDXA:%.*]] = getelementptr i16, i16* [[A]], i64 [[MUL_EXT]]
429; LV-NEXT:    [[LOADA:%.*]] = load i16, i16* [[ARRAYIDXA]], align 2
430; LV-NEXT:    [[ARRAYIDXB:%.*]] = getelementptr i16, i16* [[B]], i64 [[IND]]
431; LV-NEXT:    [[LOADB:%.*]] = load i16, i16* [[ARRAYIDXB]], align 2
432; LV-NEXT:    [[ADD:%.*]] = mul i16 [[LOADA]], [[LOADB]]
433; LV-NEXT:    store i16 [[ADD]], i16* [[ARRAYIDXA]], align 2
434; LV-NEXT:    [[INC]] = add nuw nsw i64 [[IND]], 1
435; LV-NEXT:    [[DEC]] = sub i32 [[IND1]], 1
436; LV-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[N]]
437; LV-NEXT:    br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT6:%.*]], label [[FOR_BODY]]
438; LV:       for.end.loopexit:
439; LV-NEXT:    br label [[FOR_END:%.*]]
440; LV:       for.end.loopexit6:
441; LV-NEXT:    br label [[FOR_END]]
442; LV:       for.end:
443; LV-NEXT:    ret void
444;
445  i16* noalias %b, i64 %N) {
446entry:
447  %TruncN = trunc i64 %N to i32
448  br label %for.body
449
450for.body:                                         ; preds = %for.body, %entry
451  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
452  %ind1 = phi i32 [ %TruncN, %entry ], [ %dec, %for.body ]
453
454  %mul = mul i32 %ind1, 2
455  %mul_ext = sext i32 %mul to i64
456
457  %arrayidxA = getelementptr i16, i16* %a, i64 %mul_ext
458  %loadA = load i16, i16* %arrayidxA, align 2
459
460  %arrayidxB = getelementptr i16, i16* %b, i64 %ind
461  %loadB = load i16, i16* %arrayidxB, align 2
462
463  %add = mul i16 %loadA, %loadB
464
465  store i16 %add, i16* %arrayidxA, align 2
466
467  %inc = add nuw nsw i64 %ind, 1
468  %dec = sub i32 %ind1, 1
469
470  %exitcond = icmp eq i64 %inc, %N
471  br i1 %exitcond, label %for.end, label %for.body
472
473for.end:                                          ; preds = %for.body
474  ret void
475}
476
477; The following function is similar to the one above, but has the GEP
478; to pointer %A inbounds. The index %mul doesn't have the nsw flag.
479; This means that the SCEV expression for %mul can wrap and we need
480; a SCEV predicate to continue analysis.
481;
482; We can still analyze this by adding the required no wrap SCEV predicates.
483
484define void @f5(i16* noalias %a,
485; LV-LABEL: @f5(
486; LV-NEXT:  for.body.lver.check:
487; LV-NEXT:    [[A2:%.*]] = ptrtoint i16* [[A:%.*]] to i64
488; LV-NEXT:    [[TRUNCN:%.*]] = trunc i64 [[N:%.*]] to i32
489; LV-NEXT:    [[TMP0:%.*]] = add i64 [[N]], -1
490; LV-NEXT:    [[TMP1:%.*]] = shl i32 [[TRUNCN]], 1
491; LV-NEXT:    [[TMP2:%.*]] = trunc i64 [[TMP0]] to i32
492; LV-NEXT:    [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]])
493; LV-NEXT:    [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
494; LV-NEXT:    [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
495; LV-NEXT:    [[TMP3:%.*]] = add i32 [[TMP1]], [[MUL_RESULT]]
496; LV-NEXT:    [[TMP4:%.*]] = sub i32 [[TMP1]], [[MUL_RESULT]]
497; LV-NEXT:    [[TMP5:%.*]] = icmp sgt i32 [[TMP4]], [[TMP1]]
498; LV-NEXT:    [[TMP6:%.*]] = icmp slt i32 [[TMP3]], [[TMP1]]
499; LV-NEXT:    [[TMP7:%.*]] = select i1 true, i1 [[TMP5]], i1 [[TMP6]]
500; LV-NEXT:    [[TMP8:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
501; LV-NEXT:    [[TMP9:%.*]] = or i1 [[TMP7]], [[TMP8]]
502; LV-NEXT:    [[TMP10:%.*]] = or i1 [[TMP9]], [[MUL_OVERFLOW]]
503; LV-NEXT:    [[TMP11:%.*]] = or i1 false, [[TMP10]]
504; LV-NEXT:    [[TMP12:%.*]] = sext i32 [[TMP1]] to i64
505; LV-NEXT:    [[TMP13:%.*]] = shl nsw i64 [[TMP12]], 1
506; LV-NEXT:    [[TMP14:%.*]] = add i64 [[A2]], [[TMP13]]
507; LV-NEXT:    [[MUL3:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
508; LV-NEXT:    [[MUL_RESULT4:%.*]] = extractvalue { i64, i1 } [[MUL3]], 0
509; LV-NEXT:    [[MUL_OVERFLOW5:%.*]] = extractvalue { i64, i1 } [[MUL3]], 1
510; LV-NEXT:    [[TMP15:%.*]] = add i64 [[TMP14]], [[MUL_RESULT4]]
511; LV-NEXT:    [[TMP16:%.*]] = sub i64 [[TMP14]], [[MUL_RESULT4]]
512; LV-NEXT:    [[TMP17:%.*]] = icmp ugt i64 [[TMP16]], [[TMP14]]
513; LV-NEXT:    [[TMP18:%.*]] = icmp ult i64 [[TMP15]], [[TMP14]]
514; LV-NEXT:    [[TMP19:%.*]] = select i1 true, i1 [[TMP17]], i1 [[TMP18]]
515; LV-NEXT:    [[TMP20:%.*]] = or i1 [[TMP19]], [[MUL_OVERFLOW5]]
516; LV-NEXT:    [[TMP21:%.*]] = or i1 [[TMP11]], [[TMP20]]
517; LV-NEXT:    br i1 [[TMP21]], label [[FOR_BODY_PH_LVER_ORIG:%.*]], label [[FOR_BODY_PH:%.*]]
518; LV:       for.body.ph.lver.orig:
519; LV-NEXT:    br label [[FOR_BODY_LVER_ORIG:%.*]]
520; LV:       for.body.lver.orig:
521; LV-NEXT:    [[IND_LVER_ORIG:%.*]] = phi i64 [ 0, [[FOR_BODY_PH_LVER_ORIG]] ], [ [[INC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
522; LV-NEXT:    [[IND1_LVER_ORIG:%.*]] = phi i32 [ [[TRUNCN]], [[FOR_BODY_PH_LVER_ORIG]] ], [ [[DEC_LVER_ORIG:%.*]], [[FOR_BODY_LVER_ORIG]] ]
523; LV-NEXT:    [[MUL_LVER_ORIG:%.*]] = mul i32 [[IND1_LVER_ORIG]], 2
524; LV-NEXT:    [[ARRAYIDXA_LVER_ORIG:%.*]] = getelementptr inbounds i16, i16* [[A]], i32 [[MUL_LVER_ORIG]]
525; LV-NEXT:    [[LOADA_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXA_LVER_ORIG]], align 2
526; LV-NEXT:    [[ARRAYIDXB_LVER_ORIG:%.*]] = getelementptr inbounds i16, i16* [[B:%.*]], i64 [[IND_LVER_ORIG]]
527; LV-NEXT:    [[LOADB_LVER_ORIG:%.*]] = load i16, i16* [[ARRAYIDXB_LVER_ORIG]], align 2
528; LV-NEXT:    [[ADD_LVER_ORIG:%.*]] = mul i16 [[LOADA_LVER_ORIG]], [[LOADB_LVER_ORIG]]
529; LV-NEXT:    store i16 [[ADD_LVER_ORIG]], i16* [[ARRAYIDXA_LVER_ORIG]], align 2
530; LV-NEXT:    [[INC_LVER_ORIG]] = add nuw nsw i64 [[IND_LVER_ORIG]], 1
531; LV-NEXT:    [[DEC_LVER_ORIG]] = sub i32 [[IND1_LVER_ORIG]], 1
532; LV-NEXT:    [[EXITCOND_LVER_ORIG:%.*]] = icmp eq i64 [[INC_LVER_ORIG]], [[N]]
533; LV-NEXT:    br i1 [[EXITCOND_LVER_ORIG]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_LVER_ORIG]]
534; LV:       for.body.ph:
535; LV-NEXT:    br label [[FOR_BODY:%.*]]
536; LV:       for.body:
537; LV-NEXT:    [[IND:%.*]] = phi i64 [ 0, [[FOR_BODY_PH]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
538; LV-NEXT:    [[IND1:%.*]] = phi i32 [ [[TRUNCN]], [[FOR_BODY_PH]] ], [ [[DEC:%.*]], [[FOR_BODY]] ]
539; LV-NEXT:    [[MUL:%.*]] = mul i32 [[IND1]], 2
540; LV-NEXT:    [[ARRAYIDXA:%.*]] = getelementptr inbounds i16, i16* [[A]], i32 [[MUL]]
541; LV-NEXT:    [[LOADA:%.*]] = load i16, i16* [[ARRAYIDXA]], align 2
542; LV-NEXT:    [[ARRAYIDXB:%.*]] = getelementptr inbounds i16, i16* [[B]], i64 [[IND]]
543; LV-NEXT:    [[LOADB:%.*]] = load i16, i16* [[ARRAYIDXB]], align 2
544; LV-NEXT:    [[ADD:%.*]] = mul i16 [[LOADA]], [[LOADB]]
545; LV-NEXT:    store i16 [[ADD]], i16* [[ARRAYIDXA]], align 2
546; LV-NEXT:    [[INC]] = add nuw nsw i64 [[IND]], 1
547; LV-NEXT:    [[DEC]] = sub i32 [[IND1]], 1
548; LV-NEXT:    [[EXITCOND:%.*]] = icmp eq i64 [[INC]], [[N]]
549; LV-NEXT:    br i1 [[EXITCOND]], label [[FOR_END_LOOPEXIT6:%.*]], label [[FOR_BODY]]
550; LV:       for.end.loopexit:
551; LV-NEXT:    br label [[FOR_END:%.*]]
552; LV:       for.end.loopexit6:
553; LV-NEXT:    br label [[FOR_END]]
554; LV:       for.end:
555; LV-NEXT:    ret void
556;
557  i16* noalias %b, i64 %N) {
558entry:
559  %TruncN = trunc i64 %N to i32
560  br label %for.body
561
562for.body:                                         ; preds = %for.body, %entry
563  %ind = phi i64 [ 0, %entry ], [ %inc, %for.body ]
564  %ind1 = phi i32 [ %TruncN, %entry ], [ %dec, %for.body ]
565
566  %mul = mul i32 %ind1, 2
567
568  %arrayidxA = getelementptr inbounds i16, i16* %a, i32 %mul
569  %loadA = load i16, i16* %arrayidxA, align 2
570
571  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
572  %loadB = load i16, i16* %arrayidxB, align 2
573
574  %add = mul i16 %loadA, %loadB
575
576  store i16 %add, i16* %arrayidxA, align 2
577
578  %inc = add nuw nsw i64 %ind, 1
579  %dec = sub i32 %ind1, 1
580
581  %exitcond = icmp eq i64 %inc, %N
582  br i1 %exitcond, label %for.end, label %for.body
583
584for.end:                                          ; preds = %for.body
585  ret void
586}
587