1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S | FileCheck %s
4 target 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"
5 target triple = "x86_64-apple-macosx10.8.0"
7 @c = common global [2048 x i32] zeroinitializer, align 16
8 @b = common global [2048 x i32] zeroinitializer, align 16
9 @d = common global [2048 x i32] zeroinitializer, align 16
10 @a = common global [2048 x i32] zeroinitializer, align 16
12 ; The program below gathers and scatters data. We better not vectorize it.
13 define void @cost_model_1() nounwind uwtable noinline ssp {
14 ; CHECK-LABEL: @cost_model_1(
16 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
18 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
19 ; CHECK-NEXT: [[TMP0:%.*]] = shl nsw i64 [[INDVARS_IV]], 1
20 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [2048 x i32], ptr @c, i64 0, i64 [[TMP0]]
21 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX]], align 8
22 ; CHECK-NEXT: [[IDXPROM1:%.*]] = sext i32 [[TMP1]] to i64
23 ; CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [2048 x i32], ptr @b, i64 0, i64 [[IDXPROM1]]
24 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX2]], align 4
25 ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds [2048 x i32], ptr @d, i64 0, i64 [[INDVARS_IV]]
26 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARRAYIDX4]], align 4
27 ; CHECK-NEXT: [[IDXPROM5:%.*]] = sext i32 [[TMP3]] to i64
28 ; CHECK-NEXT: [[ARRAYIDX6:%.*]] = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 [[IDXPROM5]]
29 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[ARRAYIDX6]], align 4
30 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add i64 [[INDVARS_IV]], 1
31 ; CHECK-NEXT: [[LFTR_WIDEIV:%.*]] = trunc i64 [[INDVARS_IV_NEXT]] to i32
32 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i32 [[LFTR_WIDEIV]], 256
33 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_END:%.*]], label [[FOR_BODY]]
35 ; CHECK-NEXT: ret void
40 for.body: ; preds = %for.body, %entry
41 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
42 %0 = shl nsw i64 %indvars.iv, 1
43 %arrayidx = getelementptr inbounds [2048 x i32], ptr @c, i64 0, i64 %0
44 %1 = load i32, ptr %arrayidx, align 8
45 %idxprom1 = sext i32 %1 to i64
46 %arrayidx2 = getelementptr inbounds [2048 x i32], ptr @b, i64 0, i64 %idxprom1
47 %2 = load i32, ptr %arrayidx2, align 4
48 %arrayidx4 = getelementptr inbounds [2048 x i32], ptr @d, i64 0, i64 %indvars.iv
49 %3 = load i32, ptr %arrayidx4, align 4
50 %idxprom5 = sext i32 %3 to i64
51 %arrayidx6 = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 %idxprom5
52 store i32 %2, ptr %arrayidx6, align 4
53 %indvars.iv.next = add i64 %indvars.iv, 1
54 %lftr.wideiv = trunc i64 %indvars.iv.next to i32
55 %exitcond = icmp eq i32 %lftr.wideiv, 256
56 br i1 %exitcond, label %for.end, label %for.body
58 for.end: ; preds = %for.body
62 ; This function uses a stride that is generally too big to benefit from vectorization without
63 ; really good support for a gather load. But if we don't vectorize the pointer induction,
64 ; then we don't need to extract the pointers out of vector of pointers,
65 ; and the vectorization becomes profitable.
67 define float @PR27826(ptr nocapture readonly %a, ptr nocapture readonly %b, i32 %n) {
68 ; CHECK-LABEL: @PR27826(
70 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], 0
71 ; CHECK-NEXT: br i1 [[CMP]], label [[PREHEADER:%.*]], label [[FOR_END:%.*]]
73 ; CHECK-NEXT: [[T0:%.*]] = sext i32 [[N]] to i64
74 ; CHECK-NEXT: [[TMP0:%.*]] = add nsw i64 [[T0]], -1
75 ; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[TMP0]], 5
76 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
77 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP2]], 16
78 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
80 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP2]], 16
81 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP2]], [[N_MOD_VF]]
82 ; CHECK-NEXT: [[IND_END:%.*]] = mul i64 [[N_VEC]], 32
83 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
85 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
86 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x float> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP119:%.*]], [[VECTOR_BODY]] ]
87 ; CHECK-NEXT: [[VEC_PHI1:%.*]] = phi <4 x float> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP120:%.*]], [[VECTOR_BODY]] ]
88 ; CHECK-NEXT: [[VEC_PHI2:%.*]] = phi <4 x float> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP121:%.*]], [[VECTOR_BODY]] ]
89 ; CHECK-NEXT: [[VEC_PHI3:%.*]] = phi <4 x float> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP122:%.*]], [[VECTOR_BODY]] ]
90 ; CHECK-NEXT: [[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 32
91 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[OFFSET_IDX]], 0
92 ; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[OFFSET_IDX]], 32
93 ; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[OFFSET_IDX]], 64
94 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[OFFSET_IDX]], 96
95 ; CHECK-NEXT: [[TMP7:%.*]] = add i64 [[OFFSET_IDX]], 128
96 ; CHECK-NEXT: [[TMP8:%.*]] = add i64 [[OFFSET_IDX]], 160
97 ; CHECK-NEXT: [[TMP9:%.*]] = add i64 [[OFFSET_IDX]], 192
98 ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[OFFSET_IDX]], 224
99 ; CHECK-NEXT: [[TMP11:%.*]] = add i64 [[OFFSET_IDX]], 256
100 ; CHECK-NEXT: [[TMP12:%.*]] = add i64 [[OFFSET_IDX]], 288
101 ; CHECK-NEXT: [[TMP13:%.*]] = add i64 [[OFFSET_IDX]], 320
102 ; CHECK-NEXT: [[TMP14:%.*]] = add i64 [[OFFSET_IDX]], 352
103 ; CHECK-NEXT: [[TMP15:%.*]] = add i64 [[OFFSET_IDX]], 384
104 ; CHECK-NEXT: [[TMP16:%.*]] = add i64 [[OFFSET_IDX]], 416
105 ; CHECK-NEXT: [[TMP17:%.*]] = add i64 [[OFFSET_IDX]], 448
106 ; CHECK-NEXT: [[TMP18:%.*]] = add i64 [[OFFSET_IDX]], 480
107 ; CHECK-NEXT: [[TMP19:%.*]] = getelementptr inbounds float, ptr [[A:%.*]], i64 [[TMP3]]
108 ; CHECK-NEXT: [[TMP20:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP4]]
109 ; CHECK-NEXT: [[TMP21:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP5]]
110 ; CHECK-NEXT: [[TMP22:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP6]]
111 ; CHECK-NEXT: [[TMP23:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP7]]
112 ; CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP8]]
113 ; CHECK-NEXT: [[TMP25:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP9]]
114 ; CHECK-NEXT: [[TMP26:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP10]]
115 ; CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP11]]
116 ; CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP12]]
117 ; CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP13]]
118 ; CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP14]]
119 ; CHECK-NEXT: [[TMP31:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP15]]
120 ; CHECK-NEXT: [[TMP32:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP16]]
121 ; CHECK-NEXT: [[TMP33:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP17]]
122 ; CHECK-NEXT: [[TMP34:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[TMP18]]
123 ; CHECK-NEXT: [[TMP35:%.*]] = load float, ptr [[TMP19]], align 4
124 ; CHECK-NEXT: [[TMP36:%.*]] = load float, ptr [[TMP20]], align 4
125 ; CHECK-NEXT: [[TMP37:%.*]] = load float, ptr [[TMP21]], align 4
126 ; CHECK-NEXT: [[TMP38:%.*]] = load float, ptr [[TMP22]], align 4
127 ; CHECK-NEXT: [[TMP39:%.*]] = insertelement <4 x float> poison, float [[TMP35]], i32 0
128 ; CHECK-NEXT: [[TMP40:%.*]] = insertelement <4 x float> [[TMP39]], float [[TMP36]], i32 1
129 ; CHECK-NEXT: [[TMP41:%.*]] = insertelement <4 x float> [[TMP40]], float [[TMP37]], i32 2
130 ; CHECK-NEXT: [[TMP42:%.*]] = insertelement <4 x float> [[TMP41]], float [[TMP38]], i32 3
131 ; CHECK-NEXT: [[TMP43:%.*]] = load float, ptr [[TMP23]], align 4
132 ; CHECK-NEXT: [[TMP44:%.*]] = load float, ptr [[TMP24]], align 4
133 ; CHECK-NEXT: [[TMP45:%.*]] = load float, ptr [[TMP25]], align 4
134 ; CHECK-NEXT: [[TMP46:%.*]] = load float, ptr [[TMP26]], align 4
135 ; CHECK-NEXT: [[TMP47:%.*]] = insertelement <4 x float> poison, float [[TMP43]], i32 0
136 ; CHECK-NEXT: [[TMP48:%.*]] = insertelement <4 x float> [[TMP47]], float [[TMP44]], i32 1
137 ; CHECK-NEXT: [[TMP49:%.*]] = insertelement <4 x float> [[TMP48]], float [[TMP45]], i32 2
138 ; CHECK-NEXT: [[TMP50:%.*]] = insertelement <4 x float> [[TMP49]], float [[TMP46]], i32 3
139 ; CHECK-NEXT: [[TMP51:%.*]] = load float, ptr [[TMP27]], align 4
140 ; CHECK-NEXT: [[TMP52:%.*]] = load float, ptr [[TMP28]], align 4
141 ; CHECK-NEXT: [[TMP53:%.*]] = load float, ptr [[TMP29]], align 4
142 ; CHECK-NEXT: [[TMP54:%.*]] = load float, ptr [[TMP30]], align 4
143 ; CHECK-NEXT: [[TMP55:%.*]] = insertelement <4 x float> poison, float [[TMP51]], i32 0
144 ; CHECK-NEXT: [[TMP56:%.*]] = insertelement <4 x float> [[TMP55]], float [[TMP52]], i32 1
145 ; CHECK-NEXT: [[TMP57:%.*]] = insertelement <4 x float> [[TMP56]], float [[TMP53]], i32 2
146 ; CHECK-NEXT: [[TMP58:%.*]] = insertelement <4 x float> [[TMP57]], float [[TMP54]], i32 3
147 ; CHECK-NEXT: [[TMP59:%.*]] = load float, ptr [[TMP31]], align 4
148 ; CHECK-NEXT: [[TMP60:%.*]] = load float, ptr [[TMP32]], align 4
149 ; CHECK-NEXT: [[TMP61:%.*]] = load float, ptr [[TMP33]], align 4
150 ; CHECK-NEXT: [[TMP62:%.*]] = load float, ptr [[TMP34]], align 4
151 ; CHECK-NEXT: [[TMP63:%.*]] = insertelement <4 x float> poison, float [[TMP59]], i32 0
152 ; CHECK-NEXT: [[TMP64:%.*]] = insertelement <4 x float> [[TMP63]], float [[TMP60]], i32 1
153 ; CHECK-NEXT: [[TMP65:%.*]] = insertelement <4 x float> [[TMP64]], float [[TMP61]], i32 2
154 ; CHECK-NEXT: [[TMP66:%.*]] = insertelement <4 x float> [[TMP65]], float [[TMP62]], i32 3
155 ; CHECK-NEXT: [[TMP67:%.*]] = getelementptr inbounds float, ptr [[B:%.*]], i64 [[TMP3]]
156 ; CHECK-NEXT: [[TMP68:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP4]]
157 ; CHECK-NEXT: [[TMP69:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP5]]
158 ; CHECK-NEXT: [[TMP70:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP6]]
159 ; CHECK-NEXT: [[TMP71:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP7]]
160 ; CHECK-NEXT: [[TMP72:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP8]]
161 ; CHECK-NEXT: [[TMP73:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP9]]
162 ; CHECK-NEXT: [[TMP74:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP10]]
163 ; CHECK-NEXT: [[TMP75:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP11]]
164 ; CHECK-NEXT: [[TMP76:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP12]]
165 ; CHECK-NEXT: [[TMP77:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP13]]
166 ; CHECK-NEXT: [[TMP78:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP14]]
167 ; CHECK-NEXT: [[TMP79:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP15]]
168 ; CHECK-NEXT: [[TMP80:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP16]]
169 ; CHECK-NEXT: [[TMP81:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP17]]
170 ; CHECK-NEXT: [[TMP82:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[TMP18]]
171 ; CHECK-NEXT: [[TMP83:%.*]] = load float, ptr [[TMP67]], align 4
172 ; CHECK-NEXT: [[TMP84:%.*]] = load float, ptr [[TMP68]], align 4
173 ; CHECK-NEXT: [[TMP85:%.*]] = load float, ptr [[TMP69]], align 4
174 ; CHECK-NEXT: [[TMP86:%.*]] = load float, ptr [[TMP70]], align 4
175 ; CHECK-NEXT: [[TMP87:%.*]] = insertelement <4 x float> poison, float [[TMP83]], i32 0
176 ; CHECK-NEXT: [[TMP88:%.*]] = insertelement <4 x float> [[TMP87]], float [[TMP84]], i32 1
177 ; CHECK-NEXT: [[TMP89:%.*]] = insertelement <4 x float> [[TMP88]], float [[TMP85]], i32 2
178 ; CHECK-NEXT: [[TMP90:%.*]] = insertelement <4 x float> [[TMP89]], float [[TMP86]], i32 3
179 ; CHECK-NEXT: [[TMP91:%.*]] = load float, ptr [[TMP71]], align 4
180 ; CHECK-NEXT: [[TMP92:%.*]] = load float, ptr [[TMP72]], align 4
181 ; CHECK-NEXT: [[TMP93:%.*]] = load float, ptr [[TMP73]], align 4
182 ; CHECK-NEXT: [[TMP94:%.*]] = load float, ptr [[TMP74]], align 4
183 ; CHECK-NEXT: [[TMP95:%.*]] = insertelement <4 x float> poison, float [[TMP91]], i32 0
184 ; CHECK-NEXT: [[TMP96:%.*]] = insertelement <4 x float> [[TMP95]], float [[TMP92]], i32 1
185 ; CHECK-NEXT: [[TMP97:%.*]] = insertelement <4 x float> [[TMP96]], float [[TMP93]], i32 2
186 ; CHECK-NEXT: [[TMP98:%.*]] = insertelement <4 x float> [[TMP97]], float [[TMP94]], i32 3
187 ; CHECK-NEXT: [[TMP99:%.*]] = load float, ptr [[TMP75]], align 4
188 ; CHECK-NEXT: [[TMP100:%.*]] = load float, ptr [[TMP76]], align 4
189 ; CHECK-NEXT: [[TMP101:%.*]] = load float, ptr [[TMP77]], align 4
190 ; CHECK-NEXT: [[TMP102:%.*]] = load float, ptr [[TMP78]], align 4
191 ; CHECK-NEXT: [[TMP103:%.*]] = insertelement <4 x float> poison, float [[TMP99]], i32 0
192 ; CHECK-NEXT: [[TMP104:%.*]] = insertelement <4 x float> [[TMP103]], float [[TMP100]], i32 1
193 ; CHECK-NEXT: [[TMP105:%.*]] = insertelement <4 x float> [[TMP104]], float [[TMP101]], i32 2
194 ; CHECK-NEXT: [[TMP106:%.*]] = insertelement <4 x float> [[TMP105]], float [[TMP102]], i32 3
195 ; CHECK-NEXT: [[TMP107:%.*]] = load float, ptr [[TMP79]], align 4
196 ; CHECK-NEXT: [[TMP108:%.*]] = load float, ptr [[TMP80]], align 4
197 ; CHECK-NEXT: [[TMP109:%.*]] = load float, ptr [[TMP81]], align 4
198 ; CHECK-NEXT: [[TMP110:%.*]] = load float, ptr [[TMP82]], align 4
199 ; CHECK-NEXT: [[TMP111:%.*]] = insertelement <4 x float> poison, float [[TMP107]], i32 0
200 ; CHECK-NEXT: [[TMP112:%.*]] = insertelement <4 x float> [[TMP111]], float [[TMP108]], i32 1
201 ; CHECK-NEXT: [[TMP113:%.*]] = insertelement <4 x float> [[TMP112]], float [[TMP109]], i32 2
202 ; CHECK-NEXT: [[TMP114:%.*]] = insertelement <4 x float> [[TMP113]], float [[TMP110]], i32 3
203 ; CHECK-NEXT: [[TMP115:%.*]] = fadd fast <4 x float> [[TMP42]], [[VEC_PHI]]
204 ; CHECK-NEXT: [[TMP116:%.*]] = fadd fast <4 x float> [[TMP50]], [[VEC_PHI1]]
205 ; CHECK-NEXT: [[TMP117:%.*]] = fadd fast <4 x float> [[TMP58]], [[VEC_PHI2]]
206 ; CHECK-NEXT: [[TMP118:%.*]] = fadd fast <4 x float> [[TMP66]], [[VEC_PHI3]]
207 ; CHECK-NEXT: [[TMP119]] = fadd fast <4 x float> [[TMP115]], [[TMP90]]
208 ; CHECK-NEXT: [[TMP120]] = fadd fast <4 x float> [[TMP116]], [[TMP98]]
209 ; CHECK-NEXT: [[TMP121]] = fadd fast <4 x float> [[TMP117]], [[TMP106]]
210 ; CHECK-NEXT: [[TMP122]] = fadd fast <4 x float> [[TMP118]], [[TMP114]]
211 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
212 ; CHECK-NEXT: [[TMP123:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
213 ; CHECK-NEXT: br i1 [[TMP123]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
214 ; CHECK: middle.block:
215 ; CHECK-NEXT: [[BIN_RDX:%.*]] = fadd fast <4 x float> [[TMP120]], [[TMP119]]
216 ; CHECK-NEXT: [[BIN_RDX4:%.*]] = fadd fast <4 x float> [[TMP121]], [[BIN_RDX]]
217 ; CHECK-NEXT: [[BIN_RDX5:%.*]] = fadd fast <4 x float> [[TMP122]], [[BIN_RDX4]]
218 ; CHECK-NEXT: [[TMP124:%.*]] = call fast float @llvm.vector.reduce.fadd.v4f32(float -0.000000e+00, <4 x float> [[BIN_RDX5]])
219 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP2]], [[N_VEC]]
220 ; CHECK-NEXT: br i1 [[CMP_N]], label [[LOOPEXIT:%.*]], label [[SCALAR_PH]]
222 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ 0, [[PREHEADER]] ]
223 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi float [ [[TMP124]], [[MIDDLE_BLOCK]] ], [ 0.000000e+00, [[PREHEADER]] ]
224 ; CHECK-NEXT: br label [[FOR:%.*]]
226 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR]] ]
227 ; CHECK-NEXT: [[S_02:%.*]] = phi float [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ], [ [[ADD4:%.*]], [[FOR]] ]
228 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds float, ptr [[A]], i64 [[INDVARS_IV]]
229 ; CHECK-NEXT: [[T1:%.*]] = load float, ptr [[ARRAYIDX]], align 4
230 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds float, ptr [[B]], i64 [[INDVARS_IV]]
231 ; CHECK-NEXT: [[T2:%.*]] = load float, ptr [[ARRAYIDX3]], align 4
232 ; CHECK-NEXT: [[ADD:%.*]] = fadd fast float [[T1]], [[S_02]]
233 ; CHECK-NEXT: [[ADD4]] = fadd fast float [[ADD]], [[T2]]
234 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 32
235 ; CHECK-NEXT: [[CMP1:%.*]] = icmp slt i64 [[INDVARS_IV_NEXT]], [[T0]]
236 ; CHECK-NEXT: br i1 [[CMP1]], label [[FOR]], label [[LOOPEXIT]], !llvm.loop [[LOOP3:![0-9]+]]
238 ; CHECK-NEXT: [[ADD4_LCSSA:%.*]] = phi float [ [[ADD4]], [[FOR]] ], [ [[TMP124]], [[MIDDLE_BLOCK]] ]
239 ; CHECK-NEXT: br label [[FOR_END]]
241 ; CHECK-NEXT: [[S_0_LCSSA:%.*]] = phi float [ 0.000000e+00, [[ENTRY:%.*]] ], [ [[ADD4_LCSSA]], [[LOOPEXIT]] ]
242 ; CHECK-NEXT: ret float [[S_0_LCSSA]]
245 %cmp = icmp sgt i32 %n, 0
246 br i1 %cmp, label %preheader, label %for.end
249 %t0 = sext i32 %n to i64
253 %indvars.iv = phi i64 [ 0, %preheader ], [ %indvars.iv.next, %for ]
254 %s.02 = phi float [ 0.0, %preheader ], [ %add4, %for ]
255 %arrayidx = getelementptr inbounds float, ptr %a, i64 %indvars.iv
256 %t1 = load float, ptr %arrayidx, align 4
257 %arrayidx3 = getelementptr inbounds float, ptr %b, i64 %indvars.iv
258 %t2 = load float, ptr %arrayidx3, align 4
259 %add = fadd fast float %t1, %s.02
260 %add4 = fadd fast float %add, %t2
261 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 32
262 %cmp1 = icmp slt i64 %indvars.iv.next, %t0
263 br i1 %cmp1, label %for, label %loopexit
266 %add4.lcssa = phi float [ %add4, %for ]
270 %s.0.lcssa = phi float [ 0.0, %entry ], [ %add4.lcssa, %loopexit ]
274 define void @multi_exit(ptr %dst, ptr %src.1, ptr %src.2, i64 %A, i64 %B) #0 {
275 ; CHECK-LABEL: @multi_exit(
277 ; CHECK-NEXT: [[UMAX6:%.*]] = call i64 @llvm.umax.i64(i64 [[B:%.*]], i64 1)
278 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[UMAX6]], -1
279 ; CHECK-NEXT: [[TMP1:%.*]] = freeze i64 [[TMP0]]
280 ; CHECK-NEXT: [[UMIN7:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP1]], i64 [[A:%.*]])
281 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw i64 [[UMIN7]], 1
282 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ule i64 [[TMP2]], 30
283 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_SCEVCHECK:%.*]]
284 ; CHECK: vector.scevcheck:
285 ; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[B]], i64 1)
286 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[UMAX]], -1
287 ; CHECK-NEXT: [[TMP4:%.*]] = freeze i64 [[TMP3]]
288 ; CHECK-NEXT: [[UMIN:%.*]] = call i64 @llvm.umin.i64(i64 [[TMP4]], i64 [[A]])
289 ; CHECK-NEXT: [[TMP5:%.*]] = icmp ugt i64 [[UMIN]], 4294967295
290 ; CHECK-NEXT: [[TMP6:%.*]] = trunc i64 [[UMIN]] to i32
291 ; CHECK-NEXT: [[TMP7:%.*]] = add i32 1, [[TMP6]]
292 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ult i32 [[TMP7]], 1
293 ; CHECK-NEXT: [[TMP9:%.*]] = icmp ugt i64 [[UMIN]], 4294967295
294 ; CHECK-NEXT: [[TMP10:%.*]] = or i1 [[TMP8]], [[TMP9]]
295 ; CHECK-NEXT: br i1 [[TMP10]], label [[SCALAR_PH]], label [[VECTOR_MEMCHECK:%.*]]
296 ; CHECK: vector.memcheck:
297 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[DST:%.*]], i64 1
298 ; CHECK-NEXT: [[SCEVGEP1:%.*]] = getelementptr i8, ptr [[SRC_1:%.*]], i64 8
299 ; CHECK-NEXT: [[SCEVGEP2:%.*]] = getelementptr i8, ptr [[SRC_2:%.*]], i64 8
300 ; CHECK-NEXT: [[BOUND0:%.*]] = icmp ult ptr [[DST]], [[SCEVGEP1]]
301 ; CHECK-NEXT: [[BOUND1:%.*]] = icmp ult ptr [[SRC_1]], [[SCEVGEP]]
302 ; CHECK-NEXT: [[FOUND_CONFLICT:%.*]] = and i1 [[BOUND0]], [[BOUND1]]
303 ; CHECK-NEXT: [[BOUND03:%.*]] = icmp ult ptr [[DST]], [[SCEVGEP2]]
304 ; CHECK-NEXT: [[BOUND14:%.*]] = icmp ult ptr [[SRC_2]], [[SCEVGEP]]
305 ; CHECK-NEXT: [[FOUND_CONFLICT5:%.*]] = and i1 [[BOUND03]], [[BOUND14]]
306 ; CHECK-NEXT: [[CONFLICT_RDX:%.*]] = or i1 [[FOUND_CONFLICT]], [[FOUND_CONFLICT5]]
307 ; CHECK-NEXT: br i1 [[CONFLICT_RDX]], label [[SCALAR_PH]], label [[VECTOR_PH:%.*]]
309 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP2]], 4
310 ; CHECK-NEXT: [[TMP11:%.*]] = icmp eq i64 [[N_MOD_VF]], 0
311 ; CHECK-NEXT: [[TMP12:%.*]] = select i1 [[TMP11]], i64 4, i64 [[N_MOD_VF]]
312 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP2]], [[TMP12]]
313 ; CHECK-NEXT: [[IND_END:%.*]] = trunc i64 [[N_VEC]] to i32
314 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
315 ; CHECK: vector.body:
316 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
317 ; CHECK-NEXT: [[TMP13:%.*]] = load i64, ptr [[SRC_1]], align 8, !alias.scope [[META4:![0-9]+]]
318 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT9:%.*]] = insertelement <2 x i64> poison, i64 [[TMP13]], i64 0
319 ; CHECK-NEXT: [[BROADCAST_SPLAT10:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT9]], <2 x i64> poison, <2 x i32> zeroinitializer
320 ; CHECK-NEXT: [[TMP14:%.*]] = load i64, ptr [[SRC_2]], align 8, !alias.scope [[META7:![0-9]+]]
321 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT13:%.*]] = insertelement <2 x i64> poison, i64 [[TMP14]], i64 0
322 ; CHECK-NEXT: [[BROADCAST_SPLAT14:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT13]], <2 x i64> poison, <2 x i32> zeroinitializer
323 ; CHECK-NEXT: [[TMP15:%.*]] = icmp eq <2 x i64> [[BROADCAST_SPLAT10]], zeroinitializer
324 ; CHECK-NEXT: [[TMP16:%.*]] = icmp eq <2 x i64> [[BROADCAST_SPLAT10]], zeroinitializer
325 ; CHECK-NEXT: [[TMP17:%.*]] = icmp ne <2 x i64> [[BROADCAST_SPLAT14]], zeroinitializer
326 ; CHECK-NEXT: [[TMP18:%.*]] = icmp ne <2 x i64> [[BROADCAST_SPLAT14]], zeroinitializer
327 ; CHECK-NEXT: [[TMP19:%.*]] = and <2 x i1> [[TMP17]], [[TMP15]]
328 ; CHECK-NEXT: [[TMP20:%.*]] = and <2 x i1> [[TMP18]], [[TMP16]]
329 ; CHECK-NEXT: [[TMP21:%.*]] = zext <2 x i1> [[TMP19]] to <2 x i8>
330 ; CHECK-NEXT: [[TMP22:%.*]] = zext <2 x i1> [[TMP20]] to <2 x i8>
331 ; CHECK-NEXT: [[TMP23:%.*]] = extractelement <2 x i8> [[TMP22]], i32 1
332 ; CHECK-NEXT: store i8 [[TMP23]], ptr [[DST]], align 1, !alias.scope [[META9:![0-9]+]], !noalias [[META11:![0-9]+]]
333 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
334 ; CHECK-NEXT: [[TMP24:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
335 ; CHECK-NEXT: br i1 [[TMP24]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP12:![0-9]+]]
336 ; CHECK: middle.block:
337 ; CHECK-NEXT: br label [[SCALAR_PH]]
339 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ], [ 0, [[VECTOR_SCEVCHECK]] ], [ 0, [[VECTOR_MEMCHECK]] ]
340 ; CHECK-NEXT: [[BC_RESUME_VAL8:%.*]] = phi i32 [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY]] ], [ 0, [[VECTOR_SCEVCHECK]] ], [ 0, [[VECTOR_MEMCHECK]] ]
341 ; CHECK-NEXT: br label [[LOOP:%.*]]
343 ; CHECK-NEXT: [[IV_1_WIDE:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_1_NEXT_WIDE:%.*]], [[LOOP_LATCH:%.*]] ]
344 ; CHECK-NEXT: [[IV_1:%.*]] = phi i32 [ [[BC_RESUME_VAL8]], [[SCALAR_PH]] ], [ [[IV_1_NEXT:%.*]], [[LOOP_LATCH]] ]
345 ; CHECK-NEXT: [[EC_1:%.*]] = icmp ult i64 [[IV_1_WIDE]], [[A]]
346 ; CHECK-NEXT: br i1 [[EC_1]], label [[LOOP_LATCH]], label [[EXIT:%.*]]
348 ; CHECK-NEXT: [[L_1:%.*]] = load i64, ptr [[SRC_1]], align 8
349 ; CHECK-NEXT: [[L_2:%.*]] = load i64, ptr [[SRC_2]], align 8
350 ; CHECK-NEXT: [[CMP55_US:%.*]] = icmp eq i64 [[L_1]], 0
351 ; CHECK-NEXT: [[CMP_I_US:%.*]] = icmp ne i64 [[L_2]], 0
352 ; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP_I_US]], [[CMP55_US]]
353 ; CHECK-NEXT: [[EXT:%.*]] = zext i1 [[AND]] to i8
354 ; CHECK-NEXT: store i8 [[EXT]], ptr [[DST]], align 1
355 ; CHECK-NEXT: [[IV_1_NEXT]] = add i32 [[IV_1]], 1
356 ; CHECK-NEXT: [[IV_1_NEXT_WIDE]] = zext i32 [[IV_1_NEXT]] to i64
357 ; CHECK-NEXT: [[EC_2:%.*]] = icmp ult i64 [[IV_1_NEXT_WIDE]], [[B]]
358 ; CHECK-NEXT: br i1 [[EC_2]], label [[LOOP]], label [[EXIT]], !llvm.loop [[LOOP13:![0-9]+]]
360 ; CHECK-NEXT: ret void
366 %iv.1.wide = phi i64 [ 0, %entry ], [ %iv.1.next.wide, %loop.latch ]
367 %iv.1 = phi i32 [ 0, %entry ], [ %iv.1.next, %loop.latch ]
368 %ec.1 = icmp ult i64 %iv.1.wide, %A
369 br i1 %ec.1, label %loop.latch, label %exit
372 %l.1 = load i64, ptr %src.1, align 8
373 %l.2 = load i64, ptr %src.2, align 8
374 %cmp55.us = icmp eq i64 %l.1, 0
375 %cmp.i.us = icmp ne i64 %l.2, 0
376 %and = and i1 %cmp.i.us, %cmp55.us
377 %ext = zext i1 %and to i8
378 store i8 %ext, ptr %dst, align 1
379 %iv.1.next = add i32 %iv.1, 1
380 %iv.1.next.wide = zext i32 %iv.1.next to i64
381 %ec.2 = icmp ult i64 %iv.1.next.wide, %B
382 br i1 %ec.2, label %loop, label %exit
388 define i1 @any_of_cost(ptr %start, ptr %end) #0 {
389 ; CHECK-LABEL: @any_of_cost(
391 ; CHECK-NEXT: [[START2:%.*]] = ptrtoint ptr [[START:%.*]] to i64
392 ; CHECK-NEXT: [[END1:%.*]] = ptrtoint ptr [[END:%.*]] to i64
393 ; CHECK-NEXT: [[TMP0:%.*]] = sub i64 [[END1]], [[START2]]
394 ; CHECK-NEXT: [[TMP1:%.*]] = udiv i64 [[TMP0]], 40
395 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
396 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ule i64 [[TMP2]], 4
397 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
399 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP2]], 4
400 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[N_MOD_VF]], 0
401 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i64 4, i64 [[N_MOD_VF]]
402 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP2]], [[TMP4]]
403 ; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[N_VEC]], 40
404 ; CHECK-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP5]]
405 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
406 ; CHECK: vector.body:
407 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
408 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <2 x i1> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP26:%.*]], [[VECTOR_BODY]] ]
409 ; CHECK-NEXT: [[VEC_PHI3:%.*]] = phi <2 x i1> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP27:%.*]], [[VECTOR_BODY]] ]
410 ; CHECK-NEXT: [[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 40
411 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[OFFSET_IDX]], 0
412 ; CHECK-NEXT: [[TMP7:%.*]] = add i64 [[OFFSET_IDX]], 40
413 ; CHECK-NEXT: [[TMP8:%.*]] = add i64 [[OFFSET_IDX]], 80
414 ; CHECK-NEXT: [[TMP9:%.*]] = add i64 [[OFFSET_IDX]], 120
415 ; CHECK-NEXT: [[NEXT_GEP:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP6]]
416 ; CHECK-NEXT: [[NEXT_GEP4:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP7]]
417 ; CHECK-NEXT: [[NEXT_GEP5:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP8]]
418 ; CHECK-NEXT: [[NEXT_GEP6:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP9]]
419 ; CHECK-NEXT: [[TMP10:%.*]] = getelementptr i8, ptr [[NEXT_GEP]], i64 8
420 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr i8, ptr [[NEXT_GEP4]], i64 8
421 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i8, ptr [[NEXT_GEP5]], i64 8
422 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr i8, ptr [[NEXT_GEP6]], i64 8
423 ; CHECK-NEXT: [[TMP14:%.*]] = load ptr, ptr [[TMP10]], align 8
424 ; CHECK-NEXT: [[TMP15:%.*]] = load ptr, ptr [[TMP11]], align 8
425 ; CHECK-NEXT: [[TMP16:%.*]] = insertelement <2 x ptr> poison, ptr [[TMP14]], i32 0
426 ; CHECK-NEXT: [[TMP17:%.*]] = insertelement <2 x ptr> [[TMP16]], ptr [[TMP15]], i32 1
427 ; CHECK-NEXT: [[TMP18:%.*]] = load ptr, ptr [[TMP12]], align 8
428 ; CHECK-NEXT: [[TMP19:%.*]] = load ptr, ptr [[TMP13]], align 8
429 ; CHECK-NEXT: [[TMP20:%.*]] = insertelement <2 x ptr> poison, ptr [[TMP18]], i32 0
430 ; CHECK-NEXT: [[TMP21:%.*]] = insertelement <2 x ptr> [[TMP20]], ptr [[TMP19]], i32 1
431 ; CHECK-NEXT: [[TMP22:%.*]] = icmp eq <2 x ptr> [[TMP17]], zeroinitializer
432 ; CHECK-NEXT: [[TMP23:%.*]] = icmp eq <2 x ptr> [[TMP21]], zeroinitializer
433 ; CHECK-NEXT: [[TMP24:%.*]] = xor <2 x i1> [[TMP22]], <i1 true, i1 true>
434 ; CHECK-NEXT: [[TMP25:%.*]] = xor <2 x i1> [[TMP23]], <i1 true, i1 true>
435 ; CHECK-NEXT: [[TMP26]] = or <2 x i1> [[VEC_PHI]], [[TMP24]]
436 ; CHECK-NEXT: [[TMP27]] = or <2 x i1> [[VEC_PHI3]], [[TMP25]]
437 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
438 ; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
439 ; CHECK-NEXT: br i1 [[TMP28]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP14:![0-9]+]]
440 ; CHECK: middle.block:
441 ; CHECK-NEXT: [[BIN_RDX:%.*]] = or <2 x i1> [[TMP27]], [[TMP26]]
442 ; CHECK-NEXT: [[TMP29:%.*]] = call i1 @llvm.vector.reduce.or.v2i1(<2 x i1> [[BIN_RDX]])
443 ; CHECK-NEXT: [[TMP30:%.*]] = freeze i1 [[TMP29]]
444 ; CHECK-NEXT: [[RDX_SELECT:%.*]] = select i1 [[TMP30]], i1 false, i1 false
445 ; CHECK-NEXT: br label [[SCALAR_PH]]
447 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi ptr [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ [[START]], [[ENTRY:%.*]] ]
448 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i1 [ [[RDX_SELECT]], [[MIDDLE_BLOCK]] ], [ false, [[ENTRY]] ]
449 ; CHECK-NEXT: br label [[LOOP:%.*]]
451 ; CHECK-NEXT: [[ANY_OF:%.*]] = phi i1 [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ], [ [[ANY_OF_NEXT:%.*]], [[LOOP]] ]
452 ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP]] ]
453 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr [[PTR_IV]], i64 8
454 ; CHECK-NEXT: [[L:%.*]] = load ptr, ptr [[GEP]], align 8
455 ; CHECK-NEXT: [[CMP13_NOT_NOT:%.*]] = icmp eq ptr [[L]], null
456 ; CHECK-NEXT: [[ANY_OF_NEXT]] = select i1 [[CMP13_NOT_NOT]], i1 [[ANY_OF]], i1 false
457 ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i8, ptr [[PTR_IV]], i64 40
458 ; CHECK-NEXT: [[CMP_NOT:%.*]] = icmp eq ptr [[PTR_IV]], [[END]]
459 ; CHECK-NEXT: br i1 [[CMP_NOT]], label [[EXIT:%.*]], label [[LOOP]], !llvm.loop [[LOOP15:![0-9]+]]
461 ; CHECK-NEXT: [[ANY_OF_NEXT_LCSSA:%.*]] = phi i1 [ [[ANY_OF_NEXT]], [[LOOP]] ]
462 ; CHECK-NEXT: ret i1 [[ANY_OF_NEXT_LCSSA]]
468 %any.of = phi i1 [ false, %entry ], [ %any.of.next, %loop ]
469 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop ]
470 %gep = getelementptr i8, ptr %ptr.iv, i64 8
471 %l = load ptr, ptr %gep, align 8
472 %cmp13.not.not = icmp eq ptr %l, null
473 %any.of.next = select i1 %cmp13.not.not, i1 %any.of, i1 false
474 %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 40
475 %cmp.not = icmp eq ptr %ptr.iv, %end
476 br i1 %cmp.not, label %exit, label %loop
482 define i64 @avx512_cond_load_cost(ptr %src, i32 %a, i64 %b, i32 %c, i32 %d) #1 {
483 ; CHECK-LABEL: @avx512_cond_load_cost(
485 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
486 ; CHECK: loop.header:
487 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
488 ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i32 [[IV]], 0
489 ; CHECK-NEXT: br i1 [[C_1]], label [[IF_THEN:%.*]], label [[LOOP_LATCH]]
491 ; CHECK-NEXT: [[TMP0:%.*]] = urem i32 [[A:%.*]], [[C:%.*]]
492 ; CHECK-NEXT: [[MUL:%.*]] = sub i32 0, [[TMP0]]
493 ; CHECK-NEXT: [[DIV:%.*]] = udiv i32 [[C]], [[D:%.*]]
494 ; CHECK-NEXT: [[OR:%.*]] = or i32 [[DIV]], [[MUL]]
495 ; CHECK-NEXT: [[EXT:%.*]] = sext i32 [[OR]] to i64
496 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr { i64, i64, i64 }, ptr [[SRC:%.*]], i64 [[EXT]], i32 2
497 ; CHECK-NEXT: [[L:%.*]] = load i64, ptr [[GEP]], align 8
498 ; CHECK-NEXT: [[OR_2:%.*]] = or i64 [[L]], [[B:%.*]]
499 ; CHECK-NEXT: br label [[LOOP_LATCH]]
501 ; CHECK-NEXT: [[RES:%.*]] = phi i64 [ 0, [[LOOP_HEADER]] ], [ [[OR_2]], [[IF_THEN]] ]
502 ; CHECK-NEXT: [[IV_NEXT]] = add i32 [[IV]], 1
503 ; CHECK-NEXT: [[EC:%.*]] = icmp ult i32 [[IV]], [[C]]
504 ; CHECK-NEXT: br i1 [[EC]], label [[LOOP_HEADER]], label [[EXIT:%.*]]
506 ; CHECK-NEXT: [[RES_LCSSA:%.*]] = phi i64 [ [[RES]], [[LOOP_LATCH]] ]
507 ; CHECK-NEXT: ret i64 [[RES_LCSSA]]
510 br label %loop.header
513 %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]
514 %c.1 = icmp slt i32 %iv, 0
515 br i1 %c.1, label %if.then, label %loop.latch
520 %div = udiv i32 %c, %d
521 %or = or i32 %div, %mul
522 %ext = sext i32 %or to i64
523 %gep = getelementptr { i64, i64, i64 }, ptr %src, i64 %ext, i32 2
524 %l = load i64, ptr %gep, align 8
525 %or.2 = or i64 %l, %b
529 %res = phi i64 [ 0, %loop.header ], [ %or.2, %if.then ]
530 %iv.next = add i32 %iv, 1
531 %ec = icmp ult i32 %iv, %c
532 br i1 %ec, label %loop.header, label %exit
538 define void @cost_duplicate_recipe_for_sinking(ptr %A, i64 %N) #2 {
539 ; CHECK-LABEL: @cost_duplicate_recipe_for_sinking(
541 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], 1
542 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ule i64 [[TMP0]], 16
543 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
545 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP0]], 16
546 ; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i64 [[N_MOD_VF]], 0
547 ; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i64 16, i64 [[N_MOD_VF]]
548 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP0]], [[TMP2]]
549 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
550 ; CHECK: vector.body:
551 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE36:%.*]] ]
552 ; CHECK-NEXT: [[TMP3:%.*]] = add i64 [[INDEX]], 0
553 ; CHECK-NEXT: [[TMP4:%.*]] = add i64 [[INDEX]], 4
554 ; CHECK-NEXT: [[TMP5:%.*]] = add i64 [[INDEX]], 8
555 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[INDEX]], 12
556 ; CHECK-NEXT: [[TMP7:%.*]] = shl nsw i64 [[TMP3]], 2
557 ; CHECK-NEXT: [[TMP8:%.*]] = shl nsw i64 [[TMP4]], 2
558 ; CHECK-NEXT: [[TMP9:%.*]] = shl nsw i64 [[TMP5]], 2
559 ; CHECK-NEXT: [[TMP10:%.*]] = shl nsw i64 [[TMP6]], 2
560 ; CHECK-NEXT: [[TMP11:%.*]] = getelementptr double, ptr [[A:%.*]], i64 [[TMP7]]
561 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP8]]
562 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP9]]
563 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP10]]
564 ; CHECK-NEXT: [[TMP15:%.*]] = getelementptr double, ptr [[TMP11]], i32 0
565 ; CHECK-NEXT: [[TMP16:%.*]] = getelementptr double, ptr [[TMP12]], i32 0
566 ; CHECK-NEXT: [[TMP17:%.*]] = getelementptr double, ptr [[TMP13]], i32 0
567 ; CHECK-NEXT: [[TMP18:%.*]] = getelementptr double, ptr [[TMP14]], i32 0
568 ; CHECK-NEXT: [[WIDE_VEC:%.*]] = load <16 x double>, ptr [[TMP15]], align 8
569 ; CHECK-NEXT: [[WIDE_VEC1:%.*]] = load <16 x double>, ptr [[TMP16]], align 8
570 ; CHECK-NEXT: [[WIDE_VEC2:%.*]] = load <16 x double>, ptr [[TMP17]], align 8
571 ; CHECK-NEXT: [[WIDE_VEC3:%.*]] = load <16 x double>, ptr [[TMP18]], align 8
572 ; CHECK-NEXT: [[STRIDED_VEC:%.*]] = shufflevector <16 x double> [[WIDE_VEC]], <16 x double> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
573 ; CHECK-NEXT: [[STRIDED_VEC4:%.*]] = shufflevector <16 x double> [[WIDE_VEC1]], <16 x double> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
574 ; CHECK-NEXT: [[STRIDED_VEC5:%.*]] = shufflevector <16 x double> [[WIDE_VEC2]], <16 x double> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
575 ; CHECK-NEXT: [[STRIDED_VEC6:%.*]] = shufflevector <16 x double> [[WIDE_VEC3]], <16 x double> poison, <4 x i32> <i32 0, i32 4, i32 8, i32 12>
576 ; CHECK-NEXT: [[TMP19:%.*]] = fcmp oeq <4 x double> [[STRIDED_VEC]], zeroinitializer
577 ; CHECK-NEXT: [[TMP20:%.*]] = fcmp oeq <4 x double> [[STRIDED_VEC4]], zeroinitializer
578 ; CHECK-NEXT: [[TMP21:%.*]] = fcmp oeq <4 x double> [[STRIDED_VEC5]], zeroinitializer
579 ; CHECK-NEXT: [[TMP22:%.*]] = fcmp oeq <4 x double> [[STRIDED_VEC6]], zeroinitializer
580 ; CHECK-NEXT: [[TMP23:%.*]] = extractelement <4 x i1> [[TMP19]], i32 0
581 ; CHECK-NEXT: br i1 [[TMP23]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]]
582 ; CHECK: pred.store.if:
583 ; CHECK-NEXT: [[TMP24:%.*]] = shl nsw i64 [[TMP3]], 2
584 ; CHECK-NEXT: [[TMP25:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP24]]
585 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP25]], align 8
586 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE]]
587 ; CHECK: pred.store.continue:
588 ; CHECK-NEXT: [[TMP26:%.*]] = extractelement <4 x i1> [[TMP19]], i32 1
589 ; CHECK-NEXT: br i1 [[TMP26]], label [[PRED_STORE_IF7:%.*]], label [[PRED_STORE_CONTINUE8:%.*]]
590 ; CHECK: pred.store.if7:
591 ; CHECK-NEXT: [[TMP27:%.*]] = add i64 [[INDEX]], 1
592 ; CHECK-NEXT: [[TMP28:%.*]] = shl nsw i64 [[TMP27]], 2
593 ; CHECK-NEXT: [[TMP29:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP28]]
594 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP29]], align 8
595 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE8]]
596 ; CHECK: pred.store.continue8:
597 ; CHECK-NEXT: [[TMP30:%.*]] = extractelement <4 x i1> [[TMP19]], i32 2
598 ; CHECK-NEXT: br i1 [[TMP30]], label [[PRED_STORE_IF9:%.*]], label [[PRED_STORE_CONTINUE10:%.*]]
599 ; CHECK: pred.store.if9:
600 ; CHECK-NEXT: [[TMP31:%.*]] = add i64 [[INDEX]], 2
601 ; CHECK-NEXT: [[TMP32:%.*]] = shl nsw i64 [[TMP31]], 2
602 ; CHECK-NEXT: [[TMP33:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP32]]
603 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP33]], align 8
604 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE10]]
605 ; CHECK: pred.store.continue10:
606 ; CHECK-NEXT: [[TMP34:%.*]] = extractelement <4 x i1> [[TMP19]], i32 3
607 ; CHECK-NEXT: br i1 [[TMP34]], label [[PRED_STORE_IF11:%.*]], label [[PRED_STORE_CONTINUE12:%.*]]
608 ; CHECK: pred.store.if11:
609 ; CHECK-NEXT: [[TMP35:%.*]] = add i64 [[INDEX]], 3
610 ; CHECK-NEXT: [[TMP36:%.*]] = shl nsw i64 [[TMP35]], 2
611 ; CHECK-NEXT: [[TMP37:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP36]]
612 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP37]], align 8
613 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE12]]
614 ; CHECK: pred.store.continue12:
615 ; CHECK-NEXT: [[TMP38:%.*]] = extractelement <4 x i1> [[TMP20]], i32 0
616 ; CHECK-NEXT: br i1 [[TMP38]], label [[PRED_STORE_IF13:%.*]], label [[PRED_STORE_CONTINUE14:%.*]]
617 ; CHECK: pred.store.if13:
618 ; CHECK-NEXT: [[TMP39:%.*]] = shl nsw i64 [[TMP4]], 2
619 ; CHECK-NEXT: [[TMP40:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP39]]
620 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP40]], align 8
621 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE14]]
622 ; CHECK: pred.store.continue14:
623 ; CHECK-NEXT: [[TMP41:%.*]] = extractelement <4 x i1> [[TMP20]], i32 1
624 ; CHECK-NEXT: br i1 [[TMP41]], label [[PRED_STORE_IF15:%.*]], label [[PRED_STORE_CONTINUE16:%.*]]
625 ; CHECK: pred.store.if15:
626 ; CHECK-NEXT: [[TMP42:%.*]] = add i64 [[INDEX]], 5
627 ; CHECK-NEXT: [[TMP43:%.*]] = shl nsw i64 [[TMP42]], 2
628 ; CHECK-NEXT: [[TMP44:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP43]]
629 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP44]], align 8
630 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE16]]
631 ; CHECK: pred.store.continue16:
632 ; CHECK-NEXT: [[TMP45:%.*]] = extractelement <4 x i1> [[TMP20]], i32 2
633 ; CHECK-NEXT: br i1 [[TMP45]], label [[PRED_STORE_IF17:%.*]], label [[PRED_STORE_CONTINUE18:%.*]]
634 ; CHECK: pred.store.if17:
635 ; CHECK-NEXT: [[TMP46:%.*]] = add i64 [[INDEX]], 6
636 ; CHECK-NEXT: [[TMP47:%.*]] = shl nsw i64 [[TMP46]], 2
637 ; CHECK-NEXT: [[TMP48:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP47]]
638 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP48]], align 8
639 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE18]]
640 ; CHECK: pred.store.continue18:
641 ; CHECK-NEXT: [[TMP49:%.*]] = extractelement <4 x i1> [[TMP20]], i32 3
642 ; CHECK-NEXT: br i1 [[TMP49]], label [[PRED_STORE_IF19:%.*]], label [[PRED_STORE_CONTINUE20:%.*]]
643 ; CHECK: pred.store.if19:
644 ; CHECK-NEXT: [[TMP50:%.*]] = add i64 [[INDEX]], 7
645 ; CHECK-NEXT: [[TMP51:%.*]] = shl nsw i64 [[TMP50]], 2
646 ; CHECK-NEXT: [[TMP52:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP51]]
647 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP52]], align 8
648 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE20]]
649 ; CHECK: pred.store.continue20:
650 ; CHECK-NEXT: [[TMP53:%.*]] = extractelement <4 x i1> [[TMP21]], i32 0
651 ; CHECK-NEXT: br i1 [[TMP53]], label [[PRED_STORE_IF21:%.*]], label [[PRED_STORE_CONTINUE22:%.*]]
652 ; CHECK: pred.store.if21:
653 ; CHECK-NEXT: [[TMP54:%.*]] = shl nsw i64 [[TMP5]], 2
654 ; CHECK-NEXT: [[TMP55:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP54]]
655 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP55]], align 8
656 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE22]]
657 ; CHECK: pred.store.continue22:
658 ; CHECK-NEXT: [[TMP56:%.*]] = extractelement <4 x i1> [[TMP21]], i32 1
659 ; CHECK-NEXT: br i1 [[TMP56]], label [[PRED_STORE_IF23:%.*]], label [[PRED_STORE_CONTINUE24:%.*]]
660 ; CHECK: pred.store.if23:
661 ; CHECK-NEXT: [[TMP57:%.*]] = add i64 [[INDEX]], 9
662 ; CHECK-NEXT: [[TMP58:%.*]] = shl nsw i64 [[TMP57]], 2
663 ; CHECK-NEXT: [[TMP59:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP58]]
664 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP59]], align 8
665 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE24]]
666 ; CHECK: pred.store.continue24:
667 ; CHECK-NEXT: [[TMP60:%.*]] = extractelement <4 x i1> [[TMP21]], i32 2
668 ; CHECK-NEXT: br i1 [[TMP60]], label [[PRED_STORE_IF25:%.*]], label [[PRED_STORE_CONTINUE26:%.*]]
669 ; CHECK: pred.store.if25:
670 ; CHECK-NEXT: [[TMP61:%.*]] = add i64 [[INDEX]], 10
671 ; CHECK-NEXT: [[TMP62:%.*]] = shl nsw i64 [[TMP61]], 2
672 ; CHECK-NEXT: [[TMP63:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP62]]
673 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP63]], align 8
674 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE26]]
675 ; CHECK: pred.store.continue26:
676 ; CHECK-NEXT: [[TMP64:%.*]] = extractelement <4 x i1> [[TMP21]], i32 3
677 ; CHECK-NEXT: br i1 [[TMP64]], label [[PRED_STORE_IF27:%.*]], label [[PRED_STORE_CONTINUE28:%.*]]
678 ; CHECK: pred.store.if27:
679 ; CHECK-NEXT: [[TMP65:%.*]] = add i64 [[INDEX]], 11
680 ; CHECK-NEXT: [[TMP66:%.*]] = shl nsw i64 [[TMP65]], 2
681 ; CHECK-NEXT: [[TMP67:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP66]]
682 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP67]], align 8
683 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE28]]
684 ; CHECK: pred.store.continue28:
685 ; CHECK-NEXT: [[TMP68:%.*]] = extractelement <4 x i1> [[TMP22]], i32 0
686 ; CHECK-NEXT: br i1 [[TMP68]], label [[PRED_STORE_IF29:%.*]], label [[PRED_STORE_CONTINUE30:%.*]]
687 ; CHECK: pred.store.if29:
688 ; CHECK-NEXT: [[TMP69:%.*]] = shl nsw i64 [[TMP6]], 2
689 ; CHECK-NEXT: [[TMP70:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP69]]
690 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP70]], align 8
691 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE30]]
692 ; CHECK: pred.store.continue30:
693 ; CHECK-NEXT: [[TMP71:%.*]] = extractelement <4 x i1> [[TMP22]], i32 1
694 ; CHECK-NEXT: br i1 [[TMP71]], label [[PRED_STORE_IF31:%.*]], label [[PRED_STORE_CONTINUE32:%.*]]
695 ; CHECK: pred.store.if31:
696 ; CHECK-NEXT: [[TMP72:%.*]] = add i64 [[INDEX]], 13
697 ; CHECK-NEXT: [[TMP73:%.*]] = shl nsw i64 [[TMP72]], 2
698 ; CHECK-NEXT: [[TMP74:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP73]]
699 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP74]], align 8
700 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE32]]
701 ; CHECK: pred.store.continue32:
702 ; CHECK-NEXT: [[TMP75:%.*]] = extractelement <4 x i1> [[TMP22]], i32 2
703 ; CHECK-NEXT: br i1 [[TMP75]], label [[PRED_STORE_IF33:%.*]], label [[PRED_STORE_CONTINUE34:%.*]]
704 ; CHECK: pred.store.if33:
705 ; CHECK-NEXT: [[TMP76:%.*]] = add i64 [[INDEX]], 14
706 ; CHECK-NEXT: [[TMP77:%.*]] = shl nsw i64 [[TMP76]], 2
707 ; CHECK-NEXT: [[TMP78:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP77]]
708 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP78]], align 8
709 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE34]]
710 ; CHECK: pred.store.continue34:
711 ; CHECK-NEXT: [[TMP79:%.*]] = extractelement <4 x i1> [[TMP22]], i32 3
712 ; CHECK-NEXT: br i1 [[TMP79]], label [[PRED_STORE_IF35:%.*]], label [[PRED_STORE_CONTINUE36]]
713 ; CHECK: pred.store.if35:
714 ; CHECK-NEXT: [[TMP80:%.*]] = add i64 [[INDEX]], 15
715 ; CHECK-NEXT: [[TMP81:%.*]] = shl nsw i64 [[TMP80]], 2
716 ; CHECK-NEXT: [[TMP82:%.*]] = getelementptr double, ptr [[A]], i64 [[TMP81]]
717 ; CHECK-NEXT: store double 0.000000e+00, ptr [[TMP82]], align 8
718 ; CHECK-NEXT: br label [[PRED_STORE_CONTINUE36]]
719 ; CHECK: pred.store.continue36:
720 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 16
721 ; CHECK-NEXT: [[TMP83:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
722 ; CHECK-NEXT: br i1 [[TMP83]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP16:![0-9]+]]
723 ; CHECK: middle.block:
724 ; CHECK-NEXT: br label [[SCALAR_PH]]
726 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
727 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
728 ; CHECK: loop.header:
729 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP_LATCH:%.*]] ]
730 ; CHECK-NEXT: [[IV_SHL:%.*]] = shl nsw i64 [[IV]], 2
731 ; CHECK-NEXT: [[GEP_0:%.*]] = getelementptr nusw double, ptr [[A]], i64 [[IV_SHL]]
732 ; CHECK-NEXT: [[L:%.*]] = load double, ptr [[GEP_0]], align 8
733 ; CHECK-NEXT: [[C:%.*]] = fcmp oeq double [[L]], 0.000000e+00
734 ; CHECK-NEXT: br i1 [[C]], label [[IF_THEN:%.*]], label [[LOOP_LATCH]]
736 ; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr double, ptr [[A]], i64 [[IV_SHL]]
737 ; CHECK-NEXT: store double 0.000000e+00, ptr [[GEP_1]], align 8
738 ; CHECK-NEXT: br label [[LOOP_LATCH]]
740 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], 1
741 ; CHECK-NEXT: [[EC:%.*]] = icmp eq i64 [[IV]], [[N]]
742 ; CHECK-NEXT: br i1 [[EC]], label [[EXIT:%.*]], label [[LOOP_HEADER]], !llvm.loop [[LOOP17:![0-9]+]]
744 ; CHECK-NEXT: ret void
747 br label %loop.header
750 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
751 %iv.shl = shl nsw i64 %iv, 2
752 %gep.0 = getelementptr nusw double, ptr %A, i64 %iv.shl
753 %l = load double, ptr %gep.0, align 8
754 %c = fcmp oeq double %l, 0.000000e+00
755 br i1 %c, label %if.then, label %loop.latch
758 %gep.1 = getelementptr double, ptr %A, i64 %iv.shl
759 store double 0.000000e+00, ptr %gep.1, align 8
763 %iv.next = add nsw i64 %iv, 1
764 %ec = icmp eq i64 %iv, %N
765 br i1 %ec, label %exit, label %loop.header
771 define i64 @cost_assume(ptr %end, i64 %N) {
772 ; CHECK-LABEL: @cost_assume(
774 ; CHECK-NEXT: [[END1:%.*]] = ptrtoint ptr [[END:%.*]] to i64
775 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[END1]], -9
776 ; CHECK-NEXT: [[TMP1:%.*]] = udiv i64 [[TMP0]], 9
777 ; CHECK-NEXT: [[TMP2:%.*]] = add nuw nsw i64 [[TMP1]], 1
778 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP2]], 8
779 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
781 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 [[TMP2]], 8
782 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 [[TMP2]], [[N_MOD_VF]]
783 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <2 x i64> poison, i64 [[N:%.*]], i64 0
784 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i64> [[BROADCAST_SPLATINSERT]], <2 x i64> poison, <2 x i32> zeroinitializer
785 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
786 ; CHECK: vector.body:
787 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
788 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <2 x i64> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP3:%.*]], [[VECTOR_BODY]] ]
789 ; CHECK-NEXT: [[VEC_PHI2:%.*]] = phi <2 x i64> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP4:%.*]], [[VECTOR_BODY]] ]
790 ; CHECK-NEXT: [[VEC_PHI3:%.*]] = phi <2 x i64> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP5:%.*]], [[VECTOR_BODY]] ]
791 ; CHECK-NEXT: [[VEC_PHI4:%.*]] = phi <2 x i64> [ zeroinitializer, [[VECTOR_PH]] ], [ [[TMP6:%.*]], [[VECTOR_BODY]] ]
792 ; CHECK-NEXT: [[TMP3]] = add <2 x i64> [[VEC_PHI]], <i64 1, i64 1>
793 ; CHECK-NEXT: [[TMP4]] = add <2 x i64> [[VEC_PHI2]], <i64 1, i64 1>
794 ; CHECK-NEXT: [[TMP5]] = add <2 x i64> [[VEC_PHI3]], <i64 1, i64 1>
795 ; CHECK-NEXT: [[TMP6]] = add <2 x i64> [[VEC_PHI4]], <i64 1, i64 1>
796 ; CHECK-NEXT: [[TMP7:%.*]] = icmp ne <2 x i64> [[BROADCAST_SPLAT]], zeroinitializer
797 ; CHECK-NEXT: [[TMP8:%.*]] = icmp ne <2 x i64> [[BROADCAST_SPLAT]], zeroinitializer
798 ; CHECK-NEXT: [[TMP9:%.*]] = icmp ne <2 x i64> [[BROADCAST_SPLAT]], zeroinitializer
799 ; CHECK-NEXT: [[TMP10:%.*]] = icmp ne <2 x i64> [[BROADCAST_SPLAT]], zeroinitializer
800 ; CHECK-NEXT: [[TMP11:%.*]] = extractelement <2 x i1> [[TMP7]], i32 0
801 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP11]])
802 ; CHECK-NEXT: [[TMP12:%.*]] = extractelement <2 x i1> [[TMP7]], i32 1
803 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP12]])
804 ; CHECK-NEXT: [[TMP13:%.*]] = extractelement <2 x i1> [[TMP8]], i32 0
805 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP13]])
806 ; CHECK-NEXT: [[TMP14:%.*]] = extractelement <2 x i1> [[TMP8]], i32 1
807 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP14]])
808 ; CHECK-NEXT: [[TMP15:%.*]] = extractelement <2 x i1> [[TMP9]], i32 0
809 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP15]])
810 ; CHECK-NEXT: [[TMP16:%.*]] = extractelement <2 x i1> [[TMP9]], i32 1
811 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP16]])
812 ; CHECK-NEXT: [[TMP17:%.*]] = extractelement <2 x i1> [[TMP10]], i32 0
813 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP17]])
814 ; CHECK-NEXT: [[TMP18:%.*]] = extractelement <2 x i1> [[TMP10]], i32 1
815 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[TMP18]])
816 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 8
817 ; CHECK-NEXT: [[TMP19:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
818 ; CHECK-NEXT: br i1 [[TMP19]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP18:![0-9]+]]
819 ; CHECK: middle.block:
820 ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <2 x i64> [[TMP4]], [[TMP3]]
821 ; CHECK-NEXT: [[BIN_RDX5:%.*]] = add <2 x i64> [[TMP5]], [[BIN_RDX]]
822 ; CHECK-NEXT: [[BIN_RDX6:%.*]] = add <2 x i64> [[TMP6]], [[BIN_RDX5]]
823 ; CHECK-NEXT: [[TMP20:%.*]] = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> [[BIN_RDX6]])
824 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 [[TMP2]], [[N_VEC]]
825 ; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[SCALAR_PH]]
827 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY:%.*]] ]
828 ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i64 [ [[TMP20]], [[MIDDLE_BLOCK]] ], [ 0, [[ENTRY]] ]
829 ; CHECK-NEXT: br label [[LOOP:%.*]]
831 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
832 ; CHECK-NEXT: [[TMP21:%.*]] = phi i64 [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ], [ [[TMP22:%.*]], [[LOOP]] ]
833 ; CHECK-NEXT: [[TMP22]] = add i64 [[TMP21]], 1
834 ; CHECK-NEXT: [[IV_NEXT]] = add nsw i64 [[IV]], 1
835 ; CHECK-NEXT: [[C:%.*]] = icmp ne i64 [[N]], 0
836 ; CHECK-NEXT: tail call void @llvm.assume(i1 [[C]])
837 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr nusw [9 x i8], ptr null, i64 [[IV_NEXT]]
838 ; CHECK-NEXT: [[EC:%.*]] = icmp eq ptr [[GEP]], [[END]]
839 ; CHECK-NEXT: br i1 [[EC]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP19:![0-9]+]]
841 ; CHECK-NEXT: [[DOTLCSSA:%.*]] = phi i64 [ [[TMP22]], [[LOOP]] ], [ [[TMP20]], [[MIDDLE_BLOCK]] ]
842 ; CHECK-NEXT: ret i64 [[DOTLCSSA]]
848 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
849 %0 = phi i64 [ 0, %entry ], [ %1, %loop ]
851 %iv.next = add nsw i64 %iv, 1
852 %c = icmp ne i64 %N, 0
853 tail call void @llvm.assume(i1 %c)
854 %gep = getelementptr nusw [ 9 x i8 ], ptr null, i64 %iv.next
855 %ec = icmp eq ptr %gep, %end
856 br i1 %ec, label %exit, label %loop
862 declare void @llvm.assume(i1 noundef) #0
864 attributes #0 = { "target-cpu"="penryn" }
865 attributes #1 = { "target-features"="+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl" }
866 attributes #2 = { "target-cpu"="znver3" }