30#include "llvm/IR/IntrinsicsAArch64.h"
31#include "llvm/IR/IntrinsicsARM.h"
32#include "llvm/IR/IntrinsicsNVPTX.h"
33#include "llvm/IR/IntrinsicsRISCV.h"
34#include "llvm/IR/IntrinsicsWebAssembly.h"
35#include "llvm/IR/IntrinsicsX86.h"
50 cl::desc(
"Disable autoupgrade of debug info"));
60 Type *Arg0Type =
F->getFunctionType()->getParamType(0);
75 Type *LastArgType =
F->getFunctionType()->getParamType(
76 F->getFunctionType()->getNumParams() - 1);
91 if (
F->getReturnType()->isVectorTy())
101 if (
F->getReturnType()->getScalarType()->isBFloatTy())
111 if (
F->getFunctionType()->getParamType(1)->getScalarType()->isBFloatTy())
125 if (
Name ==
"addcarryx.u32" ||
126 Name ==
"addcarryx.u64" ||
127 Name ==
"addcarry.u32" ||
128 Name ==
"addcarry.u64" ||
129 Name ==
"subborrow.u32" ||
130 Name ==
"subborrow.u64" ||
131 Name.startswith(
"sse2.padds.") ||
132 Name.startswith(
"sse2.psubs.") ||
133 Name.startswith(
"sse2.paddus.") ||
134 Name.startswith(
"sse2.psubus.") ||
135 Name.startswith(
"avx2.padds.") ||
136 Name.startswith(
"avx2.psubs.") ||
137 Name.startswith(
"avx2.paddus.") ||
138 Name.startswith(
"avx2.psubus.") ||
139 Name.startswith(
"avx512.padds.") ||
140 Name.startswith(
"avx512.psubs.") ||
141 Name.startswith(
"avx512.mask.padds.") ||
142 Name.startswith(
"avx512.mask.psubs.") ||
143 Name.startswith(
"avx512.mask.paddus.") ||
144 Name.startswith(
"avx512.mask.psubus.") ||
145 Name==
"ssse3.pabs.b.128" ||
146 Name==
"ssse3.pabs.w.128" ||
147 Name==
"ssse3.pabs.d.128" ||
148 Name.startswith(
"fma4.vfmadd.s") ||
149 Name.startswith(
"fma.vfmadd.") ||
150 Name.startswith(
"fma.vfmsub.") ||
151 Name.startswith(
"fma.vfmsubadd.") ||
152 Name.startswith(
"fma.vfnmadd.") ||
153 Name.startswith(
"fma.vfnmsub.") ||
154 Name.startswith(
"avx512.mask.vfmadd.") ||
155 Name.startswith(
"avx512.mask.vfnmadd.") ||
156 Name.startswith(
"avx512.mask.vfnmsub.") ||
157 Name.startswith(
"avx512.mask3.vfmadd.") ||
158 Name.startswith(
"avx512.maskz.vfmadd.") ||
159 Name.startswith(
"avx512.mask3.vfmsub.") ||
160 Name.startswith(
"avx512.mask3.vfnmsub.") ||
161 Name.startswith(
"avx512.mask.vfmaddsub.") ||
162 Name.startswith(
"avx512.maskz.vfmaddsub.") ||
163 Name.startswith(
"avx512.mask3.vfmaddsub.") ||
164 Name.startswith(
"avx512.mask3.vfmsubadd.") ||
165 Name.startswith(
"avx512.mask.shuf.i") ||
166 Name.startswith(
"avx512.mask.shuf.f") ||
167 Name.startswith(
"avx512.kunpck") ||
168 Name.startswith(
"avx2.pabs.") ||
169 Name.startswith(
"avx512.mask.pabs.") ||
170 Name.startswith(
"avx512.broadcastm") ||
171 Name ==
"sse.sqrt.ss" ||
172 Name ==
"sse2.sqrt.sd" ||
173 Name.startswith(
"avx512.mask.sqrt.p") ||
174 Name.startswith(
"avx.sqrt.p") ||
175 Name.startswith(
"sse2.sqrt.p") ||
176 Name.startswith(
"sse.sqrt.p") ||
177 Name.startswith(
"avx512.mask.pbroadcast") ||
178 Name.startswith(
"sse2.pcmpeq.") ||
179 Name.startswith(
"sse2.pcmpgt.") ||
180 Name.startswith(
"avx2.pcmpeq.") ||
181 Name.startswith(
"avx2.pcmpgt.") ||
182 Name.startswith(
"avx512.mask.pcmpeq.") ||
183 Name.startswith(
"avx512.mask.pcmpgt.") ||
184 Name.startswith(
"avx.vperm2f128.") ||
185 Name ==
"avx2.vperm2i128" ||
186 Name ==
"sse.add.ss" ||
187 Name ==
"sse2.add.sd" ||
188 Name ==
"sse.sub.ss" ||
189 Name ==
"sse2.sub.sd" ||
190 Name ==
"sse.mul.ss" ||
191 Name ==
"sse2.mul.sd" ||
192 Name ==
"sse.div.ss" ||
193 Name ==
"sse2.div.sd" ||
194 Name ==
"sse41.pmaxsb" ||
195 Name ==
"sse2.pmaxs.w" ||
196 Name ==
"sse41.pmaxsd" ||
197 Name ==
"sse2.pmaxu.b" ||
198 Name ==
"sse41.pmaxuw" ||
199 Name ==
"sse41.pmaxud" ||
200 Name ==
"sse41.pminsb" ||
201 Name ==
"sse2.pmins.w" ||
202 Name ==
"sse41.pminsd" ||
203 Name ==
"sse2.pminu.b" ||
204 Name ==
"sse41.pminuw" ||
205 Name ==
"sse41.pminud" ||
206 Name ==
"avx512.kand.w" ||
207 Name ==
"avx512.kandn.w" ||
208 Name ==
"avx512.knot.w" ||
209 Name ==
"avx512.kor.w" ||
210 Name ==
"avx512.kxor.w" ||
211 Name ==
"avx512.kxnor.w" ||
212 Name ==
"avx512.kortestc.w" ||
213 Name ==
"avx512.kortestz.w" ||
214 Name.startswith(
"avx512.mask.pshuf.b.") ||
215 Name.startswith(
"avx2.pmax") ||
216 Name.startswith(
"avx2.pmin") ||
217 Name.startswith(
"avx512.mask.pmax") ||
218 Name.startswith(
"avx512.mask.pmin") ||
219 Name.startswith(
"avx2.vbroadcast") ||
220 Name.startswith(
"avx2.pbroadcast") ||
221 Name.startswith(
"avx.vpermil.") ||
222 Name.startswith(
"sse2.pshuf") ||
223 Name.startswith(
"avx512.pbroadcast") ||
224 Name.startswith(
"avx512.mask.broadcast.s") ||
225 Name.startswith(
"avx512.mask.movddup") ||
226 Name.startswith(
"avx512.mask.movshdup") ||
227 Name.startswith(
"avx512.mask.movsldup") ||
228 Name.startswith(
"avx512.mask.pshuf.d.") ||
229 Name.startswith(
"avx512.mask.pshufl.w.") ||
230 Name.startswith(
"avx512.mask.pshufh.w.") ||
231 Name.startswith(
"avx512.mask.shuf.p") ||
232 Name.startswith(
"avx512.mask.vpermil.p") ||
233 Name.startswith(
"avx512.mask.perm.df.") ||
234 Name.startswith(
"avx512.mask.perm.di.") ||
235 Name.startswith(
"avx512.mask.punpckl") ||
236 Name.startswith(
"avx512.mask.punpckh") ||
237 Name.startswith(
"avx512.mask.unpckl.") ||
238 Name.startswith(
"avx512.mask.unpckh.") ||
239 Name.startswith(
"avx512.mask.pand.") ||
240 Name.startswith(
"avx512.mask.pandn.") ||
241 Name.startswith(
"avx512.mask.por.") ||
242 Name.startswith(
"avx512.mask.pxor.") ||
243 Name.startswith(
"avx512.mask.and.") ||
244 Name.startswith(
"avx512.mask.andn.") ||
245 Name.startswith(
"avx512.mask.or.") ||
246 Name.startswith(
"avx512.mask.xor.") ||
247 Name.startswith(
"avx512.mask.padd.") ||
248 Name.startswith(
"avx512.mask.psub.") ||
249 Name.startswith(
"avx512.mask.pmull.") ||
250 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
251 Name.startswith(
"avx512.mask.cvtudq2pd.") ||
252 Name.startswith(
"avx512.mask.cvtudq2ps.") ||
253 Name.startswith(
"avx512.mask.cvtqq2pd.") ||
254 Name.startswith(
"avx512.mask.cvtuqq2pd.") ||
255 Name.startswith(
"avx512.mask.cvtdq2ps.") ||
256 Name ==
"avx512.mask.vcvtph2ps.128" ||
257 Name ==
"avx512.mask.vcvtph2ps.256" ||
258 Name ==
"avx512.mask.cvtqq2ps.256" ||
259 Name ==
"avx512.mask.cvtqq2ps.512" ||
260 Name ==
"avx512.mask.cvtuqq2ps.256" ||
261 Name ==
"avx512.mask.cvtuqq2ps.512" ||
262 Name ==
"avx512.mask.cvtpd2dq.256" ||
263 Name ==
"avx512.mask.cvtpd2ps.256" ||
264 Name ==
"avx512.mask.cvttpd2dq.256" ||
265 Name ==
"avx512.mask.cvttps2dq.128" ||
266 Name ==
"avx512.mask.cvttps2dq.256" ||
267 Name ==
"avx512.mask.cvtps2pd.128" ||
268 Name ==
"avx512.mask.cvtps2pd.256" ||
269 Name ==
"avx512.cvtusi2sd" ||
270 Name.startswith(
"avx512.mask.permvar.") ||
271 Name ==
"sse2.pmulu.dq" ||
272 Name ==
"sse41.pmuldq" ||
273 Name ==
"avx2.pmulu.dq" ||
274 Name ==
"avx2.pmul.dq" ||
275 Name ==
"avx512.pmulu.dq.512" ||
276 Name ==
"avx512.pmul.dq.512" ||
277 Name.startswith(
"avx512.mask.pmul.dq.") ||
278 Name.startswith(
"avx512.mask.pmulu.dq.") ||
279 Name.startswith(
"avx512.mask.pmul.hr.sw.") ||
280 Name.startswith(
"avx512.mask.pmulh.w.") ||
281 Name.startswith(
"avx512.mask.pmulhu.w.") ||
282 Name.startswith(
"avx512.mask.pmaddw.d.") ||
283 Name.startswith(
"avx512.mask.pmaddubs.w.") ||
284 Name.startswith(
"avx512.mask.packsswb.") ||
285 Name.startswith(
"avx512.mask.packssdw.") ||
286 Name.startswith(
"avx512.mask.packuswb.") ||
287 Name.startswith(
"avx512.mask.packusdw.") ||
288 Name.startswith(
"avx512.mask.cmp.b") ||
289 Name.startswith(
"avx512.mask.cmp.d") ||
290 Name.startswith(
"avx512.mask.cmp.q") ||
291 Name.startswith(
"avx512.mask.cmp.w") ||
292 Name.startswith(
"avx512.cmp.p") ||
293 Name.startswith(
"avx512.mask.ucmp.") ||
294 Name.startswith(
"avx512.cvtb2mask.") ||
295 Name.startswith(
"avx512.cvtw2mask.") ||
296 Name.startswith(
"avx512.cvtd2mask.") ||
297 Name.startswith(
"avx512.cvtq2mask.") ||
298 Name.startswith(
"avx512.mask.vpermilvar.") ||
299 Name.startswith(
"avx512.mask.psll.d") ||
300 Name.startswith(
"avx512.mask.psll.q") ||
301 Name.startswith(
"avx512.mask.psll.w") ||
302 Name.startswith(
"avx512.mask.psra.d") ||
303 Name.startswith(
"avx512.mask.psra.q") ||
304 Name.startswith(
"avx512.mask.psra.w") ||
305 Name.startswith(
"avx512.mask.psrl.d") ||
306 Name.startswith(
"avx512.mask.psrl.q") ||
307 Name.startswith(
"avx512.mask.psrl.w") ||
308 Name.startswith(
"avx512.mask.pslli") ||
309 Name.startswith(
"avx512.mask.psrai") ||
310 Name.startswith(
"avx512.mask.psrli") ||
311 Name.startswith(
"avx512.mask.psllv") ||
312 Name.startswith(
"avx512.mask.psrav") ||
313 Name.startswith(
"avx512.mask.psrlv") ||
314 Name.startswith(
"sse41.pmovsx") ||
315 Name.startswith(
"sse41.pmovzx") ||
316 Name.startswith(
"avx2.pmovsx") ||
317 Name.startswith(
"avx2.pmovzx") ||
318 Name.startswith(
"avx512.mask.pmovsx") ||
319 Name.startswith(
"avx512.mask.pmovzx") ||
320 Name.startswith(
"avx512.mask.lzcnt.") ||
321 Name.startswith(
"avx512.mask.pternlog.") ||
322 Name.startswith(
"avx512.maskz.pternlog.") ||
323 Name.startswith(
"avx512.mask.vpmadd52") ||
324 Name.startswith(
"avx512.maskz.vpmadd52") ||
325 Name.startswith(
"avx512.mask.vpermi2var.") ||
326 Name.startswith(
"avx512.mask.vpermt2var.") ||
327 Name.startswith(
"avx512.maskz.vpermt2var.") ||
328 Name.startswith(
"avx512.mask.vpdpbusd.") ||
329 Name.startswith(
"avx512.maskz.vpdpbusd.") ||
330 Name.startswith(
"avx512.mask.vpdpbusds.") ||
331 Name.startswith(
"avx512.maskz.vpdpbusds.") ||
332 Name.startswith(
"avx512.mask.vpdpwssd.") ||
333 Name.startswith(
"avx512.maskz.vpdpwssd.") ||
334 Name.startswith(
"avx512.mask.vpdpwssds.") ||
335 Name.startswith(
"avx512.maskz.vpdpwssds.") ||
336 Name.startswith(
"avx512.mask.dbpsadbw.") ||
337 Name.startswith(
"avx512.mask.vpshld.") ||
338 Name.startswith(
"avx512.mask.vpshrd.") ||
339 Name.startswith(
"avx512.mask.vpshldv.") ||
340 Name.startswith(
"avx512.mask.vpshrdv.") ||
341 Name.startswith(
"avx512.maskz.vpshldv.") ||
342 Name.startswith(
"avx512.maskz.vpshrdv.") ||
343 Name.startswith(
"avx512.vpshld.") ||
344 Name.startswith(
"avx512.vpshrd.") ||
345 Name.startswith(
"avx512.mask.add.p") ||
346 Name.startswith(
"avx512.mask.sub.p") ||
347 Name.startswith(
"avx512.mask.mul.p") ||
348 Name.startswith(
"avx512.mask.div.p") ||
349 Name.startswith(
"avx512.mask.max.p") ||
350 Name.startswith(
"avx512.mask.min.p") ||
351 Name.startswith(
"avx512.mask.fpclass.p") ||
352 Name.startswith(
"avx512.mask.vpshufbitqmb.") ||
353 Name.startswith(
"avx512.mask.pmultishift.qb.") ||
354 Name.startswith(
"avx512.mask.conflict.") ||
355 Name ==
"avx512.mask.pmov.qd.256" ||
356 Name ==
"avx512.mask.pmov.qd.512" ||
357 Name ==
"avx512.mask.pmov.wb.256" ||
358 Name ==
"avx512.mask.pmov.wb.512" ||
359 Name ==
"sse.cvtsi2ss" ||
360 Name ==
"sse.cvtsi642ss" ||
361 Name ==
"sse2.cvtsi2sd" ||
362 Name ==
"sse2.cvtsi642sd" ||
363 Name ==
"sse2.cvtss2sd" ||
364 Name ==
"sse2.cvtdq2pd" ||
365 Name ==
"sse2.cvtdq2ps" ||
366 Name ==
"sse2.cvtps2pd" ||
367 Name ==
"avx.cvtdq2.pd.256" ||
368 Name ==
"avx.cvtdq2.ps.256" ||
369 Name ==
"avx.cvt.ps2.pd.256" ||
370 Name.startswith(
"vcvtph2ps.") ||
371 Name.startswith(
"avx.vinsertf128.") ||
372 Name ==
"avx2.vinserti128" ||
373 Name.startswith(
"avx512.mask.insert") ||
374 Name.startswith(
"avx.vextractf128.") ||
375 Name ==
"avx2.vextracti128" ||
376 Name.startswith(
"avx512.mask.vextract") ||
377 Name.startswith(
"sse4a.movnt.") ||
378 Name.startswith(
"avx.movnt.") ||
379 Name.startswith(
"avx512.storent.") ||
380 Name ==
"sse41.movntdqa" ||
381 Name ==
"avx2.movntdqa" ||
382 Name ==
"avx512.movntdqa" ||
383 Name ==
"sse2.storel.dq" ||
384 Name.startswith(
"sse.storeu.") ||
385 Name.startswith(
"sse2.storeu.") ||
386 Name.startswith(
"avx.storeu.") ||
387 Name.startswith(
"avx512.mask.storeu.") ||
388 Name.startswith(
"avx512.mask.store.p") ||
389 Name.startswith(
"avx512.mask.store.b.") ||
390 Name.startswith(
"avx512.mask.store.w.") ||
391 Name.startswith(
"avx512.mask.store.d.") ||
392 Name.startswith(
"avx512.mask.store.q.") ||
393 Name ==
"avx512.mask.store.ss" ||
394 Name.startswith(
"avx512.mask.loadu.") ||
395 Name.startswith(
"avx512.mask.load.") ||
396 Name.startswith(
"avx512.mask.expand.load.") ||
397 Name.startswith(
"avx512.mask.compress.store.") ||
398 Name.startswith(
"avx512.mask.expand.b") ||
399 Name.startswith(
"avx512.mask.expand.w") ||
400 Name.startswith(
"avx512.mask.expand.d") ||
401 Name.startswith(
"avx512.mask.expand.q") ||
402 Name.startswith(
"avx512.mask.expand.p") ||
403 Name.startswith(
"avx512.mask.compress.b") ||
404 Name.startswith(
"avx512.mask.compress.w") ||
405 Name.startswith(
"avx512.mask.compress.d") ||
406 Name.startswith(
"avx512.mask.compress.q") ||
407 Name.startswith(
"avx512.mask.compress.p") ||
408 Name ==
"sse42.crc32.64.8" ||
409 Name.startswith(
"avx.vbroadcast.s") ||
410 Name.startswith(
"avx512.vbroadcast.s") ||
411 Name.startswith(
"avx512.mask.palignr.") ||
412 Name.startswith(
"avx512.mask.valign.") ||
413 Name.startswith(
"sse2.psll.dq") ||
414 Name.startswith(
"sse2.psrl.dq") ||
415 Name.startswith(
"avx2.psll.dq") ||
416 Name.startswith(
"avx2.psrl.dq") ||
417 Name.startswith(
"avx512.psll.dq") ||
418 Name.startswith(
"avx512.psrl.dq") ||
419 Name ==
"sse41.pblendw" ||
420 Name.startswith(
"sse41.blendp") ||
421 Name.startswith(
"avx.blend.p") ||
422 Name ==
"avx2.pblendw" ||
423 Name.startswith(
"avx2.pblendd.") ||
424 Name.startswith(
"avx.vbroadcastf128") ||
425 Name ==
"avx2.vbroadcasti128" ||
426 Name.startswith(
"avx512.mask.broadcastf32x4.") ||
427 Name.startswith(
"avx512.mask.broadcastf64x2.") ||
428 Name.startswith(
"avx512.mask.broadcastf32x8.") ||
429 Name.startswith(
"avx512.mask.broadcastf64x4.") ||
430 Name.startswith(
"avx512.mask.broadcasti32x4.") ||
431 Name.startswith(
"avx512.mask.broadcasti64x2.") ||
432 Name.startswith(
"avx512.mask.broadcasti32x8.") ||
433 Name.startswith(
"avx512.mask.broadcasti64x4.") ||
434 Name ==
"xop.vpcmov" ||
435 Name ==
"xop.vpcmov.256" ||
436 Name.startswith(
"avx512.mask.move.s") ||
437 Name.startswith(
"avx512.cvtmask2") ||
438 Name.startswith(
"xop.vpcom") ||
439 Name.startswith(
"xop.vprot") ||
440 Name.startswith(
"avx512.prol") ||
441 Name.startswith(
"avx512.pror") ||
442 Name.startswith(
"avx512.mask.prorv.") ||
443 Name.startswith(
"avx512.mask.pror.") ||
444 Name.startswith(
"avx512.mask.prolv.") ||
445 Name.startswith(
"avx512.mask.prol.") ||
446 Name.startswith(
"avx512.ptestm") ||
447 Name.startswith(
"avx512.ptestnm") ||
448 Name.startswith(
"avx512.mask.pavg"))
457 if (!
Name.startswith(
"x86."))
467 if (
Name ==
"rdtscp") {
469 if (
F->getFunctionType()->getNumParams() == 0)
474 Intrinsic::x86_rdtscp);
479 if (
Name.startswith(
"sse41.ptest")) {
480 if (
Name.substr(11) ==
"c")
482 if (
Name.substr(11) ==
"z")
484 if (
Name.substr(11) ==
"nzc")
489 if (
Name ==
"sse41.insertps")
492 if (
Name ==
"sse41.dppd")
495 if (
Name ==
"sse41.dpps")
498 if (
Name ==
"sse41.mpsadbw")
501 if (
Name ==
"avx.dp.ps.256")
504 if (
Name ==
"avx2.mpsadbw")
507 if (
Name ==
"avx512.mask.cmp.pd.128")
510 if (
Name ==
"avx512.mask.cmp.pd.256")
513 if (
Name ==
"avx512.mask.cmp.pd.512")
516 if (
Name ==
"avx512.mask.cmp.ps.128")
519 if (
Name ==
"avx512.mask.cmp.ps.256")
522 if (
Name ==
"avx512.mask.cmp.ps.512")
525 if (
Name ==
"avx512bf16.cvtne2ps2bf16.128")
527 F, Intrinsic::x86_avx512bf16_cvtne2ps2bf16_128, NewFn);
528 if (
Name ==
"avx512bf16.cvtne2ps2bf16.256")
530 F, Intrinsic::x86_avx512bf16_cvtne2ps2bf16_256, NewFn);
531 if (
Name ==
"avx512bf16.cvtne2ps2bf16.512")
533 F, Intrinsic::x86_avx512bf16_cvtne2ps2bf16_512, NewFn);
534 if (
Name ==
"avx512bf16.mask.cvtneps2bf16.128")
536 F, Intrinsic::x86_avx512bf16_mask_cvtneps2bf16_128, NewFn);
537 if (
Name ==
"avx512bf16.cvtneps2bf16.256")
539 F, Intrinsic::x86_avx512bf16_cvtneps2bf16_256, NewFn);
540 if (
Name ==
"avx512bf16.cvtneps2bf16.512")
542 F, Intrinsic::x86_avx512bf16_cvtneps2bf16_512, NewFn);
543 if (
Name ==
"avx512bf16.dpbf16ps.128")
545 F, Intrinsic::x86_avx512bf16_dpbf16ps_128, NewFn);
546 if (
Name ==
"avx512bf16.dpbf16ps.256")
548 F, Intrinsic::x86_avx512bf16_dpbf16ps_256, NewFn);
549 if (
Name ==
"avx512bf16.dpbf16ps.512")
551 F, Intrinsic::x86_avx512bf16_dpbf16ps_512, NewFn);
554 if (
Name.startswith(
"xop.vfrcz.ss") &&
F->arg_size() == 2) {
557 Intrinsic::x86_xop_vfrcz_ss);
560 if (
Name.startswith(
"xop.vfrcz.sd") &&
F->arg_size() == 2) {
563 Intrinsic::x86_xop_vfrcz_sd);
567 if (
Name.startswith(
"xop.vpermil2")) {
568 auto Idx =
F->getFunctionType()->getParamType(2);
569 if (
Idx->isFPOrFPVectorTy()) {
571 unsigned IdxSize =
Idx->getPrimitiveSizeInBits();
572 unsigned EltSize =
Idx->getScalarSizeInBits();
574 if (EltSize == 64 && IdxSize == 128)
575 Permil2ID = Intrinsic::x86_xop_vpermil2pd;
576 else if (EltSize == 32 && IdxSize == 128)
577 Permil2ID = Intrinsic::x86_xop_vpermil2ps;
578 else if (EltSize == 64 && IdxSize == 256)
579 Permil2ID = Intrinsic::x86_xop_vpermil2pd_256;
581 Permil2ID = Intrinsic::x86_xop_vpermil2ps_256;
587 if (
Name ==
"seh.recoverfp") {
596 if (
Name.consume_front(
"abs."))
598 .
Case(
"bf16", Intrinsic::nvvm_abs_bf16)
599 .
Case(
"bf16x2", Intrinsic::nvvm_abs_bf16x2)
602 if (
Name.consume_front(
"fma.rn."))
604 .
Case(
"bf16", Intrinsic::nvvm_fma_rn_bf16)
605 .
Case(
"bf16x2", Intrinsic::nvvm_fma_rn_bf16x2)
606 .
Case(
"ftz_bf16", Intrinsic::nvvm_fma_rn_ftz_bf16)
607 .
Case(
"ftz.bf16x2", Intrinsic::nvvm_fma_rn_ftz_bf16x2)
608 .
Case(
"ftz.relu.bf16", Intrinsic::nvvm_fma_rn_ftz_relu_bf16)
609 .
Case(
"ftz.relu.bf16x2", Intrinsic::nvvm_fma_rn_ftz_relu_bf16x2)
610 .
Case(
"ftz_sat.bf16", Intrinsic::nvvm_fma_rn_ftz_sat_bf16)
611 .
Case(
"ftz_sat.bf16x2", Intrinsic::nvvm_fma_rn_ftz_sat_bf16x2)
612 .
Case(
"relu.bf16", Intrinsic::nvvm_fma_rn_relu_bf16)
613 .
Case(
"relu.bf16x2", Intrinsic::nvvm_fma_rn_relu_bf16x2)
614 .
Case(
"sat.bf16", Intrinsic::nvvm_fma_rn_sat_bf16)
615 .
Case(
"sat.bf16x2", Intrinsic::nvvm_fma_rn_sat_bf16x2)
618 if (
Name.consume_front(
"fmax."))
620 .
Case(
"bf16", Intrinsic::nvvm_fmax_bf16)
621 .
Case(
"bf16x2", Intrinsic::nvvm_fmax_bf16x2)
622 .
Case(
"ftz.bf16", Intrinsic::nvvm_fmax_ftz_bf16)
623 .
Case(
"ftz.bf16x2", Intrinsic::nvvm_fmax_ftz_bf16x2)
624 .
Case(
"ftz.nan.bf16", Intrinsic::nvvm_fmax_ftz_nan_bf16)
625 .
Case(
"ftz.nan.bf16x2", Intrinsic::nvvm_fmax_ftz_nan_bf16x2)
626 .
Case(
"ftz.nan.xorsign.abs.bf16",
627 Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_bf16)
628 .
Case(
"ftz.nan.xorsign.abs.bf16x2",
629 Intrinsic::nvvm_fmax_ftz_nan_xorsign_abs_bf16x2)
630 .
Case(
"ftz.xorsign.abs.bf16", Intrinsic::nvvm_fmax_ftz_xorsign_abs_bf16)
631 .
Case(
"ftz.xorsign.abs.bf16x2",
632 Intrinsic::nvvm_fmax_ftz_xorsign_abs_bf16x2)
633 .
Case(
"nan.bf16", Intrinsic::nvvm_fmax_nan_bf16)
634 .
Case(
"nan.bf16x2", Intrinsic::nvvm_fmax_nan_bf16x2)
635 .
Case(
"nan.xorsign.abs.bf16", Intrinsic::nvvm_fmax_nan_xorsign_abs_bf16)
636 .
Case(
"nan.xorsign.abs.bf16x2",
637 Intrinsic::nvvm_fmax_nan_xorsign_abs_bf16x2)
638 .
Case(
"xorsign.abs.bf16", Intrinsic::nvvm_fmax_xorsign_abs_bf16)
639 .
Case(
"xorsign.abs.bf16x2", Intrinsic::nvvm_fmax_xorsign_abs_bf16x2)
642 if (
Name.consume_front(
"fmin."))
644 .
Case(
"bf16", Intrinsic::nvvm_fmin_bf16)
645 .
Case(
"bf16x2", Intrinsic::nvvm_fmin_bf16x2)
646 .
Case(
"ftz.bf16", Intrinsic::nvvm_fmin_ftz_bf16)
647 .
Case(
"ftz.bf16x2", Intrinsic::nvvm_fmin_ftz_bf16x2)
648 .
Case(
"ftz.nan_bf16", Intrinsic::nvvm_fmin_ftz_nan_bf16)
649 .
Case(
"ftz.nan_bf16x2", Intrinsic::nvvm_fmin_ftz_nan_bf16x2)
650 .
Case(
"ftz.nan.xorsign.abs.bf16",
651 Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_bf16)
652 .
Case(
"ftz.nan.xorsign.abs.bf16x2",
653 Intrinsic::nvvm_fmin_ftz_nan_xorsign_abs_bf16x2)
654 .
Case(
"ftz.xorsign.abs.bf16", Intrinsic::nvvm_fmin_ftz_xorsign_abs_bf16)
655 .
Case(
"ftz.xorsign.abs.bf16x2",
656 Intrinsic::nvvm_fmin_ftz_xorsign_abs_bf16x2)
657 .
Case(
"nan.bf16", Intrinsic::nvvm_fmin_nan_bf16)
658 .
Case(
"nan.bf16x2", Intrinsic::nvvm_fmin_nan_bf16x2)
659 .
Case(
"nan.xorsign.abs.bf16", Intrinsic::nvvm_fmin_nan_xorsign_abs_bf16)
660 .
Case(
"nan.xorsign.abs.bf16x2",
661 Intrinsic::nvvm_fmin_nan_xorsign_abs_bf16x2)
662 .
Case(
"xorsign.abs.bf16", Intrinsic::nvvm_fmin_xorsign_abs_bf16)
663 .
Case(
"xorsign.abs.bf16x2", Intrinsic::nvvm_fmin_xorsign_abs_bf16x2)
666 if (
Name.consume_front(
"neg."))
668 .
Case(
"bf16", Intrinsic::nvvm_neg_bf16)
669 .
Case(
"bf16x2", Intrinsic::nvvm_neg_bf16x2)
676 assert(
F &&
"Illegal to upgrade a non-existent Function.");
680 if (
Name.size() <= 7 || !
Name.startswith(
"llvm."))
687 if (
Name.startswith(
"arm.rbit") ||
Name.startswith(
"aarch64.rbit")) {
689 F->arg_begin()->getType());
692 if (
Name.startswith(
"aarch64.neon.frintn")) {
694 F->arg_begin()->getType());
697 if (
Name.startswith(
"aarch64.neon.rbit")) {
699 F->arg_begin()->getType());
702 if (
Name ==
"aarch64.sve.bfdot.lane") {
704 Intrinsic::aarch64_sve_bfdot_lane_v2);
707 if (
Name ==
"aarch64.sve.bfmlalb.lane") {
709 Intrinsic::aarch64_sve_bfmlalb_lane_v2);
712 if (
Name ==
"aarch64.sve.bfmlalt.lane") {
714 Intrinsic::aarch64_sve_bfmlalt_lane_v2);
717 static const Regex LdRegex(
"^aarch64\\.sve\\.ld[234](.nxv[a-z0-9]+|$)");
720 dyn_cast<VectorType>(
F->getReturnType())->getElementType();
722 dyn_cast<VectorType>(
F->arg_begin()->getType())->getElementCount();
723 Type *Ty = VectorType::get(ScalarTy, EC);
726 .
StartsWith(
"aarch64.sve.ld2", Intrinsic::aarch64_sve_ld2_sret)
727 .
StartsWith(
"aarch64.sve.ld3", Intrinsic::aarch64_sve_ld3_sret)
728 .
StartsWith(
"aarch64.sve.ld4", Intrinsic::aarch64_sve_ld4_sret)
733 if (
Name.startswith(
"aarch64.sve.tuple.get")) {
734 Type *Tys[] = {
F->getReturnType(),
F->arg_begin()->getType()};
736 Intrinsic::vector_extract, Tys);
739 if (
Name.startswith(
"aarch64.sve.tuple.set")) {
740 auto Args =
F->getFunctionType()->params();
741 Type *Tys[] = {Args[0], Args[2], Args[1]};
743 Intrinsic::vector_insert, Tys);
746 static const Regex CreateTupleRegex(
747 "^aarch64\\.sve\\.tuple\\.create[234](.nxv[a-z0-9]+|$)");
749 auto Args =
F->getFunctionType()->params();
750 Type *Tys[] = {
F->getReturnType(), Args[1]};
752 Intrinsic::vector_insert, Tys);
755 if (
Name.startswith(
"arm.neon.vclz")) {
757 F->arg_begin()->getType(),
765 "llvm.ctlz." +
Name.substr(14),
F->getParent());
768 if (
Name.startswith(
"arm.neon.vcnt")) {
770 F->arg_begin()->getType());
773 static const Regex vstRegex(
"^arm\\.neon\\.vst([1234]|[234]lane)\\.v[a-z0-9]*$");
775 static const Intrinsic::ID StoreInts[] = {Intrinsic::arm_neon_vst1,
776 Intrinsic::arm_neon_vst2,
777 Intrinsic::arm_neon_vst3,
778 Intrinsic::arm_neon_vst4};
781 Intrinsic::arm_neon_vst2lane, Intrinsic::arm_neon_vst3lane,
782 Intrinsic::arm_neon_vst4lane
785 auto fArgs =
F->getFunctionType()->params();
786 Type *Tys[] = {fArgs[0], fArgs[1]};
787 if (!
Name.contains(
"lane"))
789 StoreInts[fArgs.size() - 3], Tys);
792 StoreLaneInts[fArgs.size() - 5], Tys);
795 if (
Name ==
"aarch64.thread.pointer" ||
Name ==
"arm.thread.pointer") {
799 if (
Name.startswith(
"arm.neon.vqadds.")) {
801 F->arg_begin()->getType());
804 if (
Name.startswith(
"arm.neon.vqaddu.")) {
806 F->arg_begin()->getType());
809 if (
Name.startswith(
"arm.neon.vqsubs.")) {
811 F->arg_begin()->getType());
814 if (
Name.startswith(
"arm.neon.vqsubu.")) {
816 F->arg_begin()->getType());
819 if (
Name.startswith(
"aarch64.neon.addp")) {
820 if (
F->arg_size() != 2)
822 VectorType *Ty = dyn_cast<VectorType>(
F->getReturnType());
823 if (Ty && Ty->getElementType()->isFloatingPointTy()) {
825 Intrinsic::aarch64_neon_faddp, Ty);
832 if ((
Name.startswith(
"arm.neon.bfdot.") ||
833 Name.startswith(
"aarch64.neon.bfdot.")) &&
834 Name.endswith(
"i8")) {
837 .
Cases(
"arm.neon.bfdot.v2f32.v8i8",
838 "arm.neon.bfdot.v4f32.v16i8",
839 Intrinsic::arm_neon_bfdot)
840 .
Cases(
"aarch64.neon.bfdot.v2f32.v8i8",
841 "aarch64.neon.bfdot.v4f32.v16i8",
842 Intrinsic::aarch64_neon_bfdot)
847 size_t OperandWidth =
F->getReturnType()->getPrimitiveSizeInBits();
848 assert((OperandWidth == 64 || OperandWidth == 128) &&
849 "Unexpected operand width");
851 std::array<Type *, 2> Tys {{
861 if ((
Name.startswith(
"arm.neon.bfm") ||
862 Name.startswith(
"aarch64.neon.bfm")) &&
863 Name.endswith(
".v4f32.v16i8")) {
866 .
Case(
"arm.neon.bfmmla.v4f32.v16i8",
867 Intrinsic::arm_neon_bfmmla)
868 .
Case(
"arm.neon.bfmlalb.v4f32.v16i8",
869 Intrinsic::arm_neon_bfmlalb)
870 .
Case(
"arm.neon.bfmlalt.v4f32.v16i8",
871 Intrinsic::arm_neon_bfmlalt)
872 .
Case(
"aarch64.neon.bfmmla.v4f32.v16i8",
873 Intrinsic::aarch64_neon_bfmmla)
874 .
Case(
"aarch64.neon.bfmlalb.v4f32.v16i8",
875 Intrinsic::aarch64_neon_bfmlalb)
876 .
Case(
"aarch64.neon.bfmlalt.v4f32.v16i8",
877 Intrinsic::aarch64_neon_bfmlalt)
882 std::array<Type *, 0> Tys;
887 if (
Name ==
"arm.mve.vctp64" &&
888 cast<FixedVectorType>(
F->getReturnType())->getNumElements() == 4) {
895 if (
Name ==
"arm.mve.mull.int.predicated.v2i64.v4i32.v4i1" ||
896 Name ==
"arm.mve.vqdmull.predicated.v2i64.v4i32.v4i1" ||
897 Name ==
"arm.mve.vldr.gather.base.predicated.v2i64.v2i64.v4i1" ||
898 Name ==
"arm.mve.vldr.gather.base.wb.predicated.v2i64.v2i64.v4i1" ||
900 "arm.mve.vldr.gather.offset.predicated.v2i64.p0i64.v2i64.v4i1" ||
901 Name ==
"arm.mve.vldr.gather.offset.predicated.v2i64.p0.v2i64.v4i1" ||
902 Name ==
"arm.mve.vstr.scatter.base.predicated.v2i64.v2i64.v4i1" ||
903 Name ==
"arm.mve.vstr.scatter.base.wb.predicated.v2i64.v2i64.v4i1" ||
905 "arm.mve.vstr.scatter.offset.predicated.p0i64.v2i64.v2i64.v4i1" ||
906 Name ==
"arm.mve.vstr.scatter.offset.predicated.p0.v2i64.v2i64.v4i1" ||
907 Name ==
"arm.cde.vcx1q.predicated.v2i64.v4i1" ||
908 Name ==
"arm.cde.vcx1qa.predicated.v2i64.v4i1" ||
909 Name ==
"arm.cde.vcx2q.predicated.v2i64.v4i1" ||
910 Name ==
"arm.cde.vcx2qa.predicated.v2i64.v4i1" ||
911 Name ==
"arm.cde.vcx3q.predicated.v2i64.v4i1" ||
912 Name ==
"arm.cde.vcx3qa.predicated.v2i64.v4i1")
915 if (
Name.consume_front(
"amdgcn.")) {
916 if (
Name ==
"alignbit") {
919 {F->getReturnType()});
923 if (
Name.startswith(
"atomic.inc") ||
Name.startswith(
"atomic.dec")) {
930 if (
Name.startswith(
"ldexp.")) {
933 F->getParent(), Intrinsic::ldexp,
934 {F->getReturnType(), F->getArg(1)->getType()});
942 if (
Name.startswith(
"ctlz.") &&
F->arg_size() == 1) {
945 F->arg_begin()->getType());
948 if (
Name.startswith(
"cttz.") &&
F->arg_size() == 1) {
951 F->arg_begin()->getType());
954 if (
Name.equals(
"coro.end") &&
F->arg_size() == 2) {
963 if (
Name.consume_front(
"dbg.")) {
964 if (
Name ==
"addr" || (
Name ==
"value" &&
F->arg_size() == 4)) {
973 if (
Name.consume_front(
"experimental.vector.")) {
975 .
StartsWith(
"extract.", Intrinsic::vector_extract)
976 .
StartsWith(
"insert.", Intrinsic::vector_insert)
979 const auto *FT =
F->getFunctionType();
981 if (
ID == Intrinsic::vector_extract)
985 if (
ID == Intrinsic::vector_insert)
993 if (
Name.consume_front(
"reduce.")) {
995 static const Regex R(
"^([a-z]+)\\.[a-z][0-9]+");
998 .
Case(
"add", Intrinsic::vector_reduce_add)
999 .
Case(
"mul", Intrinsic::vector_reduce_mul)
1000 .
Case(
"and", Intrinsic::vector_reduce_and)
1001 .
Case(
"or", Intrinsic::vector_reduce_or)
1002 .
Case(
"xor", Intrinsic::vector_reduce_xor)
1003 .
Case(
"smax", Intrinsic::vector_reduce_smax)
1004 .
Case(
"smin", Intrinsic::vector_reduce_smin)
1005 .
Case(
"umax", Intrinsic::vector_reduce_umax)
1006 .
Case(
"umin", Intrinsic::vector_reduce_umin)
1007 .
Case(
"fmax", Intrinsic::vector_reduce_fmax)
1008 .
Case(
"fmin", Intrinsic::vector_reduce_fmin)
1013 static const Regex R2(
"^v2\\.([a-z]+)\\.[fi][0-9]+");
1018 .
Case(
"fadd", Intrinsic::vector_reduce_fadd)
1019 .
Case(
"fmul", Intrinsic::vector_reduce_fmul)
1024 auto Args =
F->getFunctionType()->params();
1035 if (
Name.startswith(
"flt.rounds")) {
1042 if (
Name.startswith(
"invariant.group.barrier")) {
1044 auto Args =
F->getFunctionType()->params();
1045 Type* ObjectPtr[1] = {Args[0]};
1048 Intrinsic::launder_invariant_group, ObjectPtr);
1057 .StartsWith(
"memcpy.", Intrinsic::memcpy)
1058 .StartsWith(
"memmove.", Intrinsic::memmove)
1060 if (
F->arg_size() == 5) {
1064 F->getFunctionType()->params().slice(0, 3);
1069 if (
Name.startswith(
"memset.") &&
F->arg_size() == 5) {
1072 const auto *FT =
F->getFunctionType();
1073 Type *ParamTypes[2] = {
1074 FT->getParamType(0),
1084 if (
Name.consume_front(
"nvvm.")) {
1086 if (
F->arg_size() == 1) {
1089 .
Cases(
"brev32",
"brev64", Intrinsic::bitreverse)
1090 .
Case(
"clz.i", Intrinsic::ctlz)
1091 .
Case(
"popc.i", Intrinsic::ctpop)
1095 {F->getReturnType()});
1101 if (!
F->getReturnType()->getScalarType()->isBFloatTy()) {
1113 bool Expand =
false;
1114 if (
Name.consume_front(
"abs."))
1116 Expand =
Name ==
"i" ||
Name ==
"ll";
1117 else if (
Name ==
"clz.ll" ||
Name ==
"popc.ll" ||
Name ==
"h2f")
1119 else if (
Name.consume_front(
"max.") ||
Name.consume_front(
"min."))
1122 else if (
Name.consume_front(
"atomic.load.add."))
1124 Expand =
Name.startswith(
"f32.p") ||
Name.startswith(
"f64.p");
1139 if (
Name.startswith(
"objectsize.")) {
1140 Type *Tys[2] = {
F->getReturnType(),
F->arg_begin()->getType() };
1141 if (
F->arg_size() == 2 ||
F->arg_size() == 3 ||
1153 if (
Name.startswith(
"ptr.annotation.") &&
F->arg_size() == 4) {
1156 F->getParent(), Intrinsic::ptr_annotation,
1157 {F->arg_begin()->getType(), F->getArg(1)->getType()});
1163 if (
Name.consume_front(
"riscv.")) {
1166 .
Case(
"aes32dsi", Intrinsic::riscv_aes32dsi)
1167 .
Case(
"aes32dsmi", Intrinsic::riscv_aes32dsmi)
1168 .
Case(
"aes32esi", Intrinsic::riscv_aes32esi)
1169 .
Case(
"aes32esmi", Intrinsic::riscv_aes32esmi)
1172 if (!
F->getFunctionType()->getParamType(2)->isIntegerTy(32)) {
1185 if (!
F->getFunctionType()->getParamType(2)->isIntegerTy(32) ||
1186 F->getFunctionType()->getReturnType()->isIntegerTy(64)) {
1195 .
StartsWith(
"sha256sig0", Intrinsic::riscv_sha256sig0)
1196 .
StartsWith(
"sha256sig1", Intrinsic::riscv_sha256sig1)
1197 .
StartsWith(
"sha256sum0", Intrinsic::riscv_sha256sum0)
1198 .
StartsWith(
"sha256sum1", Intrinsic::riscv_sha256sum1)
1203 if (
F->getFunctionType()->getReturnType()->isIntegerTy(64)) {
1215 if (
Name ==
"stackprotectorcheck") {
1222 if (
Name ==
"var.annotation" &&
F->arg_size() == 4) {
1225 F->getParent(), Intrinsic::var_annotation,
1226 {{F->arg_begin()->getType(), F->getArg(1)->getType()}});
1233 if (
Name.consume_front(
"wasm.")) {
1236 .
StartsWith(
"fma.", Intrinsic::wasm_relaxed_madd)
1237 .
StartsWith(
"fms.", Intrinsic::wasm_relaxed_nmadd)
1238 .
StartsWith(
"laneselect.", Intrinsic::wasm_relaxed_laneselect)
1247 if (
Name.consume_front(
"dot.i8x16.i7x16.")) {
1249 .
Case(
"signed", Intrinsic::wasm_relaxed_dot_i8x16_i7x16_signed)
1251 Intrinsic::wasm_relaxed_dot_i8x16_i7x16_add_signed)
1269 auto *
ST = dyn_cast<StructType>(
F->getReturnType());
1270 if (ST && (!
ST->isLiteral() ||
ST->isPacked())) {
1278 auto *FT =
F->getFunctionType();
1280 auto *NewFT = FunctionType::get(NewST, FT->params(), FT->isVarArg());
1281 std::string
Name =
F->getName().str();
1284 Name,
F->getParent());
1295 if (Result != std::nullopt) {
1310 assert(
F != NewFn &&
"Intrinsic function upgraded to the same function");
1322 GV->
getName() ==
"llvm.global_dtors")) ||
1337 unsigned N =
Init->getNumOperands();
1338 std::vector<Constant *> NewCtors(
N);
1339 for (
unsigned i = 0; i !=
N; ++i) {
1340 auto Ctor = cast<Constant>(
Init->getOperand(i));
1342 Ctor->getAggregateElement(1),
1355 auto *ResultTy = cast<FixedVectorType>(
Op->getType());
1356 unsigned NumElts = ResultTy->getNumElements() * 8;
1370 for (
unsigned l = 0; l != NumElts; l += 16)
1371 for (
unsigned i = 0; i != 16; ++i) {
1372 unsigned Idx = NumElts + i - Shift;
1374 Idx -= NumElts - 16;
1375 Idxs[l + i] =
Idx + l;
1382 return Builder.CreateBitCast(Res, ResultTy,
"cast");
1389 auto *ResultTy = cast<FixedVectorType>(
Op->getType());
1390 unsigned NumElts = ResultTy->getNumElements() * 8;
1404 for (
unsigned l = 0; l != NumElts; l += 16)
1405 for (
unsigned i = 0; i != 16; ++i) {
1406 unsigned Idx = i + Shift;
1408 Idx += NumElts - 16;
1409 Idxs[l + i] =
Idx + l;
1416 return Builder.CreateBitCast(Res, ResultTy,
"cast");
1423 Builder.getInt1Ty(), cast<IntegerType>(Mask->getType())->getBitWidth());
1424 Mask =
Builder.CreateBitCast(Mask, MaskTy);
1430 for (
unsigned i = 0; i != NumElts; ++i)
1432 Mask =
Builder.CreateShuffleVector(Mask, Mask,
ArrayRef(Indices, NumElts),
1442 if (
const auto *
C = dyn_cast<Constant>(Mask))
1443 if (
C->isAllOnesValue())
1447 cast<FixedVectorType>(Op0->
getType())->getNumElements());
1448 return Builder.CreateSelect(Mask, Op0, Op1);
1454 if (
const auto *
C = dyn_cast<Constant>(Mask))
1455 if (
C->isAllOnesValue())
1459 Mask->getType()->getIntegerBitWidth());
1460 Mask =
Builder.CreateBitCast(Mask, MaskTy);
1462 return Builder.CreateSelect(Mask, Op0, Op1);
1472 unsigned ShiftVal = cast<llvm::ConstantInt>(Shift)->getZExtValue();
1474 unsigned NumElts = cast<FixedVectorType>(Op0->
getType())->getNumElements();
1475 assert((IsVALIGN || NumElts % 16 == 0) &&
"Illegal NumElts for PALIGNR!");
1476 assert((!IsVALIGN || NumElts <= 16) &&
"NumElts too large for VALIGN!");
1481 ShiftVal &= (NumElts - 1);
1490 if (ShiftVal > 16) {
1498 for (
unsigned l = 0; l < NumElts; l += 16) {
1499 for (
unsigned i = 0; i != 16; ++i) {
1500 unsigned Idx = ShiftVal + i;
1501 if (!IsVALIGN &&
Idx >= 16)
1502 Idx += NumElts - 16;
1503 Indices[l + i] =
Idx + l;
1508 Op1, Op0,
ArrayRef(Indices, NumElts),
"palignr");
1514 bool ZeroMask,
bool IndexForm) {
1520 if (VecWidth == 128 && EltWidth == 32 && IsFloat)
1521 IID = Intrinsic::x86_avx512_vpermi2var_ps_128;
1522 else if (VecWidth == 128 && EltWidth == 32 && !IsFloat)
1523 IID = Intrinsic::x86_avx512_vpermi2var_d_128;
1524 else if (VecWidth == 128 && EltWidth == 64 && IsFloat)
1525 IID = Intrinsic::x86_avx512_vpermi2var_pd_128;
1526 else if (VecWidth == 128 && EltWidth == 64 && !IsFloat)
1527 IID = Intrinsic::x86_avx512_vpermi2var_q_128;
1528 else if (VecWidth == 256 && EltWidth == 32 && IsFloat)
1529 IID = Intrinsic::x86_avx512_vpermi2var_ps_256;
1530 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
1531 IID = Intrinsic::x86_avx512_vpermi2var_d_256;
1532 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
1533 IID = Intrinsic::x86_avx512_vpermi2var_pd_256;
1534 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
1535 IID = Intrinsic::x86_avx512_vpermi2var_q_256;
1536 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
1537 IID = Intrinsic::x86_avx512_vpermi2var_ps_512;
1538 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
1539 IID = Intrinsic::x86_avx512_vpermi2var_d_512;
1540 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
1541 IID = Intrinsic::x86_avx512_vpermi2var_pd_512;
1542 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
1543 IID = Intrinsic::x86_avx512_vpermi2var_q_512;
1544 else if (VecWidth == 128 && EltWidth == 16)
1545 IID = Intrinsic::x86_avx512_vpermi2var_hi_128;
1546 else if (VecWidth == 256 && EltWidth == 16)
1547 IID = Intrinsic::x86_avx512_vpermi2var_hi_256;
1548 else if (VecWidth == 512 && EltWidth == 16)
1549 IID = Intrinsic::x86_avx512_vpermi2var_hi_512;
1550 else if (VecWidth == 128 && EltWidth == 8)
1551 IID = Intrinsic::x86_avx512_vpermi2var_qi_128;
1552 else if (VecWidth == 256 && EltWidth == 8)
1553 IID = Intrinsic::x86_avx512_vpermi2var_qi_256;
1554 else if (VecWidth == 512 && EltWidth == 8)
1555 IID = Intrinsic::x86_avx512_vpermi2var_qi_512;
1591 bool IsRotateRight) {
1600 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
1602 Amt =
Builder.CreateVectorSplat(NumElts, Amt);
1605 Intrinsic::ID IID = IsRotateRight ? Intrinsic::fshr : Intrinsic::fshl;
1607 Value *Res =
Builder.CreateCall(Intrin, {Src, Src, Amt});
1626 Pred = IsSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
1629 Pred = IsSigned ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
1632 Pred = IsSigned ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
1635 Pred = IsSigned ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE;
1638 Pred = ICmpInst::ICMP_EQ;
1641 Pred = ICmpInst::ICMP_NE;
1657 bool IsShiftRight,
bool ZeroMask) {
1670 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
1672 Amt =
Builder.CreateVectorSplat(NumElts, Amt);
1675 Intrinsic::ID IID = IsShiftRight ? Intrinsic::fshr : Intrinsic::fshl;
1677 Value *Res =
Builder.CreateCall(Intrin, {Op0, Op1, Amt});
1696 const Align Alignment =
1698 ?
Align(
Data->getType()->getPrimitiveSizeInBits().getFixedValue() / 8)
1702 if (
const auto *
C = dyn_cast<Constant>(Mask))
1703 if (
C->isAllOnesValue())
1707 unsigned NumElts = cast<FixedVectorType>(
Data->getType())->getNumElements();
1718 const Align Alignment =
1726 if (
const auto *
C = dyn_cast<Constant>(Mask))
1727 if (
C->isAllOnesValue())
1728 return Builder.CreateAlignedLoad(ValTy,
Ptr, Alignment);
1731 unsigned NumElts = cast<FixedVectorType>(ValTy)->getNumElements();
1733 return Builder.CreateMaskedLoad(ValTy,
Ptr, Alignment, Mask, Passthru);
1778 unsigned NumElts = cast<FixedVectorType>(Vec->
getType())->getNumElements();
1780 const auto *
C = dyn_cast<Constant>(Mask);
1781 if (!
C || !
C->isAllOnesValue())
1787 for (
unsigned i = 0; i != NumElts; ++i)
1789 for (
unsigned i = NumElts; i != 8; ++i)
1790 Indices[i] = NumElts + i % NumElts;
1791 Vec =
Builder.CreateShuffleVector(Vec,
1795 return Builder.CreateBitCast(Vec,
Builder.getIntNTy(std::max(NumElts, 8U)));
1801 unsigned NumElts = cast<FixedVectorType>(Op0->
getType())->getNumElements();
1807 }
else if (
CC == 7) {
1814 case 0: Pred = ICmpInst::ICMP_EQ;
break;
1815 case 1: Pred =
Signed ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT;
break;
1816 case 2: Pred =
Signed ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE;
break;
1817 case 4: Pred = ICmpInst::ICMP_NE;
break;
1818 case 5: Pred =
Signed ? ICmpInst::ICMP_SGE : ICmpInst::ICMP_UGE;
break;
1819 case 6: Pred =
Signed ? ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
break;
1856 unsigned NumElts = cast<FixedVectorType>(CI.
getType())->getNumElements();
1858 return Builder.CreateSExt(Mask, ReturnOp,
"vpmovm2");
1869 if (
Name.startswith(
"max.p")) {
1870 if (VecWidth == 128 && EltWidth == 32)
1871 IID = Intrinsic::x86_sse_max_ps;
1872 else if (VecWidth == 128 && EltWidth == 64)
1873 IID = Intrinsic::x86_sse2_max_pd;
1874 else if (VecWidth == 256 && EltWidth == 32)
1875 IID = Intrinsic::x86_avx_max_ps_256;
1876 else if (VecWidth == 256 && EltWidth == 64)
1877 IID = Intrinsic::x86_avx_max_pd_256;
1880 }
else if (
Name.startswith(
"min.p")) {
1881 if (VecWidth == 128 && EltWidth == 32)
1882 IID = Intrinsic::x86_sse_min_ps;
1883 else if (VecWidth == 128 && EltWidth == 64)
1884 IID = Intrinsic::x86_sse2_min_pd;
1885 else if (VecWidth == 256 && EltWidth == 32)
1886 IID = Intrinsic::x86_avx_min_ps_256;
1887 else if (VecWidth == 256 && EltWidth == 64)
1888 IID = Intrinsic::x86_avx_min_pd_256;
1891 }
else if (
Name.startswith(
"pshuf.b.")) {
1892 if (VecWidth == 128)
1893 IID = Intrinsic::x86_ssse3_pshuf_b_128;
1894 else if (VecWidth == 256)
1895 IID = Intrinsic::x86_avx2_pshuf_b;
1896 else if (VecWidth == 512)
1897 IID = Intrinsic::x86_avx512_pshuf_b_512;
1900 }
else if (
Name.startswith(
"pmul.hr.sw.")) {
1901 if (VecWidth == 128)
1902 IID = Intrinsic::x86_ssse3_pmul_hr_sw_128;
1903 else if (VecWidth == 256)
1904 IID = Intrinsic::x86_avx2_pmul_hr_sw;
1905 else if (VecWidth == 512)
1906 IID = Intrinsic::x86_avx512_pmul_hr_sw_512;
1909 }
else if (
Name.startswith(
"pmulh.w.")) {
1910 if (VecWidth == 128)
1911 IID = Intrinsic::x86_sse2_pmulh_w;
1912 else if (VecWidth == 256)
1913 IID = Intrinsic::x86_avx2_pmulh_w;
1914 else if (VecWidth == 512)
1915 IID = Intrinsic::x86_avx512_pmulh_w_512;
1918 }
else if (
Name.startswith(
"pmulhu.w.")) {
1919 if (VecWidth == 128)
1920 IID = Intrinsic::x86_sse2_pmulhu_w;
1921 else if (VecWidth == 256)
1922 IID = Intrinsic::x86_avx2_pmulhu_w;
1923 else if (VecWidth == 512)
1924 IID = Intrinsic::x86_avx512_pmulhu_w_512;
1927 }
else if (
Name.startswith(
"pmaddw.d.")) {
1928 if (VecWidth == 128)
1929 IID = Intrinsic::x86_sse2_pmadd_wd;
1930 else if (VecWidth == 256)
1931 IID = Intrinsic::x86_avx2_pmadd_wd;
1932 else if (VecWidth == 512)
1933 IID = Intrinsic::x86_avx512_pmaddw_d_512;
1936 }
else if (
Name.startswith(
"pmaddubs.w.")) {
1937 if (VecWidth == 128)
1938 IID = Intrinsic::x86_ssse3_pmadd_ub_sw_128;
1939 else if (VecWidth == 256)
1940 IID = Intrinsic::x86_avx2_pmadd_ub_sw;
1941 else if (VecWidth == 512)
1942 IID = Intrinsic::x86_avx512_pmaddubs_w_512;
1945 }
else if (
Name.startswith(
"packsswb.")) {
1946 if (VecWidth == 128)
1947 IID = Intrinsic::x86_sse2_packsswb_128;
1948 else if (VecWidth == 256)
1949 IID = Intrinsic::x86_avx2_packsswb;
1950 else if (VecWidth == 512)
1951 IID = Intrinsic::x86_avx512_packsswb_512;
1954 }
else if (
Name.startswith(
"packssdw.")) {
1955 if (VecWidth == 128)
1956 IID = Intrinsic::x86_sse2_packssdw_128;
1957 else if (VecWidth == 256)
1958 IID = Intrinsic::x86_avx2_packssdw;
1959 else if (VecWidth == 512)
1960 IID = Intrinsic::x86_avx512_packssdw_512;
1963 }
else if (
Name.startswith(
"packuswb.")) {
1964 if (VecWidth == 128)
1965 IID = Intrinsic::x86_sse2_packuswb_128;
1966 else if (VecWidth == 256)
1967 IID = Intrinsic::x86_avx2_packuswb;
1968 else if (VecWidth == 512)
1969 IID = Intrinsic::x86_avx512_packuswb_512;
1972 }
else if (
Name.startswith(
"packusdw.")) {
1973 if (VecWidth == 128)
1974 IID = Intrinsic::x86_sse41_packusdw;
1975 else if (VecWidth == 256)
1976 IID = Intrinsic::x86_avx2_packusdw;
1977 else if (VecWidth == 512)
1978 IID = Intrinsic::x86_avx512_packusdw_512;
1981 }
else if (
Name.startswith(
"vpermilvar.")) {
1982 if (VecWidth == 128 && EltWidth == 32)
1983 IID = Intrinsic::x86_avx_vpermilvar_ps;
1984 else if (VecWidth == 128 && EltWidth == 64)
1985 IID = Intrinsic::x86_avx_vpermilvar_pd;
1986 else if (VecWidth == 256 && EltWidth == 32)
1987 IID = Intrinsic::x86_avx_vpermilvar_ps_256;
1988 else if (VecWidth == 256 && EltWidth == 64)
1989 IID = Intrinsic::x86_avx_vpermilvar_pd_256;
1990 else if (VecWidth == 512 && EltWidth == 32)
1991 IID = Intrinsic::x86_avx512_vpermilvar_ps_512;
1992 else if (VecWidth == 512 && EltWidth == 64)
1993 IID = Intrinsic::x86_avx512_vpermilvar_pd_512;
1996 }
else if (
Name ==
"cvtpd2dq.256") {
1997 IID = Intrinsic::x86_avx_cvt_pd2dq_256;
1998 }
else if (
Name ==
"cvtpd2ps.256") {
1999 IID = Intrinsic::x86_avx_cvt_pd2_ps_256;
2000 }
else if (
Name ==
"cvttpd2dq.256") {
2001 IID = Intrinsic::x86_avx_cvtt_pd2dq_256;
2002 }
else if (
Name ==
"cvttps2dq.128") {
2003 IID = Intrinsic::x86_sse2_cvttps2dq;
2004 }
else if (
Name ==
"cvttps2dq.256") {
2005 IID = Intrinsic::x86_avx_cvtt_ps2dq_256;
2006 }
else if (
Name.startswith(
"permvar.")) {
2008 if (VecWidth == 256 && EltWidth == 32 && IsFloat)
2009 IID = Intrinsic::x86_avx2_permps;
2010 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
2011 IID = Intrinsic::x86_avx2_permd;
2012 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
2013 IID = Intrinsic::x86_avx512_permvar_df_256;
2014 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
2015 IID = Intrinsic::x86_avx512_permvar_di_256;
2016 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
2017 IID = Intrinsic::x86_avx512_permvar_sf_512;
2018 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
2019 IID = Intrinsic::x86_avx512_permvar_si_512;
2020 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
2021 IID = Intrinsic::x86_avx512_permvar_df_512;
2022 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
2023 IID = Intrinsic::x86_avx512_permvar_di_512;
2024 else if (VecWidth == 128 && EltWidth == 16)
2025 IID = Intrinsic::x86_avx512_permvar_hi_128;
2026 else if (VecWidth == 256 && EltWidth == 16)
2027 IID = Intrinsic::x86_avx512_permvar_hi_256;
2028 else if (VecWidth == 512 && EltWidth == 16)
2029 IID = Intrinsic::x86_avx512_permvar_hi_512;
2030 else if (VecWidth == 128 && EltWidth == 8)
2031 IID = Intrinsic::x86_avx512_permvar_qi_128;
2032 else if (VecWidth == 256 && EltWidth == 8)
2033 IID = Intrinsic::x86_avx512_permvar_qi_256;
2034 else if (VecWidth == 512 && EltWidth == 8)
2035 IID = Intrinsic::x86_avx512_permvar_qi_512;
2038 }
else if (
Name.startswith(
"dbpsadbw.")) {
2039 if (VecWidth == 128)
2040 IID = Intrinsic::x86_avx512_dbpsadbw_128;
2041 else if (VecWidth == 256)
2042 IID = Intrinsic::x86_avx512_dbpsadbw_256;
2043 else if (VecWidth == 512)
2044 IID = Intrinsic::x86_avx512_dbpsadbw_512;
2047 }
else if (
Name.startswith(
"pmultishift.qb.")) {
2048 if (VecWidth == 128)
2049 IID = Intrinsic::x86_avx512_pmultishift_qb_128;
2050 else if (VecWidth == 256)
2051 IID = Intrinsic::x86_avx512_pmultishift_qb_256;
2052 else if (VecWidth == 512)
2053 IID = Intrinsic::x86_avx512_pmultishift_qb_512;
2056 }
else if (
Name.startswith(
"conflict.")) {
2057 if (
Name[9] ==
'd' && VecWidth == 128)
2058 IID = Intrinsic::x86_avx512_conflict_d_128;
2059 else if (
Name[9] ==
'd' && VecWidth == 256)
2060 IID = Intrinsic::x86_avx512_conflict_d_256;
2061 else if (
Name[9] ==
'd' && VecWidth == 512)
2062 IID = Intrinsic::x86_avx512_conflict_d_512;
2063 else if (
Name[9] ==
'q' && VecWidth == 128)
2064 IID = Intrinsic::x86_avx512_conflict_q_128;
2065 else if (
Name[9] ==
'q' && VecWidth == 256)
2066 IID = Intrinsic::x86_avx512_conflict_q_256;
2067 else if (
Name[9] ==
'q' && VecWidth == 512)
2068 IID = Intrinsic::x86_avx512_conflict_q_512;
2071 }
else if (
Name.startswith(
"pavg.")) {
2072 if (
Name[5] ==
'b' && VecWidth == 128)
2073 IID = Intrinsic::x86_sse2_pavg_b;
2074 else if (
Name[5] ==
'b' && VecWidth == 256)
2075 IID = Intrinsic::x86_avx2_pavg_b;
2076 else if (
Name[5] ==
'b' && VecWidth == 512)
2077 IID = Intrinsic::x86_avx512_pavg_b_512;
2078 else if (
Name[5] ==
'w' && VecWidth == 128)
2079 IID = Intrinsic::x86_sse2_pavg_w;
2080 else if (
Name[5] ==
'w' && VecWidth == 256)
2081 IID = Intrinsic::x86_avx2_pavg_w;
2082 else if (
Name[5] ==
'w' && VecWidth == 512)
2083 IID = Intrinsic::x86_avx512_pavg_w_512;
2104 if (AsmStr->find(
"mov\tfp") == 0 &&
2105 AsmStr->find(
"objc_retainAutoreleaseReturnValue") != std::string::npos &&
2106 (Pos = AsmStr->find(
"# marker")) != std::string::npos) {
2107 AsmStr->replace(Pos, 1,
";");
2113 if (
Name ==
"mve.vctp64.old") {
2121 F->getParent(), Intrinsic::arm_mve_pred_v2i,
2122 {VectorType::get(Builder.getInt1Ty(), 2, false)}),
2126 F->getParent(), Intrinsic::arm_mve_pred_i2v,
2127 {VectorType::get(Builder.getInt1Ty(), 4, false)}),
2129 }
else if (
Name ==
"mve.mull.int.predicated.v2i64.v4i32.v4i1" ||
2130 Name ==
"mve.vqdmull.predicated.v2i64.v4i32.v4i1" ||
2131 Name ==
"mve.vldr.gather.base.predicated.v2i64.v2i64.v4i1" ||
2132 Name ==
"mve.vldr.gather.base.wb.predicated.v2i64.v2i64.v4i1" ||
2134 "mve.vldr.gather.offset.predicated.v2i64.p0i64.v2i64.v4i1" ||
2135 Name ==
"mve.vldr.gather.offset.predicated.v2i64.p0.v2i64.v4i1" ||
2136 Name ==
"mve.vstr.scatter.base.predicated.v2i64.v2i64.v4i1" ||
2137 Name ==
"mve.vstr.scatter.base.wb.predicated.v2i64.v2i64.v4i1" ||
2139 "mve.vstr.scatter.offset.predicated.p0i64.v2i64.v2i64.v4i1" ||
2140 Name ==
"mve.vstr.scatter.offset.predicated.p0.v2i64.v2i64.v4i1" ||
2141 Name ==
"cde.vcx1q.predicated.v2i64.v4i1" ||
2142 Name ==
"cde.vcx1qa.predicated.v2i64.v4i1" ||
2143 Name ==
"cde.vcx2q.predicated.v2i64.v4i1" ||
2144 Name ==
"cde.vcx2qa.predicated.v2i64.v4i1" ||
2145 Name ==
"cde.vcx3q.predicated.v2i64.v4i1" ||
2146 Name ==
"cde.vcx3qa.predicated.v2i64.v4i1") {
2147 std::vector<Type *> Tys;
2151 case Intrinsic::arm_mve_mull_int_predicated:
2152 case Intrinsic::arm_mve_vqdmull_predicated:
2153 case Intrinsic::arm_mve_vldr_gather_base_predicated:
2156 case Intrinsic::arm_mve_vldr_gather_base_wb_predicated:
2157 case Intrinsic::arm_mve_vstr_scatter_base_predicated:
2158 case Intrinsic::arm_mve_vstr_scatter_base_wb_predicated:
2162 case Intrinsic::arm_mve_vldr_gather_offset_predicated:
2166 case Intrinsic::arm_mve_vstr_scatter_offset_predicated:
2170 case Intrinsic::arm_cde_vcx1q_predicated:
2171 case Intrinsic::arm_cde_vcx1qa_predicated:
2172 case Intrinsic::arm_cde_vcx2q_predicated:
2173 case Intrinsic::arm_cde_vcx2qa_predicated:
2174 case Intrinsic::arm_cde_vcx3q_predicated:
2175 case Intrinsic::arm_cde_vcx3qa_predicated:
2182 std::vector<Value *> Ops;
2184 Type *Ty =
Op->getType();
2188 F->getParent(), Intrinsic::arm_mve_pred_v2i,
2189 {VectorType::get(Builder.getInt1Ty(), 4, false)}),
2193 Intrinsic::arm_mve_pred_i2v, {V2I1Ty}),
2207 const bool IsInc =
Name.startswith(
"atomic.inc.");
2208 if (IsInc ||
Name.startswith(
"atomic.dec.")) {
2223 if (Order == AtomicOrdering::NotAtomic ||
2224 Order == AtomicOrdering::Unordered)
2225 Order = AtomicOrdering::SequentiallyConsistent;
2229 SyncScope::ID SSID =
F->getContext().getOrInsertSyncScopeID(
"agent");
2231 Builder.CreateAtomicRMW(RMWOp,
Ptr, Val, std::nullopt, Order, SSID);
2233 if (!VolatileArg || !VolatileArg->
isZero())
2259 assert(
Name.startswith(
"llvm.") &&
"Intrinsic doesn't start with 'llvm.'");
2262 bool IsX86 =
Name.startswith(
"x86.");
2265 bool IsNVVM =
Name.startswith(
"nvvm.");
2268 bool IsARM =
Name.startswith(
"arm.");
2271 bool IsAMDGCN =
Name.startswith(
"amdgcn.");
2275 if (IsX86 &&
Name.startswith(
"sse4a.movnt.")) {
2286 Type *SrcEltTy = cast<VectorType>(Arg1->
getType())->getElementType();
2287 PointerType *EltPtrTy = PointerType::getUnqual(SrcEltTy);
2293 SI->setMetadata(LLVMContext::MD_nontemporal, Node);
2300 if (IsX86 && (
Name.startswith(
"avx.movnt.") ||
2301 Name.startswith(
"avx512.storent."))) {
2312 PointerType::getUnqual(Arg1->
getType()),
2317 SI->setMetadata(LLVMContext::MD_nontemporal, Node);
2324 if (IsX86 &&
Name ==
"sse2.storel.dq") {
2329 Value *BC0 =
Builder.CreateBitCast(Arg1, NewVecTy,
"cast");
2332 PointerType::getUnqual(Elt->
getType()),
2341 if (IsX86 && (
Name.startswith(
"sse.storeu.") ||
2342 Name.startswith(
"sse2.storeu.") ||
2343 Name.startswith(
"avx.storeu."))) {
2347 Arg0 =
Builder.CreateBitCast(Arg0,
2348 PointerType::getUnqual(Arg1->
getType()),
2357 if (IsX86 &&
Name ==
"avx512.mask.store.ss") {
2367 if (IsX86 && (
Name.startswith(
"avx512.mask.store"))) {
2380 if (IsX86 && (
Name.startswith(
"sse2.pcmp") ||
2381 Name.startswith(
"avx2.pcmp"))) {
2383 bool CmpEq =
Name[9] ==
'e';
2384 Rep =
Builder.CreateICmp(CmpEq ? ICmpInst::ICMP_EQ : ICmpInst::ICMP_SGT,
2387 }
else if (IsX86 && (
Name.startswith(
"avx512.broadcastm"))) {
2394 Rep =
Builder.CreateVectorSplat(NumElts, Rep);
2395 }
else if (IsX86 && (
Name ==
"sse.sqrt.ss" ||
2396 Name ==
"sse2.sqrt.sd")) {
2400 Intrinsic::sqrt, Elt0->
getType());
2403 }
else if (IsX86 && (
Name.startswith(
"avx.sqrt.p") ||
2404 Name.startswith(
"sse2.sqrt.p") ||
2405 Name.startswith(
"sse.sqrt.p"))) {
2409 {CI->getArgOperand(0)});
2410 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.sqrt.p"))) {
2413 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
2415 : Intrinsic::x86_avx512_sqrt_pd_512;
2424 {CI->getArgOperand(0)});
2428 }
else if (IsX86 && (
Name.startswith(
"avx512.ptestm") ||
2429 Name.startswith(
"avx512.ptestnm"))) {
2433 Rep =
Builder.CreateAnd(Op0, Op1);
2437 Name.startswith(
"avx512.ptestm") ? ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ;
2438 Rep =
Builder.CreateICmp(Pred, Rep, Zero);
2440 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.pbroadcast"))){
2446 }
else if (IsX86 && (
Name.startswith(
"avx512.kunpck"))) {
2451 for (
unsigned i = 0; i != NumElts; ++i)
2464 }
else if (IsX86 &&
Name ==
"avx512.kand.w") {
2469 }
else if (IsX86 &&
Name ==
"avx512.kandn.w") {
2475 }
else if (IsX86 &&
Name ==
"avx512.kor.w") {
2480 }
else if (IsX86 &&
Name ==
"avx512.kxor.w") {
2485 }
else if (IsX86 &&
Name ==
"avx512.kxnor.w") {
2491 }
else if (IsX86 &&
Name ==
"avx512.knot.w") {
2496 (
Name ==
"avx512.kortestz.w" ||
Name ==
"avx512.kortestc.w")) {
2502 if (
Name[14] ==
'c')
2503 C = ConstantInt::getAllOnesValue(
Builder.getInt16Ty());
2505 C = ConstantInt::getNullValue(
Builder.getInt16Ty());
2506 Rep =
Builder.CreateICmpEQ(Rep,
C);
2508 }
else if (IsX86 && (
Name ==
"sse.add.ss" ||
Name ==
"sse2.add.sd" ||
2509 Name ==
"sse.sub.ss" ||
Name ==
"sse2.sub.sd" ||
2510 Name ==
"sse.mul.ss" ||
Name ==
"sse2.mul.sd" ||
2511 Name ==
"sse.div.ss" ||
Name ==
"sse2.div.sd")) {
2518 if (
Name.contains(
".add."))
2519 EltOp =
Builder.CreateFAdd(Elt0, Elt1);
2520 else if (
Name.contains(
".sub."))
2521 EltOp =
Builder.CreateFSub(Elt0, Elt1);
2522 else if (
Name.contains(
".mul."))
2523 EltOp =
Builder.CreateFMul(Elt0, Elt1);
2525 EltOp =
Builder.CreateFDiv(Elt0, Elt1);
2528 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.pcmp")) {
2530 bool CmpEq =
Name[16] ==
'e';
2532 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.vpshufbitqmb.")) {
2538 case 128: IID = Intrinsic::x86_avx512_vpshufbitqmb_128;
break;
2539 case 256: IID = Intrinsic::x86_avx512_vpshufbitqmb_256;
break;
2540 case 512: IID = Intrinsic::x86_avx512_vpshufbitqmb_512;
break;
2544 { CI->getOperand(0), CI->getArgOperand(1) });
2546 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.fpclass.p")) {
2551 if (VecWidth == 128 && EltWidth == 32)
2552 IID = Intrinsic::x86_avx512_fpclass_ps_128;
2553 else if (VecWidth == 256 && EltWidth == 32)
2554 IID = Intrinsic::x86_avx512_fpclass_ps_256;
2555 else if (VecWidth == 512 && EltWidth == 32)
2556 IID = Intrinsic::x86_avx512_fpclass_ps_512;
2557 else if (VecWidth == 128 && EltWidth == 64)
2558 IID = Intrinsic::x86_avx512_fpclass_pd_128;
2559 else if (VecWidth == 256 && EltWidth == 64)
2560 IID = Intrinsic::x86_avx512_fpclass_pd_256;
2561 else if (VecWidth == 512 && EltWidth == 64)
2562 IID = Intrinsic::x86_avx512_fpclass_pd_512;
2567 { CI->getOperand(0), CI->getArgOperand(1) });
2569 }
else if (IsX86 &&
Name.startswith(
"avx512.cmp.p")) {
2571 Type *OpTy = Args[0]->getType();
2575 if (VecWidth == 128 && EltWidth == 32)
2576 IID = Intrinsic::x86_avx512_mask_cmp_ps_128;
2577 else if (VecWidth == 256 && EltWidth == 32)
2578 IID = Intrinsic::x86_avx512_mask_cmp_ps_256;
2579 else if (VecWidth == 512 && EltWidth == 32)
2580 IID = Intrinsic::x86_avx512_mask_cmp_ps_512;
2581 else if (VecWidth == 128 && EltWidth == 64)
2582 IID = Intrinsic::x86_avx512_mask_cmp_pd_128;
2583 else if (VecWidth == 256 && EltWidth == 64)
2584 IID = Intrinsic::x86_avx512_mask_cmp_pd_256;
2585 else if (VecWidth == 512 && EltWidth == 64)
2586 IID = Intrinsic::x86_avx512_mask_cmp_pd_512;
2591 if (VecWidth == 512)
2593 Args.push_back(Mask);
2597 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.cmp.")) {
2599 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2601 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.ucmp.")) {
2602 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2604 }
else if (IsX86 && (
Name.startswith(
"avx512.cvtb2mask.") ||
2605 Name.startswith(
"avx512.cvtw2mask.") ||
2606 Name.startswith(
"avx512.cvtd2mask.") ||
2607 Name.startswith(
"avx512.cvtq2mask."))) {
2610 Rep =
Builder.CreateICmp(ICmpInst::ICMP_SLT,
Op, Zero);
2612 }
else if(IsX86 && (
Name ==
"ssse3.pabs.b.128" ||
2613 Name ==
"ssse3.pabs.w.128" ||
2614 Name ==
"ssse3.pabs.d.128" ||
2615 Name.startswith(
"avx2.pabs") ||
2616 Name.startswith(
"avx512.mask.pabs"))) {
2618 }
else if (IsX86 && (
Name ==
"sse41.pmaxsb" ||
2619 Name ==
"sse2.pmaxs.w" ||
2620 Name ==
"sse41.pmaxsd" ||
2621 Name.startswith(
"avx2.pmaxs") ||
2622 Name.startswith(
"avx512.mask.pmaxs"))) {
2624 }
else if (IsX86 && (
Name ==
"sse2.pmaxu.b" ||
2625 Name ==
"sse41.pmaxuw" ||
2626 Name ==
"sse41.pmaxud" ||
2627 Name.startswith(
"avx2.pmaxu") ||
2628 Name.startswith(
"avx512.mask.pmaxu"))) {
2630 }
else if (IsX86 && (
Name ==
"sse41.pminsb" ||
2631 Name ==
"sse2.pmins.w" ||
2632 Name ==
"sse41.pminsd" ||
2633 Name.startswith(
"avx2.pmins") ||
2634 Name.startswith(
"avx512.mask.pmins"))) {
2636 }
else if (IsX86 && (
Name ==
"sse2.pminu.b" ||
2637 Name ==
"sse41.pminuw" ||
2638 Name ==
"sse41.pminud" ||
2639 Name.startswith(
"avx2.pminu") ||
2640 Name.startswith(
"avx512.mask.pminu"))) {
2642 }
else if (IsX86 && (
Name ==
"sse2.pmulu.dq" ||
2643 Name ==
"avx2.pmulu.dq" ||
2644 Name ==
"avx512.pmulu.dq.512" ||
2645 Name.startswith(
"avx512.mask.pmulu.dq."))) {
2647 }
else if (IsX86 && (
Name ==
"sse41.pmuldq" ||
2648 Name ==
"avx2.pmul.dq" ||
2649 Name ==
"avx512.pmul.dq.512" ||
2650 Name.startswith(
"avx512.mask.pmul.dq."))) {
2652 }
else if (IsX86 && (
Name ==
"sse.cvtsi2ss" ||
2653 Name ==
"sse2.cvtsi2sd" ||
2654 Name ==
"sse.cvtsi642ss" ||
2655 Name ==
"sse2.cvtsi642sd")) {
2658 cast<VectorType>(CI->
getType())->getElementType());
2660 }
else if (IsX86 &&
Name ==
"avx512.cvtusi2sd") {
2663 cast<VectorType>(CI->
getType())->getElementType());
2665 }
else if (IsX86 &&
Name ==
"sse2.cvtss2sd") {
2668 Rep, cast<VectorType>(CI->
getType())->getElementType());
2670 }
else if (IsX86 && (
Name ==
"sse2.cvtdq2pd" ||
2671 Name ==
"sse2.cvtdq2ps" ||
2672 Name ==
"avx.cvtdq2.pd.256" ||
2673 Name ==
"avx.cvtdq2.ps.256" ||
2674 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
2675 Name.startswith(
"avx512.mask.cvtudq2pd.") ||
2676 Name.startswith(
"avx512.mask.cvtdq2ps.") ||
2677 Name.startswith(
"avx512.mask.cvtudq2ps.") ||
2678 Name.startswith(
"avx512.mask.cvtqq2pd.") ||
2679 Name.startswith(
"avx512.mask.cvtuqq2pd.") ||
2680 Name ==
"avx512.mask.cvtqq2ps.256" ||
2681 Name ==
"avx512.mask.cvtqq2ps.512" ||
2682 Name ==
"avx512.mask.cvtuqq2ps.256" ||
2683 Name ==
"avx512.mask.cvtuqq2ps.512" ||
2684 Name ==
"sse2.cvtps2pd" ||
2685 Name ==
"avx.cvt.ps2.pd.256" ||
2686 Name ==
"avx512.mask.cvtps2pd.128" ||
2687 Name ==
"avx512.mask.cvtps2pd.256")) {
2688 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2690 auto *SrcTy = cast<FixedVectorType>(Rep->
getType());
2692 unsigned NumDstElts = DstTy->getNumElements();
2693 if (NumDstElts < SrcTy->getNumElements()) {
2694 assert(NumDstElts == 2 &&
"Unexpected vector size");
2698 bool IsPS2PD = SrcTy->getElementType()->isFloatTy();
2701 Rep =
Builder.CreateFPExt(Rep, DstTy,
"cvtps2pd");
2704 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
2705 Intrinsic::ID IID = IsUnsigned ? Intrinsic::x86_avx512_uitofp_round
2706 : Intrinsic::x86_avx512_sitofp_round;
2711 Rep = IsUnsigned ?
Builder.CreateUIToFP(Rep, DstTy,
"cvt")
2712 :
Builder.CreateSIToFP(Rep, DstTy,
"cvt");
2718 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vcvtph2ps.") ||
2719 Name.startswith(
"vcvtph2ps."))) {
2720 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2722 auto *SrcTy = cast<FixedVectorType>(Rep->
getType());
2723 unsigned NumDstElts = DstTy->getNumElements();
2724 if (NumDstElts != SrcTy->getNumElements()) {
2725 assert(NumDstElts == 4 &&
"Unexpected vector size");
2730 Rep =
Builder.CreateFPExt(Rep, DstTy,
"cvtph2ps");
2734 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.load")) {
2740 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.expand.load.")) {
2741 auto *ResultTy = cast<FixedVectorType>(CI->
getType());
2742 Type *PtrTy = ResultTy->getElementType();
2749 ResultTy->getNumElements());
2752 Intrinsic::masked_expandload,
2755 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.compress.store.")) {
2757 Type *PtrTy = ResultTy->getElementType();
2765 cast<FixedVectorType>(ResultTy)->getNumElements());
2768 Intrinsic::masked_compressstore,
2771 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.compress.") ||
2772 Name.startswith(
"avx512.mask.expand."))) {
2773 auto *ResultTy = cast<FixedVectorType>(CI->
getType());
2776 ResultTy->getNumElements());
2778 bool IsCompress =
Name[12] ==
'c';
2779 Intrinsic::ID IID = IsCompress ? Intrinsic::x86_avx512_mask_compress
2780 : Intrinsic::x86_avx512_mask_expand;
2784 }
else if (IsX86 &&
Name.startswith(
"xop.vpcom")) {
2786 if (
Name.endswith(
"ub") ||
Name.endswith(
"uw") ||
Name.endswith(
"ud") ||
2787 Name.endswith(
"uq"))
2789 else if (
Name.endswith(
"b") ||
Name.endswith(
"w") ||
Name.endswith(
"d") ||
2797 Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2800 if (
Name.startswith(
"lt"))
2802 else if (
Name.startswith(
"le"))
2804 else if (
Name.startswith(
"gt"))
2806 else if (
Name.startswith(
"ge"))
2808 else if (
Name.startswith(
"eq"))
2810 else if (
Name.startswith(
"ne"))
2812 else if (
Name.startswith(
"false"))
2814 else if (
Name.startswith(
"true"))
2821 }
else if (IsX86 &&
Name.startswith(
"xop.vpcmov")) {
2826 Rep =
Builder.CreateOr(Sel0, Sel1);
2827 }
else if (IsX86 && (
Name.startswith(
"xop.vprot") ||
2828 Name.startswith(
"avx512.prol") ||
2829 Name.startswith(
"avx512.mask.prol"))) {
2831 }
else if (IsX86 && (
Name.startswith(
"avx512.pror") ||
2832 Name.startswith(
"avx512.mask.pror"))) {
2834 }
else if (IsX86 && (
Name.startswith(
"avx512.vpshld.") ||
2835 Name.startswith(
"avx512.mask.vpshld") ||
2836 Name.startswith(
"avx512.maskz.vpshld"))) {
2837 bool ZeroMask =
Name[11] ==
'z';
2839 }
else if (IsX86 && (
Name.startswith(
"avx512.vpshrd.") ||
2840 Name.startswith(
"avx512.mask.vpshrd") ||
2841 Name.startswith(
"avx512.maskz.vpshrd"))) {
2842 bool ZeroMask =
Name[11] ==
'z';
2844 }
else if (IsX86 &&
Name ==
"sse42.crc32.64.8") {
2846 Intrinsic::x86_sse42_crc32_32_8);
2850 }
else if (IsX86 && (
Name.startswith(
"avx.vbroadcast.s") ||
2851 Name.startswith(
"avx512.vbroadcast.s"))) {
2853 auto *VecTy = cast<FixedVectorType>(CI->
getType());
2854 Type *EltTy = VecTy->getElementType();
2855 unsigned EltNum = VecTy->getNumElements();
2859 for (
unsigned I = 0;
I < EltNum; ++
I)
2860 Rep =
Builder.CreateInsertElement(Rep, Load,
2862 }
else if (IsX86 && (
Name.startswith(
"sse41.pmovsx") ||
2863 Name.startswith(
"sse41.pmovzx") ||
2864 Name.startswith(
"avx2.pmovsx") ||
2865 Name.startswith(
"avx2.pmovzx") ||
2866 Name.startswith(
"avx512.mask.pmovsx") ||
2867 Name.startswith(
"avx512.mask.pmovzx"))) {
2868 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2869 unsigned NumDstElts = DstTy->getNumElements();
2873 for (
unsigned i = 0; i != NumDstElts; ++i)
2880 Rep = DoSext ?
Builder.CreateSExt(SV, DstTy)
2881 :
Builder.CreateZExt(SV, DstTy);
2886 }
else if (
Name ==
"avx512.mask.pmov.qd.256" ||
2887 Name ==
"avx512.mask.pmov.qd.512" ||
2888 Name ==
"avx512.mask.pmov.wb.256" ||
2889 Name ==
"avx512.mask.pmov.wb.512") {
2894 }
else if (IsX86 && (
Name.startswith(
"avx.vbroadcastf128") ||
2895 Name ==
"avx2.vbroadcasti128")) {
2897 Type *EltTy = cast<VectorType>(CI->
getType())->getElementType();
2901 PointerType::getUnqual(VT));
2903 if (NumSrcElts == 2)
2906 Rep =
Builder.CreateShuffleVector(
2908 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.shuf.i") ||
2909 Name.startswith(
"avx512.mask.shuf.f"))) {
2910 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2914 unsigned ControlBitsMask = NumLanes - 1;
2915 unsigned NumControlBits = NumLanes / 2;
2918 for (
unsigned l = 0; l != NumLanes; ++l) {
2919 unsigned LaneMask = (Imm >> (l * NumControlBits)) & ControlBitsMask;
2921 if (l >= NumLanes / 2)
2922 LaneMask += NumLanes;
2923 for (
unsigned i = 0; i != NumElementsInLane; ++i)
2924 ShuffleMask.
push_back(LaneMask * NumElementsInLane + i);
2930 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.broadcastf") ||
2931 Name.startswith(
"avx512.mask.broadcasti"))) {
2932 unsigned NumSrcElts =
2935 unsigned NumDstElts =
2936 cast<FixedVectorType>(CI->
getType())->getNumElements();
2939 for (
unsigned i = 0; i != NumDstElts; ++i)
2940 ShuffleMask[i] = i % NumSrcElts;
2947 }
else if (IsX86 && (
Name.startswith(
"avx2.pbroadcast") ||
2948 Name.startswith(
"avx2.vbroadcast") ||
2949 Name.startswith(
"avx512.pbroadcast") ||
2950 Name.startswith(
"avx512.mask.broadcast.s"))) {
2957 Rep =
Builder.CreateShuffleVector(
Op, M);
2962 }
else if (IsX86 && (
Name.startswith(
"sse2.padds.") ||
2963 Name.startswith(
"avx2.padds.") ||
2964 Name.startswith(
"avx512.padds.") ||
2965 Name.startswith(
"avx512.mask.padds."))) {
2967 }
else if (IsX86 && (
Name.startswith(
"sse2.psubs.") ||
2968 Name.startswith(
"avx2.psubs.") ||
2969 Name.startswith(
"avx512.psubs.") ||
2970 Name.startswith(
"avx512.mask.psubs."))) {
2972 }
else if (IsX86 && (
Name.startswith(
"sse2.paddus.") ||
2973 Name.startswith(
"avx2.paddus.") ||
2974 Name.startswith(
"avx512.mask.paddus."))) {
2976 }
else if (IsX86 && (
Name.startswith(
"sse2.psubus.") ||
2977 Name.startswith(
"avx2.psubus.") ||
2978 Name.startswith(
"avx512.mask.psubus."))) {
2980 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.palignr.")) {
2987 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.valign.")) {
2994 }
else if (IsX86 && (
Name ==
"sse2.psll.dq" ||
2995 Name ==
"avx2.psll.dq")) {
2997 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3000 }
else if (IsX86 && (
Name ==
"sse2.psrl.dq" ||
3001 Name ==
"avx2.psrl.dq")) {
3003 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3006 }
else if (IsX86 && (
Name ==
"sse2.psll.dq.bs" ||
3007 Name ==
"avx2.psll.dq.bs" ||
3008 Name ==
"avx512.psll.dq.512")) {
3010 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3012 }
else if (IsX86 && (
Name ==
"sse2.psrl.dq.bs" ||
3013 Name ==
"avx2.psrl.dq.bs" ||
3014 Name ==
"avx512.psrl.dq.512")) {
3016 unsigned Shift = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3018 }
else if (IsX86 && (
Name ==
"sse41.pblendw" ||
3019 Name.startswith(
"sse41.blendp") ||
3020 Name.startswith(
"avx.blend.p") ||
3021 Name ==
"avx2.pblendw" ||
3022 Name.startswith(
"avx2.pblendd."))) {
3025 unsigned Imm = cast <ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3026 auto *VecTy = cast<FixedVectorType>(CI->
getType());
3027 unsigned NumElts = VecTy->getNumElements();
3030 for (
unsigned i = 0; i != NumElts; ++i)
3031 Idxs[i] = ((Imm >> (i%8)) & 1) ? i + NumElts : i;
3033 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
3034 }
else if (IsX86 && (
Name.startswith(
"avx.vinsertf128.") ||
3035 Name ==
"avx2.vinserti128" ||
3036 Name.startswith(
"avx512.mask.insert"))) {
3039 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3040 unsigned DstNumElts =
3041 cast<FixedVectorType>(CI->
getType())->getNumElements();
3042 unsigned SrcNumElts =
3043 cast<FixedVectorType>(Op1->
getType())->getNumElements();
3044 unsigned Scale = DstNumElts / SrcNumElts;
3051 for (
unsigned i = 0; i != SrcNumElts; ++i)
3053 for (
unsigned i = SrcNumElts; i != DstNumElts; ++i)
3054 Idxs[i] = SrcNumElts;
3055 Rep =
Builder.CreateShuffleVector(Op1, Idxs);
3069 for (
unsigned i = 0; i != DstNumElts; ++i)
3072 for (
unsigned i = 0; i != SrcNumElts; ++i)
3073 Idxs[i + Imm * SrcNumElts] = i + DstNumElts;
3074 Rep =
Builder.CreateShuffleVector(Op0, Rep, Idxs);
3080 }
else if (IsX86 && (
Name.startswith(
"avx.vextractf128.") ||
3081 Name ==
"avx2.vextracti128" ||
3082 Name.startswith(
"avx512.mask.vextract"))) {
3084 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3085 unsigned DstNumElts =
3086 cast<FixedVectorType>(CI->
getType())->getNumElements();
3087 unsigned SrcNumElts =
3088 cast<FixedVectorType>(Op0->
getType())->getNumElements();
3089 unsigned Scale = SrcNumElts / DstNumElts;
3096 for (
unsigned i = 0; i != DstNumElts; ++i) {
3097 Idxs[i] = i + (Imm * DstNumElts);
3099 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
3105 }
else if (!IsX86 &&
Name ==
"stackprotectorcheck") {
3107 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.perm.df.") ||
3108 Name.startswith(
"avx512.mask.perm.di."))) {
3110 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3111 auto *VecTy = cast<FixedVectorType>(CI->
getType());
3112 unsigned NumElts = VecTy->getNumElements();
3115 for (
unsigned i = 0; i != NumElts; ++i)
3116 Idxs[i] = (i & ~0x3) + ((Imm >> (2 * (i & 0x3))) & 3);
3118 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
3123 }
else if (IsX86 && (
Name.startswith(
"avx.vperm2f128.") ||
3124 Name ==
"avx2.vperm2i128")) {
3133 uint8_t Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3135 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3136 unsigned HalfSize = NumElts / 2;
3148 unsigned StartIndex = (Imm & 0x01) ? HalfSize : 0;
3149 for (
unsigned i = 0; i < HalfSize; ++i)
3150 ShuffleMask[i] = StartIndex + i;
3153 StartIndex = (Imm & 0x10) ? HalfSize : 0;
3154 for (
unsigned i = 0; i < HalfSize; ++i)
3155 ShuffleMask[i + HalfSize] = NumElts + StartIndex + i;
3157 Rep =
Builder.CreateShuffleVector(V0, V1, ShuffleMask);
3159 }
else if (IsX86 && (
Name.startswith(
"avx.vpermil.") ||
3160 Name ==
"sse2.pshuf.d" ||
3161 Name.startswith(
"avx512.mask.vpermil.p") ||
3162 Name.startswith(
"avx512.mask.pshuf.d."))) {
3164 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3165 auto *VecTy = cast<FixedVectorType>(CI->
getType());
3166 unsigned NumElts = VecTy->getNumElements();
3168 unsigned IdxSize = 64 / VecTy->getScalarSizeInBits();
3169 unsigned IdxMask = ((1 << IdxSize) - 1);
3175 for (
unsigned i = 0; i != NumElts; ++i)
3176 Idxs[i] = ((Imm >> ((i * IdxSize) % 8)) & IdxMask) | (i & ~IdxMask);
3178 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
3183 }
else if (IsX86 && (
Name ==
"sse2.pshufl.w" ||
3184 Name.startswith(
"avx512.mask.pshufl.w."))) {
3186 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3187 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3190 for (
unsigned l = 0; l != NumElts; l += 8) {
3191 for (
unsigned i = 0; i != 4; ++i)
3192 Idxs[i + l] = ((Imm >> (2 * i)) & 0x3) + l;
3193 for (
unsigned i = 4; i != 8; ++i)
3194 Idxs[i + l] = i + l;
3197 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
3202 }
else if (IsX86 && (
Name ==
"sse2.pshufh.w" ||
3203 Name.startswith(
"avx512.mask.pshufh.w."))) {
3205 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
3206 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3209 for (
unsigned l = 0; l != NumElts; l += 8) {
3210 for (
unsigned i = 0; i != 4; ++i)
3211 Idxs[i + l] = i + l;
3212 for (
unsigned i = 0; i != 4; ++i)
3213 Idxs[i + l + 4] = ((Imm >> (2 * i)) & 0x3) + 4 + l;
3216 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
3221 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.shuf.p")) {
3224 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
3225 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3228 unsigned HalfLaneElts = NumLaneElts / 2;
3231 for (
unsigned i = 0; i != NumElts; ++i) {
3233 Idxs[i] = i - (i % NumLaneElts);
3235 if ((i % NumLaneElts) >= HalfLaneElts)
3239 Idxs[i] += (Imm >> ((i * HalfLaneElts) % 8)) & ((1 << HalfLaneElts) - 1);
3242 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
3246 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.movddup") ||
3247 Name.startswith(
"avx512.mask.movshdup") ||
3248 Name.startswith(
"avx512.mask.movsldup"))) {
3250 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3254 if (
Name.startswith(
"avx512.mask.movshdup."))
3258 for (
unsigned l = 0; l != NumElts; l += NumLaneElts)
3259 for (
unsigned i = 0; i != NumLaneElts; i += 2) {
3260 Idxs[i + l + 0] = i + l +
Offset;
3261 Idxs[i + l + 1] = i + l +
Offset;
3264 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
3268 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.punpckl") ||
3269 Name.startswith(
"avx512.mask.unpckl."))) {
3272 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3276 for (
int l = 0; l != NumElts; l += NumLaneElts)
3277 for (
int i = 0; i != NumLaneElts; ++i)
3278 Idxs[i + l] = l + (i / 2) + NumElts * (i % 2);
3280 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
3284 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.punpckh") ||
3285 Name.startswith(
"avx512.mask.unpckh."))) {
3288 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3292 for (
int l = 0; l != NumElts; l += NumLaneElts)
3293 for (
int i = 0; i != NumLaneElts; ++i)
3294 Idxs[i + l] = (NumLaneElts / 2) + l + (i / 2) + NumElts * (i % 2);
3296 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
3300 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.and.") ||
3301 Name.startswith(
"avx512.mask.pand."))) {
3303 VectorType *ITy = VectorType::getInteger(FTy);
3306 Rep =
Builder.CreateBitCast(Rep, FTy);
3309 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.andn.") ||
3310 Name.startswith(
"avx512.mask.pandn."))) {
3312 VectorType *ITy = VectorType::getInteger(FTy);
3316 Rep =
Builder.CreateBitCast(Rep, FTy);
3319 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.or.") ||
3320 Name.startswith(
"avx512.mask.por."))) {
3322 VectorType *ITy = VectorType::getInteger(FTy);
3325 Rep =
Builder.CreateBitCast(Rep, FTy);
3328 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.xor.") ||
3329 Name.startswith(
"avx512.mask.pxor."))) {
3331 VectorType *ITy = VectorType::getInteger(FTy);
3334 Rep =
Builder.CreateBitCast(Rep, FTy);
3337 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.padd.")) {
3341 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psub.")) {
3345 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.pmull.")) {
3349 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.add.p")) {
3350 if (
Name.endswith(
".512")) {
3352 if (
Name[17] ==
's')
3353 IID = Intrinsic::x86_avx512_add_ps_512;
3355 IID = Intrinsic::x86_avx512_add_pd_512;
3358 { CI->getArgOperand(0), CI->getArgOperand(1),
3359 CI->getArgOperand(4) });
3365 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.div.p")) {
3366 if (
Name.endswith(
".512")) {
3368 if (
Name[17] ==
's')
3369 IID = Intrinsic::x86_avx512_div_ps_512;
3371 IID = Intrinsic::x86_avx512_div_pd_512;
3374 { CI->getArgOperand(0), CI->getArgOperand(1),
3375 CI->getArgOperand(4) });
3381 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.mul.p")) {
3382 if (
Name.endswith(
".512")) {
3384 if (
Name[17] ==
's')
3385 IID = Intrinsic::x86_avx512_mul_ps_512;
3387 IID = Intrinsic::x86_avx512_mul_pd_512;
3390 { CI->getArgOperand(0), CI->getArgOperand(1),
3391 CI->getArgOperand(4) });
3397 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.sub.p")) {
3398 if (
Name.endswith(
".512")) {
3400 if (
Name[17] ==
's')
3401 IID = Intrinsic::x86_avx512_sub_ps_512;
3403 IID = Intrinsic::x86_avx512_sub_pd_512;
3406 { CI->getArgOperand(0), CI->getArgOperand(1),
3407 CI->getArgOperand(4) });
3413 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.max.p") ||
3414 Name.startswith(
"avx512.mask.min.p")) &&
3415 Name.drop_front(18) ==
".512") {
3416 bool IsDouble =
Name[17] ==
'd';
3417 bool IsMin =
Name[13] ==
'i';
3419 { Intrinsic::x86_avx512_max_ps_512, Intrinsic::x86_avx512_max_pd_512 },
3420 { Intrinsic::x86_avx512_min_ps_512, Intrinsic::x86_avx512_min_pd_512 }
3425 { CI->getArgOperand(0), CI->getArgOperand(1),
3426 CI->getArgOperand(4) });
3429 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.lzcnt.")) {
3433 { CI->getArgOperand(0), Builder.getInt1(false) });
3436 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psll")) {
3437 bool IsImmediate =
Name[16] ==
'i' ||
3438 (
Name.size() > 18 &&
Name[18] ==
'i');
3439 bool IsVariable =
Name[16] ==
'v';
3446 if (IsVariable &&
Name[17] !=
'.') {
3447 if (
Size ==
'd' &&
Name[17] ==
'2')
3448 IID = Intrinsic::x86_avx2_psllv_q;
3449 else if (
Size ==
'd' &&
Name[17] ==
'4')
3450 IID = Intrinsic::x86_avx2_psllv_q_256;
3451 else if (
Size ==
's' &&
Name[17] ==
'4')
3452 IID = Intrinsic::x86_avx2_psllv_d;
3453 else if (
Size ==
's' &&
Name[17] ==
'8')
3454 IID = Intrinsic::x86_avx2_psllv_d_256;
3455 else if (
Size ==
'h' &&
Name[17] ==
'8')
3456 IID = Intrinsic::x86_avx512_psllv_w_128;
3457 else if (
Size ==
'h' &&
Name[17] ==
'1')
3458 IID = Intrinsic::x86_avx512_psllv_w_256;
3459 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3460 IID = Intrinsic::x86_avx512_psllv_w_512;
3463 }
else if (
Name.endswith(
".128")) {
3465 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_d
3466 : Intrinsic::x86_sse2_psll_d;
3467 else if (
Size ==
'q')
3468 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_q
3469 : Intrinsic::x86_sse2_psll_q;
3470 else if (
Size ==
'w')
3471 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_w
3472 : Intrinsic::x86_sse2_psll_w;
3475 }
else if (
Name.endswith(
".256")) {
3477 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_d
3478 : Intrinsic::x86_avx2_psll_d;
3479 else if (
Size ==
'q')
3480 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_q
3481 : Intrinsic::x86_avx2_psll_q;
3482 else if (
Size ==
'w')
3483 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_w
3484 : Intrinsic::x86_avx2_psll_w;
3489 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_d_512 :
3490 IsVariable ? Intrinsic::x86_avx512_psllv_d_512 :
3491 Intrinsic::x86_avx512_psll_d_512;
3492 else if (
Size ==
'q')
3493 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_q_512 :
3494 IsVariable ? Intrinsic::x86_avx512_psllv_q_512 :
3495 Intrinsic::x86_avx512_psll_q_512;
3496 else if (
Size ==
'w')
3497 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_w_512
3498 : Intrinsic::x86_avx512_psll_w_512;
3504 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psrl")) {
3505 bool IsImmediate =
Name[16] ==
'i' ||
3506 (
Name.size() > 18 &&
Name[18] ==
'i');
3507 bool IsVariable =
Name[16] ==
'v';
3514 if (IsVariable &&
Name[17] !=
'.') {
3515 if (
Size ==
'd' &&
Name[17] ==
'2')
3516 IID = Intrinsic::x86_avx2_psrlv_q;
3517 else if (
Size ==
'd' &&
Name[17] ==
'4')
3518 IID = Intrinsic::x86_avx2_psrlv_q_256;
3519 else if (
Size ==
's' &&
Name[17] ==
'4')
3520 IID = Intrinsic::x86_avx2_psrlv_d;
3521 else if (
Size ==
's' &&
Name[17] ==
'8')
3522 IID = Intrinsic::x86_avx2_psrlv_d_256;
3523 else if (
Size ==
'h' &&
Name[17] ==
'8')
3524 IID = Intrinsic::x86_avx512_psrlv_w_128;
3525 else if (
Size ==
'h' &&
Name[17] ==
'1')
3526 IID = Intrinsic::x86_avx512_psrlv_w_256;
3527 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3528 IID = Intrinsic::x86_avx512_psrlv_w_512;
3531 }
else if (
Name.endswith(
".128")) {
3533 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_d
3534 : Intrinsic::x86_sse2_psrl_d;
3535 else if (
Size ==
'q')
3536 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_q
3537 : Intrinsic::x86_sse2_psrl_q;
3538 else if (
Size ==
'w')
3539 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_w
3540 : Intrinsic::x86_sse2_psrl_w;
3543 }
else if (
Name.endswith(
".256")) {
3545 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_d
3546 : Intrinsic::x86_avx2_psrl_d;
3547 else if (
Size ==
'q')
3548 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_q
3549 : Intrinsic::x86_avx2_psrl_q;
3550 else if (
Size ==
'w')
3551 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_w
3552 : Intrinsic::x86_avx2_psrl_w;
3557 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_d_512 :
3558 IsVariable ? Intrinsic::x86_avx512_psrlv_d_512 :
3559 Intrinsic::x86_avx512_psrl_d_512;
3560 else if (
Size ==
'q')
3561 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_q_512 :
3562 IsVariable ? Intrinsic::x86_avx512_psrlv_q_512 :
3563 Intrinsic::x86_avx512_psrl_q_512;
3564 else if (
Size ==
'w')
3565 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_w_512
3566 : Intrinsic::x86_avx512_psrl_w_512;
3572 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psra")) {
3573 bool IsImmediate =
Name[16] ==
'i' ||
3574 (
Name.size() > 18 &&
Name[18] ==
'i');
3575 bool IsVariable =
Name[16] ==
'v';
3582 if (IsVariable &&
Name[17] !=
'.') {
3583 if (
Size ==
's' &&
Name[17] ==
'4')
3584 IID = Intrinsic::x86_avx2_psrav_d;
3585 else if (
Size ==
's' &&
Name[17] ==
'8')
3586 IID = Intrinsic::x86_avx2_psrav_d_256;
3587 else if (
Size ==
'h' &&
Name[17] ==
'8')
3588 IID = Intrinsic::x86_avx512_psrav_w_128;
3589 else if (
Size ==
'h' &&
Name[17] ==
'1')
3590 IID = Intrinsic::x86_avx512_psrav_w_256;
3591 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3592 IID = Intrinsic::x86_avx512_psrav_w_512;
3595 }
else if (
Name.endswith(
".128")) {
3597 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_d
3598 : Intrinsic::x86_sse2_psra_d;
3599 else if (
Size ==
'q')
3600 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_128 :
3601 IsVariable ? Intrinsic::x86_avx512_psrav_q_128 :
3602 Intrinsic::x86_avx512_psra_q_128;
3603 else if (
Size ==
'w')
3604 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_w
3605 : Intrinsic::x86_sse2_psra_w;
3608 }
else if (
Name.endswith(
".256")) {
3610 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_d
3611 : Intrinsic::x86_avx2_psra_d;
3612 else if (
Size ==
'q')
3613 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_256 :
3614 IsVariable ? Intrinsic::x86_avx512_psrav_q_256 :
3615 Intrinsic::x86_avx512_psra_q_256;
3616 else if (
Size ==
'w')
3617 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_w
3618 : Intrinsic::x86_avx2_psra_w;
3623 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_d_512 :
3624 IsVariable ? Intrinsic::x86_avx512_psrav_d_512 :
3625 Intrinsic::x86_avx512_psra_d_512;
3626 else if (
Size ==
'q')
3627 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_512 :
3628 IsVariable ? Intrinsic::x86_avx512_psrav_q_512 :
3629 Intrinsic::x86_avx512_psra_q_512;
3630 else if (
Size ==
'w')
3631 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_w_512
3632 : Intrinsic::x86_avx512_psra_w_512;
3638 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.move.s")) {
3640 }
else if (IsX86 &&
Name.startswith(
"avx512.cvtmask2")) {
3642 }
else if (IsX86 &&
Name.endswith(
".movntdqa")) {
3650 Ptr, PointerType::getUnqual(CI->
getType()),
"cast");
3654 LI->
setMetadata(LLVMContext::MD_nontemporal, Node);
3656 }
else if (IsX86 && (
Name.startswith(
"fma.vfmadd.") ||
3657 Name.startswith(
"fma.vfmsub.") ||
3658 Name.startswith(
"fma.vfnmadd.") ||
3659 Name.startswith(
"fma.vfnmsub."))) {
3660 bool NegMul =
Name[6] ==
'n';
3661 bool NegAcc = NegMul ?
Name[8] ==
's' :
Name[7] ==
's';
3662 bool IsScalar = NegMul ?
Name[12] ==
's' :
Name[11] ==
's';
3673 if (NegMul && !IsScalar)
3674 Ops[0] =
Builder.CreateFNeg(Ops[0]);
3675 if (NegMul && IsScalar)
3676 Ops[1] =
Builder.CreateFNeg(Ops[1]);
3678 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3688 }
else if (IsX86 &&
Name.startswith(
"fma4.vfmadd.s")) {
3703 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vfmadd.s") ||
3704 Name.startswith(
"avx512.maskz.vfmadd.s") ||
3705 Name.startswith(
"avx512.mask3.vfmadd.s") ||
3706 Name.startswith(
"avx512.mask3.vfmsub.s") ||
3707 Name.startswith(
"avx512.mask3.vfnmsub.s"))) {
3708 bool IsMask3 =
Name[11] ==
'3';
3709 bool IsMaskZ =
Name[11] ==
'z';
3711 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3712 bool NegMul =
Name[2] ==
'n';
3713 bool NegAcc = NegMul ?
Name[4] ==
's' :
Name[3] ==
's';
3719 if (NegMul && (IsMask3 || IsMaskZ))
3721 if (NegMul && !(IsMask3 || IsMaskZ))
3731 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4) {
3735 if (
Name.back() ==
'd')
3736 IID = Intrinsic::x86_avx512_vfmadd_f64;
3738 IID = Intrinsic::x86_avx512_vfmadd_f32;
3740 Rep =
Builder.CreateCall(FMA, Ops);
3753 if (NegAcc && IsMask3)
3761 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vfmadd.p") ||
3762 Name.startswith(
"avx512.mask.vfnmadd.p") ||
3763 Name.startswith(
"avx512.mask.vfnmsub.p") ||
3764 Name.startswith(
"avx512.mask3.vfmadd.p") ||
3765 Name.startswith(
"avx512.mask3.vfmsub.p") ||
3766 Name.startswith(
"avx512.mask3.vfnmsub.p") ||
3767 Name.startswith(
"avx512.maskz.vfmadd.p"))) {
3768 bool IsMask3 =
Name[11] ==
'3';
3769 bool IsMaskZ =
Name[11] ==
'z';
3771 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3772 bool NegMul =
Name[2] ==
'n';
3773 bool NegAcc = NegMul ?
Name[4] ==
's' :
Name[3] ==
's';
3779 if (NegMul && (IsMask3 || IsMaskZ))
3781 if (NegMul && !(IsMask3 || IsMaskZ))
3788 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4)) {
3792 IID = Intrinsic::x86_avx512_vfmadd_ps_512;
3794 IID = Intrinsic::x86_avx512_vfmadd_pd_512;
3797 { A, B, C, CI->getArgOperand(4) });
3810 }
else if (IsX86 &&
Name.startswith(
"fma.vfmsubadd.p")) {
3814 if (VecWidth == 128 && EltWidth == 32)
3815 IID = Intrinsic::x86_fma_vfmaddsub_ps;
3816 else if (VecWidth == 256 && EltWidth == 32)
3817 IID = Intrinsic::x86_fma_vfmaddsub_ps_256;
3818 else if (VecWidth == 128 && EltWidth == 64)
3819 IID = Intrinsic::x86_fma_vfmaddsub_pd;
3820 else if (VecWidth == 256 && EltWidth == 64)
3821 IID = Intrinsic::x86_fma_vfmaddsub_pd_256;
3827 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3830 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vfmaddsub.p") ||
3831 Name.startswith(
"avx512.mask3.vfmaddsub.p") ||
3832 Name.startswith(
"avx512.maskz.vfmaddsub.p") ||
3833 Name.startswith(
"avx512.mask3.vfmsubadd.p"))) {
3834 bool IsMask3 =
Name[11] ==
'3';
3835 bool IsMaskZ =
Name[11] ==
'z';
3837 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3838 bool IsSubAdd =
Name[3] ==
's';
3843 IID = Intrinsic::x86_avx512_vfmaddsub_ps_512;
3845 IID = Intrinsic::x86_avx512_vfmaddsub_pd_512;
3850 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3855 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3863 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3870 for (
int i = 0; i != NumElts; ++i)
3871 Idxs[i] = i + (i % 2) * NumElts;
3873 Rep =
Builder.CreateShuffleVector(Even, Odd, Idxs);
3881 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.pternlog.") ||
3882 Name.startswith(
"avx512.maskz.pternlog."))) {
3883 bool ZeroMask =
Name[11] ==
'z';
3887 if (VecWidth == 128 && EltWidth == 32)
3888 IID = Intrinsic::x86_avx512_pternlog_d_128;
3889 else if (VecWidth == 256 && EltWidth == 32)
3890 IID = Intrinsic::x86_avx512_pternlog_d_256;
3891 else if (VecWidth == 512 && EltWidth == 32)
3892 IID = Intrinsic::x86_avx512_pternlog_d_512;
3893 else if (VecWidth == 128 && EltWidth == 64)
3894 IID = Intrinsic::x86_avx512_pternlog_q_128;
3895 else if (VecWidth == 256 && EltWidth == 64)
3896 IID = Intrinsic::x86_avx512_pternlog_q_256;
3897 else if (VecWidth == 512 && EltWidth == 64)
3898 IID = Intrinsic::x86_avx512_pternlog_q_512;
3909 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpmadd52") ||
3910 Name.startswith(
"avx512.maskz.vpmadd52"))) {
3911 bool ZeroMask =
Name[11] ==
'z';
3915 if (VecWidth == 128 && !
High)
3916 IID = Intrinsic::x86_avx512_vpmadd52l_uq_128;
3917 else if (VecWidth == 256 && !
High)
3918 IID = Intrinsic::x86_avx512_vpmadd52l_uq_256;
3919 else if (VecWidth == 512 && !
High)
3920 IID = Intrinsic::x86_avx512_vpmadd52l_uq_512;
3921 else if (VecWidth == 128 &&
High)
3922 IID = Intrinsic::x86_avx512_vpmadd52h_uq_128;
3923 else if (VecWidth == 256 &&
High)
3924 IID = Intrinsic::x86_avx512_vpmadd52h_uq_256;
3925 else if (VecWidth == 512 &&
High)
3926 IID = Intrinsic::x86_avx512_vpmadd52h_uq_512;
3937 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpermi2var.") ||
3938 Name.startswith(
"avx512.mask.vpermt2var.") ||
3939 Name.startswith(
"avx512.maskz.vpermt2var."))) {
3940 bool ZeroMask =
Name[11] ==
'z';
3941 bool IndexForm =
Name[17] ==
'i';
3943 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpdpbusd.") ||
3944 Name.startswith(
"avx512.maskz.vpdpbusd.") ||
3945 Name.startswith(
"avx512.mask.vpdpbusds.") ||
3946 Name.startswith(
"avx512.maskz.vpdpbusds."))) {
3947 bool ZeroMask =
Name[11] ==
'z';
3948 bool IsSaturating =
Name[ZeroMask ? 21 : 20] ==
's';
3951 if (VecWidth == 128 && !IsSaturating)
3952 IID = Intrinsic::x86_avx512_vpdpbusd_128;
3953 else if (VecWidth == 256 && !IsSaturating)
3954 IID = Intrinsic::x86_avx512_vpdpbusd_256;
3955 else if (VecWidth == 512 && !IsSaturating)
3956 IID = Intrinsic::x86_avx512_vpdpbusd_512;
3957 else if (VecWidth == 128 && IsSaturating)
3958 IID = Intrinsic::x86_avx512_vpdpbusds_128;
3959 else if (VecWidth == 256 && IsSaturating)
3960 IID = Intrinsic::x86_avx512_vpdpbusds_256;
3961 else if (VecWidth == 512 && IsSaturating)
3962 IID = Intrinsic::x86_avx512_vpdpbusds_512;
3973 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpdpwssd.") ||
3974 Name.startswith(
"avx512.maskz.vpdpwssd.") ||
3975 Name.startswith(
"avx512.mask.vpdpwssds.") ||
3976 Name.startswith(
"avx512.maskz.vpdpwssds."))) {
3977 bool ZeroMask =
Name[11] ==
'z';
3978 bool IsSaturating =
Name[ZeroMask ? 21 : 20] ==
's';
3981 if (VecWidth == 128 && !IsSaturating)
3982 IID = Intrinsic::x86_avx512_vpdpwssd_128;
3983 else if (VecWidth == 256 && !IsSaturating)
3984 IID = Intrinsic::x86_avx512_vpdpwssd_256;
3985 else if (VecWidth == 512 && !IsSaturating)
3986 IID = Intrinsic::x86_avx512_vpdpwssd_512;
3987 else if (VecWidth == 128 && IsSaturating)
3988 IID = Intrinsic::x86_avx512_vpdpwssds_128;
3989 else if (VecWidth == 256 && IsSaturating)
3990 IID = Intrinsic::x86_avx512_vpdpwssds_256;
3991 else if (VecWidth == 512 && IsSaturating)
3992 IID = Intrinsic::x86_avx512_vpdpwssds_512;
4003 }
else if (IsX86 && (
Name ==
"addcarryx.u32" ||
Name ==
"addcarryx.u64" ||
4004 Name ==
"addcarry.u32" ||
Name ==
"addcarry.u64" ||
4005 Name ==
"subborrow.u32" ||
Name ==
"subborrow.u64")) {
4007 if (
Name[0] ==
'a' &&
Name.back() ==
'2')
4008 IID = Intrinsic::x86_addcarry_32;
4009 else if (
Name[0] ==
'a' &&
Name.back() ==
'4')
4010 IID = Intrinsic::x86_addcarry_64;
4011 else if (
Name[0] ==
's' &&
Name.back() ==
'2')
4012 IID = Intrinsic::x86_subborrow_32;
4013 else if (
Name[0] ==
's' &&
Name.back() ==
'4')
4014 IID = Intrinsic::x86_subborrow_64;
4036 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.") &&
4039 }
else if (IsNVVM && (
Name ==
"abs.i" ||
Name ==
"abs.ll")) {
4044 Rep =
Builder.CreateSelect(Cmp, Arg, Neg,
"abs");
4045 }
else if (IsNVVM && (
Name.startswith(
"atomic.load.add.f32.p") ||
4046 Name.startswith(
"atomic.load.add.f64.p"))) {
4050 AtomicOrdering::SequentiallyConsistent);
4051 }
else if (IsNVVM && (
Name ==
"max.i" ||
Name ==
"max.ll" ||
4052 Name ==
"max.ui" ||
Name ==
"max.ull")) {
4056 ?
Builder.CreateICmpUGE(Arg0, Arg1,
"max.cond")
4057 :
Builder.CreateICmpSGE(Arg0, Arg1,
"max.cond");
4058 Rep =
Builder.CreateSelect(Cmp, Arg0, Arg1,
"max");
4059 }
else if (IsNVVM && (
Name ==
"min.i" ||
Name ==
"min.ll" ||
4060 Name ==
"min.ui" ||
Name ==
"min.ull")) {
4064 ?
Builder.CreateICmpULE(Arg0, Arg1,
"min.cond")
4065 :
Builder.CreateICmpSLE(Arg0, Arg1,
"min.cond");
4066 Rep =
Builder.CreateSelect(Cmp, Arg0, Arg1,
"min");
4067 }
else if (IsNVVM &&
Name ==
"clz.ll") {
4073 {Arg, Builder.getFalse()},
"ctlz");
4074 Rep =
Builder.CreateTrunc(Ctlz,
Builder.getInt32Ty(),
"ctlz.trunc");
4075 }
else if (IsNVVM &&
Name ==
"popc.ll") {