27 #include "llvm/IR/IntrinsicsAArch64.h"
28 #include "llvm/IR/IntrinsicsARM.h"
29 #include "llvm/IR/IntrinsicsX86.h"
46 Type *Arg0Type =
F->getFunctionType()->getParamType(0);
61 Type *LastArgType =
F->getFunctionType()->getParamType(
62 F->getFunctionType()->getNumParams() - 1);
77 if (
F->getReturnType()->isVectorTy())
91 if (
Name ==
"addcarryx.u32" ||
92 Name ==
"addcarryx.u64" ||
93 Name ==
"addcarry.u32" ||
94 Name ==
"addcarry.u64" ||
95 Name ==
"subborrow.u32" ||
96 Name ==
"subborrow.u64" ||
97 Name.startswith(
"sse2.padds.") ||
98 Name.startswith(
"sse2.psubs.") ||
99 Name.startswith(
"sse2.paddus.") ||
100 Name.startswith(
"sse2.psubus.") ||
101 Name.startswith(
"avx2.padds.") ||
102 Name.startswith(
"avx2.psubs.") ||
103 Name.startswith(
"avx2.paddus.") ||
104 Name.startswith(
"avx2.psubus.") ||
105 Name.startswith(
"avx512.padds.") ||
106 Name.startswith(
"avx512.psubs.") ||
107 Name.startswith(
"avx512.mask.padds.") ||
108 Name.startswith(
"avx512.mask.psubs.") ||
109 Name.startswith(
"avx512.mask.paddus.") ||
110 Name.startswith(
"avx512.mask.psubus.") ||
111 Name==
"ssse3.pabs.b.128" ||
112 Name==
"ssse3.pabs.w.128" ||
113 Name==
"ssse3.pabs.d.128" ||
114 Name.startswith(
"fma4.vfmadd.s") ||
115 Name.startswith(
"fma.vfmadd.") ||
116 Name.startswith(
"fma.vfmsub.") ||
117 Name.startswith(
"fma.vfmsubadd.") ||
118 Name.startswith(
"fma.vfnmadd.") ||
119 Name.startswith(
"fma.vfnmsub.") ||
120 Name.startswith(
"avx512.mask.vfmadd.") ||
121 Name.startswith(
"avx512.mask.vfnmadd.") ||
122 Name.startswith(
"avx512.mask.vfnmsub.") ||
123 Name.startswith(
"avx512.mask3.vfmadd.") ||
124 Name.startswith(
"avx512.maskz.vfmadd.") ||
125 Name.startswith(
"avx512.mask3.vfmsub.") ||
126 Name.startswith(
"avx512.mask3.vfnmsub.") ||
127 Name.startswith(
"avx512.mask.vfmaddsub.") ||
128 Name.startswith(
"avx512.maskz.vfmaddsub.") ||
129 Name.startswith(
"avx512.mask3.vfmaddsub.") ||
130 Name.startswith(
"avx512.mask3.vfmsubadd.") ||
131 Name.startswith(
"avx512.mask.shuf.i") ||
132 Name.startswith(
"avx512.mask.shuf.f") ||
133 Name.startswith(
"avx512.kunpck") ||
134 Name.startswith(
"avx2.pabs.") ||
135 Name.startswith(
"avx512.mask.pabs.") ||
136 Name.startswith(
"avx512.broadcastm") ||
137 Name ==
"sse.sqrt.ss" ||
138 Name ==
"sse2.sqrt.sd" ||
139 Name.startswith(
"avx512.mask.sqrt.p") ||
140 Name.startswith(
"avx.sqrt.p") ||
141 Name.startswith(
"sse2.sqrt.p") ||
142 Name.startswith(
"sse.sqrt.p") ||
143 Name.startswith(
"avx512.mask.pbroadcast") ||
144 Name.startswith(
"sse2.pcmpeq.") ||
145 Name.startswith(
"sse2.pcmpgt.") ||
146 Name.startswith(
"avx2.pcmpeq.") ||
147 Name.startswith(
"avx2.pcmpgt.") ||
148 Name.startswith(
"avx512.mask.pcmpeq.") ||
149 Name.startswith(
"avx512.mask.pcmpgt.") ||
150 Name.startswith(
"avx.vperm2f128.") ||
151 Name ==
"avx2.vperm2i128" ||
152 Name ==
"sse.add.ss" ||
153 Name ==
"sse2.add.sd" ||
154 Name ==
"sse.sub.ss" ||
155 Name ==
"sse2.sub.sd" ||
156 Name ==
"sse.mul.ss" ||
157 Name ==
"sse2.mul.sd" ||
158 Name ==
"sse.div.ss" ||
159 Name ==
"sse2.div.sd" ||
160 Name ==
"sse41.pmaxsb" ||
161 Name ==
"sse2.pmaxs.w" ||
162 Name ==
"sse41.pmaxsd" ||
163 Name ==
"sse2.pmaxu.b" ||
164 Name ==
"sse41.pmaxuw" ||
165 Name ==
"sse41.pmaxud" ||
166 Name ==
"sse41.pminsb" ||
167 Name ==
"sse2.pmins.w" ||
168 Name ==
"sse41.pminsd" ||
169 Name ==
"sse2.pminu.b" ||
170 Name ==
"sse41.pminuw" ||
171 Name ==
"sse41.pminud" ||
172 Name ==
"avx512.kand.w" ||
173 Name ==
"avx512.kandn.w" ||
174 Name ==
"avx512.knot.w" ||
175 Name ==
"avx512.kor.w" ||
176 Name ==
"avx512.kxor.w" ||
177 Name ==
"avx512.kxnor.w" ||
178 Name ==
"avx512.kortestc.w" ||
179 Name ==
"avx512.kortestz.w" ||
180 Name.startswith(
"avx512.mask.pshuf.b.") ||
181 Name.startswith(
"avx2.pmax") ||
182 Name.startswith(
"avx2.pmin") ||
183 Name.startswith(
"avx512.mask.pmax") ||
184 Name.startswith(
"avx512.mask.pmin") ||
185 Name.startswith(
"avx2.vbroadcast") ||
186 Name.startswith(
"avx2.pbroadcast") ||
187 Name.startswith(
"avx.vpermil.") ||
188 Name.startswith(
"sse2.pshuf") ||
189 Name.startswith(
"avx512.pbroadcast") ||
190 Name.startswith(
"avx512.mask.broadcast.s") ||
191 Name.startswith(
"avx512.mask.movddup") ||
192 Name.startswith(
"avx512.mask.movshdup") ||
193 Name.startswith(
"avx512.mask.movsldup") ||
194 Name.startswith(
"avx512.mask.pshuf.d.") ||
195 Name.startswith(
"avx512.mask.pshufl.w.") ||
196 Name.startswith(
"avx512.mask.pshufh.w.") ||
197 Name.startswith(
"avx512.mask.shuf.p") ||
198 Name.startswith(
"avx512.mask.vpermil.p") ||
199 Name.startswith(
"avx512.mask.perm.df.") ||
200 Name.startswith(
"avx512.mask.perm.di.") ||
201 Name.startswith(
"avx512.mask.punpckl") ||
202 Name.startswith(
"avx512.mask.punpckh") ||
203 Name.startswith(
"avx512.mask.unpckl.") ||
204 Name.startswith(
"avx512.mask.unpckh.") ||
205 Name.startswith(
"avx512.mask.pand.") ||
206 Name.startswith(
"avx512.mask.pandn.") ||
207 Name.startswith(
"avx512.mask.por.") ||
208 Name.startswith(
"avx512.mask.pxor.") ||
209 Name.startswith(
"avx512.mask.and.") ||
210 Name.startswith(
"avx512.mask.andn.") ||
211 Name.startswith(
"avx512.mask.or.") ||
212 Name.startswith(
"avx512.mask.xor.") ||
213 Name.startswith(
"avx512.mask.padd.") ||
214 Name.startswith(
"avx512.mask.psub.") ||
215 Name.startswith(
"avx512.mask.pmull.") ||
216 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
217 Name.startswith(
"avx512.mask.cvtudq2pd.") ||
218 Name.startswith(
"avx512.mask.cvtudq2ps.") ||
219 Name.startswith(
"avx512.mask.cvtqq2pd.") ||
220 Name.startswith(
"avx512.mask.cvtuqq2pd.") ||
221 Name.startswith(
"avx512.mask.cvtdq2ps.") ||
222 Name ==
"avx512.mask.vcvtph2ps.128" ||
223 Name ==
"avx512.mask.vcvtph2ps.256" ||
224 Name ==
"avx512.mask.cvtqq2ps.256" ||
225 Name ==
"avx512.mask.cvtqq2ps.512" ||
226 Name ==
"avx512.mask.cvtuqq2ps.256" ||
227 Name ==
"avx512.mask.cvtuqq2ps.512" ||
228 Name ==
"avx512.mask.cvtpd2dq.256" ||
229 Name ==
"avx512.mask.cvtpd2ps.256" ||
230 Name ==
"avx512.mask.cvttpd2dq.256" ||
231 Name ==
"avx512.mask.cvttps2dq.128" ||
232 Name ==
"avx512.mask.cvttps2dq.256" ||
233 Name ==
"avx512.mask.cvtps2pd.128" ||
234 Name ==
"avx512.mask.cvtps2pd.256" ||
235 Name ==
"avx512.cvtusi2sd" ||
236 Name.startswith(
"avx512.mask.permvar.") ||
237 Name ==
"sse2.pmulu.dq" ||
238 Name ==
"sse41.pmuldq" ||
239 Name ==
"avx2.pmulu.dq" ||
240 Name ==
"avx2.pmul.dq" ||
241 Name ==
"avx512.pmulu.dq.512" ||
242 Name ==
"avx512.pmul.dq.512" ||
243 Name.startswith(
"avx512.mask.pmul.dq.") ||
244 Name.startswith(
"avx512.mask.pmulu.dq.") ||
245 Name.startswith(
"avx512.mask.pmul.hr.sw.") ||
246 Name.startswith(
"avx512.mask.pmulh.w.") ||
247 Name.startswith(
"avx512.mask.pmulhu.w.") ||
248 Name.startswith(
"avx512.mask.pmaddw.d.") ||
249 Name.startswith(
"avx512.mask.pmaddubs.w.") ||
250 Name.startswith(
"avx512.mask.packsswb.") ||
251 Name.startswith(
"avx512.mask.packssdw.") ||
252 Name.startswith(
"avx512.mask.packuswb.") ||
253 Name.startswith(
"avx512.mask.packusdw.") ||
254 Name.startswith(
"avx512.mask.cmp.b") ||
255 Name.startswith(
"avx512.mask.cmp.d") ||
256 Name.startswith(
"avx512.mask.cmp.q") ||
257 Name.startswith(
"avx512.mask.cmp.w") ||
258 Name.startswith(
"avx512.cmp.p") ||
259 Name.startswith(
"avx512.mask.ucmp.") ||
260 Name.startswith(
"avx512.cvtb2mask.") ||
261 Name.startswith(
"avx512.cvtw2mask.") ||
262 Name.startswith(
"avx512.cvtd2mask.") ||
263 Name.startswith(
"avx512.cvtq2mask.") ||
264 Name.startswith(
"avx512.mask.vpermilvar.") ||
265 Name.startswith(
"avx512.mask.psll.d") ||
266 Name.startswith(
"avx512.mask.psll.q") ||
267 Name.startswith(
"avx512.mask.psll.w") ||
268 Name.startswith(
"avx512.mask.psra.d") ||
269 Name.startswith(
"avx512.mask.psra.q") ||
270 Name.startswith(
"avx512.mask.psra.w") ||
271 Name.startswith(
"avx512.mask.psrl.d") ||
272 Name.startswith(
"avx512.mask.psrl.q") ||
273 Name.startswith(
"avx512.mask.psrl.w") ||
274 Name.startswith(
"avx512.mask.pslli") ||
275 Name.startswith(
"avx512.mask.psrai") ||
276 Name.startswith(
"avx512.mask.psrli") ||
277 Name.startswith(
"avx512.mask.psllv") ||
278 Name.startswith(
"avx512.mask.psrav") ||
279 Name.startswith(
"avx512.mask.psrlv") ||
280 Name.startswith(
"sse41.pmovsx") ||
281 Name.startswith(
"sse41.pmovzx") ||
282 Name.startswith(
"avx2.pmovsx") ||
283 Name.startswith(
"avx2.pmovzx") ||
284 Name.startswith(
"avx512.mask.pmovsx") ||
285 Name.startswith(
"avx512.mask.pmovzx") ||
286 Name.startswith(
"avx512.mask.lzcnt.") ||
287 Name.startswith(
"avx512.mask.pternlog.") ||
288 Name.startswith(
"avx512.maskz.pternlog.") ||
289 Name.startswith(
"avx512.mask.vpmadd52") ||
290 Name.startswith(
"avx512.maskz.vpmadd52") ||
291 Name.startswith(
"avx512.mask.vpermi2var.") ||
292 Name.startswith(
"avx512.mask.vpermt2var.") ||
293 Name.startswith(
"avx512.maskz.vpermt2var.") ||
294 Name.startswith(
"avx512.mask.vpdpbusd.") ||
295 Name.startswith(
"avx512.maskz.vpdpbusd.") ||
296 Name.startswith(
"avx512.mask.vpdpbusds.") ||
297 Name.startswith(
"avx512.maskz.vpdpbusds.") ||
298 Name.startswith(
"avx512.mask.vpdpwssd.") ||
299 Name.startswith(
"avx512.maskz.vpdpwssd.") ||
300 Name.startswith(
"avx512.mask.vpdpwssds.") ||
301 Name.startswith(
"avx512.maskz.vpdpwssds.") ||
302 Name.startswith(
"avx512.mask.dbpsadbw.") ||
303 Name.startswith(
"avx512.mask.vpshld.") ||
304 Name.startswith(
"avx512.mask.vpshrd.") ||
305 Name.startswith(
"avx512.mask.vpshldv.") ||
306 Name.startswith(
"avx512.mask.vpshrdv.") ||
307 Name.startswith(
"avx512.maskz.vpshldv.") ||
308 Name.startswith(
"avx512.maskz.vpshrdv.") ||
309 Name.startswith(
"avx512.vpshld.") ||
310 Name.startswith(
"avx512.vpshrd.") ||
311 Name.startswith(
"avx512.mask.add.p") ||
312 Name.startswith(
"avx512.mask.sub.p") ||
313 Name.startswith(
"avx512.mask.mul.p") ||
314 Name.startswith(
"avx512.mask.div.p") ||
315 Name.startswith(
"avx512.mask.max.p") ||
316 Name.startswith(
"avx512.mask.min.p") ||
317 Name.startswith(
"avx512.mask.fpclass.p") ||
318 Name.startswith(
"avx512.mask.vpshufbitqmb.") ||
319 Name.startswith(
"avx512.mask.pmultishift.qb.") ||
320 Name.startswith(
"avx512.mask.conflict.") ||
321 Name ==
"avx512.mask.pmov.qd.256" ||
322 Name ==
"avx512.mask.pmov.qd.512" ||
323 Name ==
"avx512.mask.pmov.wb.256" ||
324 Name ==
"avx512.mask.pmov.wb.512" ||
325 Name ==
"sse.cvtsi2ss" ||
326 Name ==
"sse.cvtsi642ss" ||
327 Name ==
"sse2.cvtsi2sd" ||
328 Name ==
"sse2.cvtsi642sd" ||
329 Name ==
"sse2.cvtss2sd" ||
330 Name ==
"sse2.cvtdq2pd" ||
331 Name ==
"sse2.cvtdq2ps" ||
332 Name ==
"sse2.cvtps2pd" ||
333 Name ==
"avx.cvtdq2.pd.256" ||
334 Name ==
"avx.cvtdq2.ps.256" ||
335 Name ==
"avx.cvt.ps2.pd.256" ||
336 Name.startswith(
"vcvtph2ps.") ||
337 Name.startswith(
"avx.vinsertf128.") ||
338 Name ==
"avx2.vinserti128" ||
339 Name.startswith(
"avx512.mask.insert") ||
340 Name.startswith(
"avx.vextractf128.") ||
341 Name ==
"avx2.vextracti128" ||
342 Name.startswith(
"avx512.mask.vextract") ||
343 Name.startswith(
"sse4a.movnt.") ||
344 Name.startswith(
"avx.movnt.") ||
345 Name.startswith(
"avx512.storent.") ||
346 Name ==
"sse41.movntdqa" ||
347 Name ==
"avx2.movntdqa" ||
348 Name ==
"avx512.movntdqa" ||
349 Name ==
"sse2.storel.dq" ||
350 Name.startswith(
"sse.storeu.") ||
351 Name.startswith(
"sse2.storeu.") ||
352 Name.startswith(
"avx.storeu.") ||
353 Name.startswith(
"avx512.mask.storeu.") ||
354 Name.startswith(
"avx512.mask.store.p") ||
355 Name.startswith(
"avx512.mask.store.b.") ||
356 Name.startswith(
"avx512.mask.store.w.") ||
357 Name.startswith(
"avx512.mask.store.d.") ||
358 Name.startswith(
"avx512.mask.store.q.") ||
359 Name ==
"avx512.mask.store.ss" ||
360 Name.startswith(
"avx512.mask.loadu.") ||
361 Name.startswith(
"avx512.mask.load.") ||
362 Name.startswith(
"avx512.mask.expand.load.") ||
363 Name.startswith(
"avx512.mask.compress.store.") ||
364 Name.startswith(
"avx512.mask.expand.b") ||
365 Name.startswith(
"avx512.mask.expand.w") ||
366 Name.startswith(
"avx512.mask.expand.d") ||
367 Name.startswith(
"avx512.mask.expand.q") ||
368 Name.startswith(
"avx512.mask.expand.p") ||
369 Name.startswith(
"avx512.mask.compress.b") ||
370 Name.startswith(
"avx512.mask.compress.w") ||
371 Name.startswith(
"avx512.mask.compress.d") ||
372 Name.startswith(
"avx512.mask.compress.q") ||
373 Name.startswith(
"avx512.mask.compress.p") ||
374 Name ==
"sse42.crc32.64.8" ||
375 Name.startswith(
"avx.vbroadcast.s") ||
376 Name.startswith(
"avx512.vbroadcast.s") ||
377 Name.startswith(
"avx512.mask.palignr.") ||
378 Name.startswith(
"avx512.mask.valign.") ||
379 Name.startswith(
"sse2.psll.dq") ||
380 Name.startswith(
"sse2.psrl.dq") ||
381 Name.startswith(
"avx2.psll.dq") ||
382 Name.startswith(
"avx2.psrl.dq") ||
383 Name.startswith(
"avx512.psll.dq") ||
384 Name.startswith(
"avx512.psrl.dq") ||
385 Name ==
"sse41.pblendw" ||
386 Name.startswith(
"sse41.blendp") ||
387 Name.startswith(
"avx.blend.p") ||
388 Name ==
"avx2.pblendw" ||
389 Name.startswith(
"avx2.pblendd.") ||
390 Name.startswith(
"avx.vbroadcastf128") ||
391 Name ==
"avx2.vbroadcasti128" ||
392 Name.startswith(
"avx512.mask.broadcastf32x4.") ||
393 Name.startswith(
"avx512.mask.broadcastf64x2.") ||
394 Name.startswith(
"avx512.mask.broadcastf32x8.") ||
395 Name.startswith(
"avx512.mask.broadcastf64x4.") ||
396 Name.startswith(
"avx512.mask.broadcasti32x4.") ||
397 Name.startswith(
"avx512.mask.broadcasti64x2.") ||
398 Name.startswith(
"avx512.mask.broadcasti32x8.") ||
399 Name.startswith(
"avx512.mask.broadcasti64x4.") ||
400 Name ==
"xop.vpcmov" ||
401 Name ==
"xop.vpcmov.256" ||
402 Name.startswith(
"avx512.mask.move.s") ||
403 Name.startswith(
"avx512.cvtmask2") ||
404 Name.startswith(
"xop.vpcom") ||
405 Name.startswith(
"xop.vprot") ||
406 Name.startswith(
"avx512.prol") ||
407 Name.startswith(
"avx512.pror") ||
408 Name.startswith(
"avx512.mask.prorv.") ||
409 Name.startswith(
"avx512.mask.pror.") ||
410 Name.startswith(
"avx512.mask.prolv.") ||
411 Name.startswith(
"avx512.mask.prol.") ||
412 Name.startswith(
"avx512.ptestm") ||
413 Name.startswith(
"avx512.ptestnm") ||
414 Name.startswith(
"avx512.mask.pavg"))
423 if (!
Name.startswith(
"x86."))
433 if (
Name ==
"rdtscp") {
435 if (
F->getFunctionType()->getNumParams() == 0)
440 Intrinsic::x86_rdtscp);
445 if (
Name.startswith(
"sse41.ptest")) {
446 if (
Name.substr(11) ==
"c")
448 if (
Name.substr(11) ==
"z")
450 if (
Name.substr(11) ==
"nzc")
455 if (
Name ==
"sse41.insertps")
458 if (
Name ==
"sse41.dppd")
461 if (
Name ==
"sse41.dpps")
464 if (
Name ==
"sse41.mpsadbw")
467 if (
Name ==
"avx.dp.ps.256")
470 if (
Name ==
"avx2.mpsadbw")
473 if (
Name ==
"avx512.mask.cmp.pd.128")
476 if (
Name ==
"avx512.mask.cmp.pd.256")
479 if (
Name ==
"avx512.mask.cmp.pd.512")
482 if (
Name ==
"avx512.mask.cmp.ps.128")
485 if (
Name ==
"avx512.mask.cmp.ps.256")
488 if (
Name ==
"avx512.mask.cmp.ps.512")
493 if (
Name.startswith(
"xop.vfrcz.ss") &&
F->arg_size() == 2) {
496 Intrinsic::x86_xop_vfrcz_ss);
499 if (
Name.startswith(
"xop.vfrcz.sd") &&
F->arg_size() == 2) {
502 Intrinsic::x86_xop_vfrcz_sd);
506 if (
Name.startswith(
"xop.vpermil2")) {
507 auto Idx =
F->getFunctionType()->getParamType(2);
508 if (Idx->isFPOrFPVectorTy()) {
510 unsigned IdxSize = Idx->getPrimitiveSizeInBits();
511 unsigned EltSize = Idx->getScalarSizeInBits();
513 if (EltSize == 64 && IdxSize == 128)
514 Permil2ID = Intrinsic::x86_xop_vpermil2pd;
515 else if (EltSize == 32 && IdxSize == 128)
516 Permil2ID = Intrinsic::x86_xop_vpermil2ps;
517 else if (EltSize == 64 && IdxSize == 256)
518 Permil2ID = Intrinsic::x86_xop_vpermil2pd_256;
520 Permil2ID = Intrinsic::x86_xop_vpermil2ps_256;
526 if (
Name ==
"seh.recoverfp") {
535 assert(
F &&
"Illegal to upgrade a non-existent Function.");
539 if (
Name.size() <= 8 || !
Name.startswith(
"llvm."))
546 if (
Name.startswith(
"arm.rbit") ||
Name.startswith(
"aarch64.rbit")) {
548 F->arg_begin()->getType());
551 if (
Name.startswith(
"aarch64.neon.frintn")) {
553 F->arg_begin()->getType());
556 if (
Name.startswith(
"arm.neon.vclz")) {
558 F->arg_begin()->getType(),
566 "llvm.ctlz." +
Name.substr(14),
F->getParent());
569 if (
Name.startswith(
"arm.neon.vcnt")) {
571 F->arg_begin()->getType());
574 static const Regex vldRegex(
"^arm\\.neon\\.vld([1234]|[234]lane)\\.v[a-z0-9]*$");
576 auto fArgs =
F->getFunctionType()->params();
582 "llvm." +
Name +
".p0i8",
F->getParent());
585 static const Regex vstRegex(
"^arm\\.neon\\.vst([1234]|[234]lane)\\.v[a-z0-9]*$");
587 static const Intrinsic::ID StoreInts[] = {Intrinsic::arm_neon_vst1,
588 Intrinsic::arm_neon_vst2,
589 Intrinsic::arm_neon_vst3,
590 Intrinsic::arm_neon_vst4};
593 Intrinsic::arm_neon_vst2lane, Intrinsic::arm_neon_vst3lane,
594 Intrinsic::arm_neon_vst4lane
597 auto fArgs =
F->getFunctionType()->params();
598 Type *Tys[] = {fArgs[0], fArgs[1]};
601 StoreInts[fArgs.size() - 3], Tys);
604 StoreLaneInts[fArgs.size() - 5], Tys);
607 if (
Name ==
"aarch64.thread.pointer" ||
Name ==
"arm.thread.pointer") {
611 if (
Name.startswith(
"arm.neon.vqadds.")) {
613 F->arg_begin()->getType());
616 if (
Name.startswith(
"arm.neon.vqaddu.")) {
618 F->arg_begin()->getType());
621 if (
Name.startswith(
"arm.neon.vqsubs.")) {
623 F->arg_begin()->getType());
626 if (
Name.startswith(
"arm.neon.vqsubu.")) {
628 F->arg_begin()->getType());
631 if (
Name.startswith(
"aarch64.neon.addp")) {
632 if (
F->arg_size() != 2)
634 VectorType *Ty = dyn_cast<VectorType>(
F->getReturnType());
637 Intrinsic::aarch64_neon_faddp, Ty);
644 if ((
Name.startswith(
"arm.neon.bfdot.") ||
645 Name.startswith(
"aarch64.neon.bfdot.")) &&
646 Name.endswith(
"i8")) {
649 .
Cases(
"arm.neon.bfdot.v2f32.v8i8",
650 "arm.neon.bfdot.v4f32.v16i8",
651 Intrinsic::arm_neon_bfdot)
652 .
Cases(
"aarch64.neon.bfdot.v2f32.v8i8",
653 "aarch64.neon.bfdot.v4f32.v16i8",
654 Intrinsic::aarch64_neon_bfdot)
659 size_t OperandWidth =
F->getReturnType()->getPrimitiveSizeInBits();
660 assert((OperandWidth == 64 || OperandWidth == 128) &&
661 "Unexpected operand width");
663 std::array<Type *, 2> Tys {{
673 if ((
Name.startswith(
"arm.neon.bfm") ||
674 Name.startswith(
"aarch64.neon.bfm")) &&
675 Name.endswith(
".v4f32.v16i8")) {
678 .
Case(
"arm.neon.bfmmla.v4f32.v16i8",
679 Intrinsic::arm_neon_bfmmla)
680 .
Case(
"arm.neon.bfmlalb.v4f32.v16i8",
681 Intrinsic::arm_neon_bfmlalb)
682 .
Case(
"arm.neon.bfmlalt.v4f32.v16i8",
683 Intrinsic::arm_neon_bfmlalt)
684 .
Case(
"aarch64.neon.bfmmla.v4f32.v16i8",
685 Intrinsic::aarch64_neon_bfmmla)
686 .
Case(
"aarch64.neon.bfmlalb.v4f32.v16i8",
687 Intrinsic::aarch64_neon_bfmlalb)
688 .
Case(
"aarch64.neon.bfmlalt.v4f32.v16i8",
689 Intrinsic::aarch64_neon_bfmlalt)
694 std::array<Type *, 0> Tys;
702 if (
Name.startswith(
"ctlz.") &&
F->arg_size() == 1) {
705 F->arg_begin()->getType());
708 if (
Name.startswith(
"cttz.") &&
F->arg_size() == 1) {
711 F->arg_begin()->getType());
717 if (
Name ==
"dbg.value" &&
F->arg_size() == 4) {
726 static const Regex R(
"^experimental.vector.reduce.([a-z]+)\\.[a-z][0-9]+");
730 .
Case(
"add", Intrinsic::vector_reduce_add)
731 .
Case(
"mul", Intrinsic::vector_reduce_mul)
732 .
Case(
"and", Intrinsic::vector_reduce_and)
733 .
Case(
"or", Intrinsic::vector_reduce_or)
734 .
Case(
"xor", Intrinsic::vector_reduce_xor)
735 .
Case(
"smax", Intrinsic::vector_reduce_smax)
736 .
Case(
"smin", Intrinsic::vector_reduce_smin)
737 .
Case(
"umax", Intrinsic::vector_reduce_umax)
738 .
Case(
"umin", Intrinsic::vector_reduce_umin)
739 .
Case(
"fmax", Intrinsic::vector_reduce_fmax)
740 .
Case(
"fmin", Intrinsic::vector_reduce_fmin)
744 auto Args =
F->getFunctionType()->params();
750 "^experimental.vector.reduce.v2.([a-z]+)\\.[fi][0-9]+");
755 ID = Intrinsic::vector_reduce_fadd;
757 ID = Intrinsic::vector_reduce_fmul;
760 auto Args =
F->getFunctionType()->params();
770 bool IsLifetimeStart =
Name.startswith(
"lifetime.start");
771 if (IsLifetimeStart ||
Name.startswith(
"invariant.start")) {
773 Intrinsic::lifetime_start : Intrinsic::invariant_start;
774 auto Args =
F->getFunctionType()->params();
783 bool IsLifetimeEnd =
Name.startswith(
"lifetime.end");
784 if (IsLifetimeEnd ||
Name.startswith(
"invariant.end")) {
786 Intrinsic::lifetime_end : Intrinsic::invariant_end;
788 auto Args =
F->getFunctionType()->params();
789 Type* ObjectPtr[1] = {
Args[IsLifetimeEnd ? 1 : 2]};
796 if (
Name.startswith(
"invariant.group.barrier")) {
798 auto Args =
F->getFunctionType()->params();
802 Intrinsic::launder_invariant_group, ObjectPtr);
810 if (
Name.startswith(
"masked.load.")) {
811 Type *Tys[] = {
F->getReturnType(),
F->arg_begin()->getType() };
815 Intrinsic::masked_load,
820 if (
Name.startswith(
"masked.store.")) {
821 auto Args =
F->getFunctionType()->params();
826 Intrinsic::masked_store,
833 if (
Name.startswith(
"masked.gather.")) {
834 Type *Tys[] = {
F->getReturnType(),
F->arg_begin()->getType()};
838 Intrinsic::masked_gather, Tys);
842 if (
Name.startswith(
"masked.scatter.")) {
843 auto Args =
F->getFunctionType()->params();
848 Intrinsic::masked_scatter, Tys);
855 if (
Name.startswith(
"memcpy.") &&
F->arg_size() == 5) {
863 if (
Name.startswith(
"memmove.") &&
F->arg_size() == 5) {
871 if (
Name.startswith(
"memset.") &&
F->arg_size() == 5) {
874 const auto *FT =
F->getFunctionType();
875 Type *ParamTypes[2] = {
886 if (
Name.startswith(
"nvvm.")) {
891 .
Cases(
"brev32",
"brev64", Intrinsic::bitreverse)
892 .
Case(
"clz.i", Intrinsic::ctlz)
893 .
Case(
"popc.i", Intrinsic::ctpop)
897 {F->getReturnType()});
906 .
Cases(
"abs.i",
"abs.ll",
true)
907 .
Cases(
"clz.ll",
"popc.ll",
"h2f",
true)
908 .
Cases(
"max.i",
"max.ll",
"max.ui",
"max.ull",
true)
909 .
Cases(
"min.i",
"min.ll",
"min.ui",
"min.ull",
true)
923 if (
Name.startswith(
"objectsize.")) {
924 Type *Tys[2] = {
F->getReturnType(),
F->arg_begin()->getType() };
925 if (
F->arg_size() == 2 ||
F->arg_size() == 3 ||
936 if (
Name ==
"prefetch") {
938 Type *Tys[] = {
F->arg_begin()->getType()};
945 }
else if (
Name.startswith(
"ptr.annotation.") &&
F->arg_size() == 4) {
948 Intrinsic::ptr_annotation,
949 F->arg_begin()->getType());
955 if (
Name ==
"stackprotectorcheck") {
962 if (
Name ==
"var.annotation" &&
F->arg_size() == 4) {
965 Intrinsic::var_annotation);
977 if (Result !=
None) {
978 NewFn = Result.getValue();
992 assert(
F != NewFn &&
"Intrinsic function upgraded to the same function");
1004 GV->
getName() ==
"llvm.global_dtors")) ||
1019 unsigned N =
Init->getNumOperands();
1020 std::vector<Constant *> NewCtors(
N);
1021 for (
unsigned i = 0;
i !=
N; ++
i) {
1022 auto Ctor = cast<Constant>(
Init->getOperand(
i));
1024 EltTy, Ctor->getAggregateElement(0u), Ctor->getAggregateElement(1),
1037 auto *ResultTy = cast<FixedVectorType>(
Op->getType());
1038 unsigned NumElts = ResultTy->getNumElements() * 8;
1052 for (
unsigned l = 0;
l != NumElts;
l += 16)
1053 for (
unsigned i = 0;
i != 16; ++
i) {
1054 unsigned Idx = NumElts +
i -
Shift;
1056 Idx -= NumElts - 16;
1057 Idxs[
l +
i] = Idx +
l;
1064 return Builder.CreateBitCast(Res, ResultTy,
"cast");
1071 auto *ResultTy = cast<FixedVectorType>(
Op->getType());
1072 unsigned NumElts = ResultTy->getNumElements() * 8;
1086 for (
unsigned l = 0;
l != NumElts;
l += 16)
1087 for (
unsigned i = 0;
i != 16; ++
i) {
1088 unsigned Idx =
i +
Shift;
1090 Idx += NumElts - 16;
1091 Idxs[
l +
i] = Idx +
l;
1098 return Builder.CreateBitCast(Res, ResultTy,
"cast");
1105 Builder.getInt1Ty(), cast<IntegerType>(
Mask->getType())->getBitWidth());
1112 for (
unsigned i = 0;
i != NumElts; ++
i)
1124 if (
const auto *
C = dyn_cast<Constant>(
Mask))
1125 if (
C->isAllOnesValue())
1129 cast<FixedVectorType>(Op0->
getType())->getNumElements());
1136 if (
const auto *
C = dyn_cast<Constant>(
Mask))
1137 if (
C->isAllOnesValue())
1141 Mask->getType()->getIntegerBitWidth());
1154 unsigned ShiftVal = cast<llvm::ConstantInt>(
Shift)->getZExtValue();
1156 unsigned NumElts = cast<FixedVectorType>(Op0->
getType())->getNumElements();
1157 assert((IsVALIGN || NumElts % 16 == 0) &&
"Illegal NumElts for PALIGNR!");
1158 assert((!IsVALIGN || NumElts <= 16) &&
"NumElts too large for VALIGN!");
1163 ShiftVal &= (NumElts - 1);
1172 if (ShiftVal > 16) {
1180 for (
unsigned l = 0;
l < NumElts;
l += 16) {
1181 for (
unsigned i = 0;
i != 16; ++
i) {
1182 unsigned Idx = ShiftVal +
i;
1183 if (!IsVALIGN && Idx >= 16)
1184 Idx += NumElts - 16;
1185 Indices[
l +
i] = Idx +
l;
1197 bool ZeroMask,
bool IndexForm) {
1203 if (VecWidth == 128 && EltWidth == 32 && IsFloat)
1204 IID = Intrinsic::x86_avx512_vpermi2var_ps_128;
1205 else if (VecWidth == 128 && EltWidth == 32 && !IsFloat)
1206 IID = Intrinsic::x86_avx512_vpermi2var_d_128;
1207 else if (VecWidth == 128 && EltWidth == 64 && IsFloat)
1208 IID = Intrinsic::x86_avx512_vpermi2var_pd_128;
1209 else if (VecWidth == 128 && EltWidth == 64 && !IsFloat)
1210 IID = Intrinsic::x86_avx512_vpermi2var_q_128;
1211 else if (VecWidth == 256 && EltWidth == 32 && IsFloat)
1212 IID = Intrinsic::x86_avx512_vpermi2var_ps_256;
1213 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
1214 IID = Intrinsic::x86_avx512_vpermi2var_d_256;
1215 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
1216 IID = Intrinsic::x86_avx512_vpermi2var_pd_256;
1217 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
1218 IID = Intrinsic::x86_avx512_vpermi2var_q_256;
1219 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
1220 IID = Intrinsic::x86_avx512_vpermi2var_ps_512;
1221 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
1222 IID = Intrinsic::x86_avx512_vpermi2var_d_512;
1223 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
1224 IID = Intrinsic::x86_avx512_vpermi2var_pd_512;
1225 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
1226 IID = Intrinsic::x86_avx512_vpermi2var_q_512;
1227 else if (VecWidth == 128 && EltWidth == 16)
1228 IID = Intrinsic::x86_avx512_vpermi2var_hi_128;
1229 else if (VecWidth == 256 && EltWidth == 16)
1230 IID = Intrinsic::x86_avx512_vpermi2var_hi_256;
1231 else if (VecWidth == 512 && EltWidth == 16)
1232 IID = Intrinsic::x86_avx512_vpermi2var_hi_512;
1233 else if (VecWidth == 128 && EltWidth == 8)
1234 IID = Intrinsic::x86_avx512_vpermi2var_qi_128;
1235 else if (VecWidth == 256 && EltWidth == 8)
1236 IID = Intrinsic::x86_avx512_vpermi2var_qi_256;
1237 else if (VecWidth == 512 && EltWidth == 8)
1238 IID = Intrinsic::x86_avx512_vpermi2var_qi_512;
1274 bool IsRotateRight) {
1283 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
1285 Amt =
Builder.CreateVectorSplat(NumElts, Amt);
1288 Intrinsic::ID IID = IsRotateRight ? Intrinsic::fshr : Intrinsic::fshl;
1290 Value *Res =
Builder.CreateCall(Intrin, {Src, Src, Amt});
1340 bool IsShiftRight,
bool ZeroMask) {
1353 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
1355 Amt =
Builder.CreateVectorSplat(NumElts, Amt);
1358 Intrinsic::ID IID = IsShiftRight ? Intrinsic::fshr : Intrinsic::fshl;
1360 Value *Res =
Builder.CreateCall(Intrin, {Op0, Op1, Amt});
1377 Ptr =
Builder.CreateBitCast(Ptr,
1379 const Align Alignment =
1381 ?
Align(
Data->getType()->getPrimitiveSizeInBits().getFixedSize() / 8)
1385 if (
const auto *
C = dyn_cast<Constant>(
Mask))
1386 if (
C->isAllOnesValue())
1387 return Builder.CreateAlignedStore(
Data, Ptr, Alignment);
1390 unsigned NumElts = cast<FixedVectorType>(
Data->getType())->getNumElements();
1401 const Align Alignment =
1408 if (
const auto *
C = dyn_cast<Constant>(
Mask))
1409 if (
C->isAllOnesValue())
1410 return Builder.CreateAlignedLoad(ValTy, Ptr, Alignment);
1414 cast<FixedVectorType>(Passthru->
getType())->getNumElements();
1416 return Builder.CreateMaskedLoad(Ptr, Alignment,
Mask, Passthru);
1439 LHS =
Builder.CreateShl(LHS, ShiftAmt);
1440 LHS =
Builder.CreateAShr(LHS, ShiftAmt);
1441 RHS =
Builder.CreateShl(RHS, ShiftAmt);
1442 RHS =
Builder.CreateAShr(RHS, ShiftAmt);
1461 unsigned NumElts = cast<FixedVectorType>(Vec->
getType())->getNumElements();
1463 const auto *
C = dyn_cast<Constant>(
Mask);
1464 if (!
C || !
C->isAllOnesValue())
1470 for (
unsigned i = 0;
i != NumElts; ++
i)
1472 for (
unsigned i = NumElts;
i != 8; ++
i)
1473 Indices[
i] = NumElts +
i % NumElts;
1474 Vec =
Builder.CreateShuffleVector(Vec,
1482 unsigned CC,
bool Signed) {
1484 unsigned NumElts = cast<FixedVectorType>(Op0->
getType())->getNumElements();
1490 }
else if (CC == 7) {
1529 Value* Extract1 =
Builder.CreateExtractElement(
B, (uint64_t)0);
1530 Value* Extract2 =
Builder.CreateExtractElement(Src, (uint64_t)0);
1539 unsigned NumElts = cast<FixedVectorType>(CI.
getType())->getNumElements();
1541 return Builder.CreateSExt(
Mask, ReturnOp,
"vpmovm2");
1552 if (
Name.startswith(
"max.p")) {
1553 if (VecWidth == 128 && EltWidth == 32)
1554 IID = Intrinsic::x86_sse_max_ps;
1555 else if (VecWidth == 128 && EltWidth == 64)
1556 IID = Intrinsic::x86_sse2_max_pd;
1557 else if (VecWidth == 256 && EltWidth == 32)
1558 IID = Intrinsic::x86_avx_max_ps_256;
1559 else if (VecWidth == 256 && EltWidth == 64)
1560 IID = Intrinsic::x86_avx_max_pd_256;
1563 }
else if (
Name.startswith(
"min.p")) {
1564 if (VecWidth == 128 && EltWidth == 32)
1565 IID = Intrinsic::x86_sse_min_ps;
1566 else if (VecWidth == 128 && EltWidth == 64)
1567 IID = Intrinsic::x86_sse2_min_pd;
1568 else if (VecWidth == 256 && EltWidth == 32)
1569 IID = Intrinsic::x86_avx_min_ps_256;
1570 else if (VecWidth == 256 && EltWidth == 64)
1571 IID = Intrinsic::x86_avx_min_pd_256;
1574 }
else if (
Name.startswith(
"pshuf.b.")) {
1575 if (VecWidth == 128)
1576 IID = Intrinsic::x86_ssse3_pshuf_b_128;
1577 else if (VecWidth == 256)
1578 IID = Intrinsic::x86_avx2_pshuf_b;
1579 else if (VecWidth == 512)
1580 IID = Intrinsic::x86_avx512_pshuf_b_512;
1583 }
else if (
Name.startswith(
"pmul.hr.sw.")) {
1584 if (VecWidth == 128)
1585 IID = Intrinsic::x86_ssse3_pmul_hr_sw_128;
1586 else if (VecWidth == 256)
1587 IID = Intrinsic::x86_avx2_pmul_hr_sw;
1588 else if (VecWidth == 512)
1589 IID = Intrinsic::x86_avx512_pmul_hr_sw_512;
1592 }
else if (
Name.startswith(
"pmulh.w.")) {
1593 if (VecWidth == 128)
1594 IID = Intrinsic::x86_sse2_pmulh_w;
1595 else if (VecWidth == 256)
1596 IID = Intrinsic::x86_avx2_pmulh_w;
1597 else if (VecWidth == 512)
1598 IID = Intrinsic::x86_avx512_pmulh_w_512;
1601 }
else if (
Name.startswith(
"pmulhu.w.")) {
1602 if (VecWidth == 128)
1603 IID = Intrinsic::x86_sse2_pmulhu_w;
1604 else if (VecWidth == 256)
1605 IID = Intrinsic::x86_avx2_pmulhu_w;
1606 else if (VecWidth == 512)
1607 IID = Intrinsic::x86_avx512_pmulhu_w_512;
1610 }
else if (
Name.startswith(
"pmaddw.d.")) {
1611 if (VecWidth == 128)
1612 IID = Intrinsic::x86_sse2_pmadd_wd;
1613 else if (VecWidth == 256)
1614 IID = Intrinsic::x86_avx2_pmadd_wd;
1615 else if (VecWidth == 512)
1616 IID = Intrinsic::x86_avx512_pmaddw_d_512;
1619 }
else if (
Name.startswith(
"pmaddubs.w.")) {
1620 if (VecWidth == 128)
1621 IID = Intrinsic::x86_ssse3_pmadd_ub_sw_128;
1622 else if (VecWidth == 256)
1623 IID = Intrinsic::x86_avx2_pmadd_ub_sw;
1624 else if (VecWidth == 512)
1625 IID = Intrinsic::x86_avx512_pmaddubs_w_512;
1628 }
else if (
Name.startswith(
"packsswb.")) {
1629 if (VecWidth == 128)
1630 IID = Intrinsic::x86_sse2_packsswb_128;
1631 else if (VecWidth == 256)
1632 IID = Intrinsic::x86_avx2_packsswb;
1633 else if (VecWidth == 512)
1634 IID = Intrinsic::x86_avx512_packsswb_512;
1637 }
else if (
Name.startswith(
"packssdw.")) {
1638 if (VecWidth == 128)
1639 IID = Intrinsic::x86_sse2_packssdw_128;
1640 else if (VecWidth == 256)
1641 IID = Intrinsic::x86_avx2_packssdw;
1642 else if (VecWidth == 512)
1643 IID = Intrinsic::x86_avx512_packssdw_512;
1646 }
else if (
Name.startswith(
"packuswb.")) {
1647 if (VecWidth == 128)
1648 IID = Intrinsic::x86_sse2_packuswb_128;
1649 else if (VecWidth == 256)
1650 IID = Intrinsic::x86_avx2_packuswb;
1651 else if (VecWidth == 512)
1652 IID = Intrinsic::x86_avx512_packuswb_512;
1655 }
else if (
Name.startswith(
"packusdw.")) {
1656 if (VecWidth == 128)
1657 IID = Intrinsic::x86_sse41_packusdw;
1658 else if (VecWidth == 256)
1659 IID = Intrinsic::x86_avx2_packusdw;
1660 else if (VecWidth == 512)
1661 IID = Intrinsic::x86_avx512_packusdw_512;
1664 }
else if (
Name.startswith(
"vpermilvar.")) {
1665 if (VecWidth == 128 && EltWidth == 32)
1666 IID = Intrinsic::x86_avx_vpermilvar_ps;
1667 else if (VecWidth == 128 && EltWidth == 64)
1668 IID = Intrinsic::x86_avx_vpermilvar_pd;
1669 else if (VecWidth == 256 && EltWidth == 32)
1670 IID = Intrinsic::x86_avx_vpermilvar_ps_256;
1671 else if (VecWidth == 256 && EltWidth == 64)
1672 IID = Intrinsic::x86_avx_vpermilvar_pd_256;
1673 else if (VecWidth == 512 && EltWidth == 32)
1674 IID = Intrinsic::x86_avx512_vpermilvar_ps_512;
1675 else if (VecWidth == 512 && EltWidth == 64)
1676 IID = Intrinsic::x86_avx512_vpermilvar_pd_512;
1679 }
else if (
Name ==
"cvtpd2dq.256") {
1680 IID = Intrinsic::x86_avx_cvt_pd2dq_256;
1681 }
else if (
Name ==
"cvtpd2ps.256") {
1682 IID = Intrinsic::x86_avx_cvt_pd2_ps_256;
1683 }
else if (
Name ==
"cvttpd2dq.256") {
1684 IID = Intrinsic::x86_avx_cvtt_pd2dq_256;
1685 }
else if (
Name ==
"cvttps2dq.128") {
1686 IID = Intrinsic::x86_sse2_cvttps2dq;
1687 }
else if (
Name ==
"cvttps2dq.256") {
1688 IID = Intrinsic::x86_avx_cvtt_ps2dq_256;
1689 }
else if (
Name.startswith(
"permvar.")) {
1691 if (VecWidth == 256 && EltWidth == 32 && IsFloat)
1692 IID = Intrinsic::x86_avx2_permps;
1693 else if (VecWidth == 256 && EltWidth == 32 && !IsFloat)
1694 IID = Intrinsic::x86_avx2_permd;
1695 else if (VecWidth == 256 && EltWidth == 64 && IsFloat)
1696 IID = Intrinsic::x86_avx512_permvar_df_256;
1697 else if (VecWidth == 256 && EltWidth == 64 && !IsFloat)
1698 IID = Intrinsic::x86_avx512_permvar_di_256;
1699 else if (VecWidth == 512 && EltWidth == 32 && IsFloat)
1700 IID = Intrinsic::x86_avx512_permvar_sf_512;
1701 else if (VecWidth == 512 && EltWidth == 32 && !IsFloat)
1702 IID = Intrinsic::x86_avx512_permvar_si_512;
1703 else if (VecWidth == 512 && EltWidth == 64 && IsFloat)
1704 IID = Intrinsic::x86_avx512_permvar_df_512;
1705 else if (VecWidth == 512 && EltWidth == 64 && !IsFloat)
1706 IID = Intrinsic::x86_avx512_permvar_di_512;
1707 else if (VecWidth == 128 && EltWidth == 16)
1708 IID = Intrinsic::x86_avx512_permvar_hi_128;
1709 else if (VecWidth == 256 && EltWidth == 16)
1710 IID = Intrinsic::x86_avx512_permvar_hi_256;
1711 else if (VecWidth == 512 && EltWidth == 16)
1712 IID = Intrinsic::x86_avx512_permvar_hi_512;
1713 else if (VecWidth == 128 && EltWidth == 8)
1714 IID = Intrinsic::x86_avx512_permvar_qi_128;
1715 else if (VecWidth == 256 && EltWidth == 8)
1716 IID = Intrinsic::x86_avx512_permvar_qi_256;
1717 else if (VecWidth == 512 && EltWidth == 8)
1718 IID = Intrinsic::x86_avx512_permvar_qi_512;
1721 }
else if (
Name.startswith(
"dbpsadbw.")) {
1722 if (VecWidth == 128)
1723 IID = Intrinsic::x86_avx512_dbpsadbw_128;
1724 else if (VecWidth == 256)
1725 IID = Intrinsic::x86_avx512_dbpsadbw_256;
1726 else if (VecWidth == 512)
1727 IID = Intrinsic::x86_avx512_dbpsadbw_512;
1730 }
else if (
Name.startswith(
"pmultishift.qb.")) {
1731 if (VecWidth == 128)
1732 IID = Intrinsic::x86_avx512_pmultishift_qb_128;
1733 else if (VecWidth == 256)
1734 IID = Intrinsic::x86_avx512_pmultishift_qb_256;
1735 else if (VecWidth == 512)
1736 IID = Intrinsic::x86_avx512_pmultishift_qb_512;
1739 }
else if (
Name.startswith(
"conflict.")) {
1740 if (
Name[9] ==
'd' && VecWidth == 128)
1741 IID = Intrinsic::x86_avx512_conflict_d_128;
1742 else if (
Name[9] ==
'd' && VecWidth == 256)
1743 IID = Intrinsic::x86_avx512_conflict_d_256;
1744 else if (
Name[9] ==
'd' && VecWidth == 512)
1745 IID = Intrinsic::x86_avx512_conflict_d_512;
1746 else if (
Name[9] ==
'q' && VecWidth == 128)
1747 IID = Intrinsic::x86_avx512_conflict_q_128;
1748 else if (
Name[9] ==
'q' && VecWidth == 256)
1749 IID = Intrinsic::x86_avx512_conflict_q_256;
1750 else if (
Name[9] ==
'q' && VecWidth == 512)
1751 IID = Intrinsic::x86_avx512_conflict_q_512;
1754 }
else if (
Name.startswith(
"pavg.")) {
1755 if (
Name[5] ==
'b' && VecWidth == 128)
1756 IID = Intrinsic::x86_sse2_pavg_b;
1757 else if (
Name[5] ==
'b' && VecWidth == 256)
1758 IID = Intrinsic::x86_avx2_pavg_b;
1759 else if (
Name[5] ==
'b' && VecWidth == 512)
1760 IID = Intrinsic::x86_avx512_pavg_b_512;
1761 else if (
Name[5] ==
'w' && VecWidth == 128)
1762 IID = Intrinsic::x86_sse2_pavg_w;
1763 else if (
Name[5] ==
'w' && VecWidth == 256)
1764 IID = Intrinsic::x86_avx2_pavg_w;
1765 else if (
Name[5] ==
'w' && VecWidth == 512)
1766 IID = Intrinsic::x86_avx512_pavg_w_512;
1788 if (AsmStr->find(
"mov\tfp") == 0 &&
1789 AsmStr->find(
"objc_retainAutoreleaseReturnValue") != std::string::npos &&
1790 (Pos = AsmStr->find(
"# marker")) != std::string::npos) {
1791 AsmStr->replace(Pos, 1,
";");
1803 assert(
F &&
"Intrinsic call is not direct?");
1809 assert(
Name.startswith(
"llvm.") &&
"Intrinsic doesn't start with 'llvm.'");
1812 bool IsX86 =
Name.startswith(
"x86.");
1815 bool IsNVVM =
Name.startswith(
"nvvm.");
1819 if (IsX86 &&
Name.startswith(
"sse4a.movnt.")) {
1831 Type *SrcEltTy = cast<VectorType>(Arg1->
getType())->getElementType();
1835 Builder.CreateExtractElement(Arg1, (uint64_t)0,
"extractelement");
1838 SI->setMetadata(
M->getMDKindID(
"nontemporal"), Node);
1845 if (IsX86 && (
Name.startswith(
"avx.movnt.") ||
1846 Name.startswith(
"avx512.storent."))) {
1863 SI->setMetadata(
M->getMDKindID(
"nontemporal"), Node);
1870 if (IsX86 &&
Name ==
"sse2.storel.dq") {
1875 Value *BC0 =
Builder.CreateBitCast(Arg1, NewVecTy,
"cast");
1876 Value *Elt =
Builder.CreateExtractElement(BC0, (uint64_t)0);
1887 if (IsX86 && (
Name.startswith(
"sse.storeu.") ||
1888 Name.startswith(
"sse2.storeu.") ||
1889 Name.startswith(
"avx.storeu."))) {
1893 Arg0 =
Builder.CreateBitCast(Arg0,
1903 if (IsX86 &&
Name ==
"avx512.mask.store.ss") {
1913 if (IsX86 && (
Name.startswith(
"avx512.mask.store"))) {
1915 bool Aligned =
Name[17] !=
'u';
1926 if (IsX86 && (
Name.startswith(
"sse2.pcmp") ||
1927 Name.startswith(
"avx2.pcmp"))) {
1929 bool CmpEq =
Name[9] ==
'e';
1933 }
else if (IsX86 && (
Name.startswith(
"avx512.broadcastm"))) {
1940 Rep =
Builder.CreateVectorSplat(NumElts, Rep);
1941 }
else if (IsX86 && (
Name ==
"sse.sqrt.ss" ||
1942 Name ==
"sse2.sqrt.sd")) {
1944 Value *Elt0 =
Builder.CreateExtractElement(Vec, (uint64_t)0);
1946 Intrinsic::sqrt, Elt0->
getType());
1948 Rep =
Builder.CreateInsertElement(Vec, Elt0, (uint64_t)0);
1949 }
else if (IsX86 && (
Name.startswith(
"avx.sqrt.p") ||
1950 Name.startswith(
"sse2.sqrt.p") ||
1951 Name.startswith(
"sse.sqrt.p"))) {
1955 {CI->getArgOperand(0)});
1956 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.sqrt.p"))) {
1959 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
1961 : Intrinsic::x86_avx512_sqrt_pd_512;
1970 {CI->getArgOperand(0)});
1974 }
else if (IsX86 && (
Name.startswith(
"avx512.ptestm") ||
1975 Name.startswith(
"avx512.ptestnm"))) {
1979 Rep =
Builder.CreateAnd(Op0, Op1);
1984 Rep =
Builder.CreateICmp(Pred, Rep, Zero);
1986 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.pbroadcast"))){
1992 }
else if (IsX86 && (
Name.startswith(
"avx512.kunpck"))) {
1997 for (
unsigned i = 0;
i != NumElts; ++
i)
2002 LHS =
Builder.CreateShuffleVector(LHS, LHS,
2004 RHS =
Builder.CreateShuffleVector(RHS, RHS,
2008 Rep =
Builder.CreateShuffleVector(RHS, LHS,
2011 }
else if (IsX86 &&
Name ==
"avx512.kand.w") {
2014 Rep =
Builder.CreateAnd(LHS, RHS);
2016 }
else if (IsX86 &&
Name ==
"avx512.kandn.w") {
2020 Rep =
Builder.CreateAnd(LHS, RHS);
2022 }
else if (IsX86 &&
Name ==
"avx512.kor.w") {
2025 Rep =
Builder.CreateOr(LHS, RHS);
2027 }
else if (IsX86 &&
Name ==
"avx512.kxor.w") {
2030 Rep =
Builder.CreateXor(LHS, RHS);
2032 }
else if (IsX86 &&
Name ==
"avx512.kxnor.w") {
2036 Rep =
Builder.CreateXor(LHS, RHS);
2038 }
else if (IsX86 &&
Name ==
"avx512.knot.w") {
2043 (
Name ==
"avx512.kortestz.w" ||
Name ==
"avx512.kortestc.w")) {
2046 Rep =
Builder.CreateOr(LHS, RHS);
2049 if (
Name[14] ==
'c')
2053 Rep =
Builder.CreateICmpEQ(Rep,
C);
2055 }
else if (IsX86 && (
Name ==
"sse.add.ss" ||
Name ==
"sse2.add.sd" ||
2056 Name ==
"sse.sub.ss" ||
Name ==
"sse2.sub.sd" ||
2057 Name ==
"sse.mul.ss" ||
Name ==
"sse2.mul.sd" ||
2058 Name ==
"sse.div.ss" ||
Name ==
"sse2.div.sd")) {
2065 if (
Name.contains(
".add."))
2066 EltOp =
Builder.CreateFAdd(Elt0, Elt1);
2067 else if (
Name.contains(
".sub."))
2068 EltOp =
Builder.CreateFSub(Elt0, Elt1);
2069 else if (
Name.contains(
".mul."))
2070 EltOp =
Builder.CreateFMul(Elt0, Elt1);
2072 EltOp =
Builder.CreateFDiv(Elt0, Elt1);
2075 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.pcmp")) {
2077 bool CmpEq =
Name[16] ==
'e';
2079 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.vpshufbitqmb.")) {
2085 case 128: IID = Intrinsic::x86_avx512_vpshufbitqmb_128;
break;
2086 case 256: IID = Intrinsic::x86_avx512_vpshufbitqmb_256;
break;
2087 case 512: IID = Intrinsic::x86_avx512_vpshufbitqmb_512;
break;
2091 { CI->getOperand(0), CI->getArgOperand(1) });
2093 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.fpclass.p")) {
2098 if (VecWidth == 128 && EltWidth == 32)
2099 IID = Intrinsic::x86_avx512_fpclass_ps_128;
2100 else if (VecWidth == 256 && EltWidth == 32)
2101 IID = Intrinsic::x86_avx512_fpclass_ps_256;
2102 else if (VecWidth == 512 && EltWidth == 32)
2103 IID = Intrinsic::x86_avx512_fpclass_ps_512;
2104 else if (VecWidth == 128 && EltWidth == 64)
2105 IID = Intrinsic::x86_avx512_fpclass_pd_128;
2106 else if (VecWidth == 256 && EltWidth == 64)
2107 IID = Intrinsic::x86_avx512_fpclass_pd_256;
2108 else if (VecWidth == 512 && EltWidth == 64)
2109 IID = Intrinsic::x86_avx512_fpclass_pd_512;
2114 { CI->getOperand(0), CI->getArgOperand(1) });
2116 }
else if (IsX86 &&
Name.startswith(
"avx512.cmp.p")) {
2123 if (VecWidth == 128 && EltWidth == 32)
2124 IID = Intrinsic::x86_avx512_mask_cmp_ps_128;
2125 else if (VecWidth == 256 && EltWidth == 32)
2126 IID = Intrinsic::x86_avx512_mask_cmp_ps_256;
2127 else if (VecWidth == 512 && EltWidth == 32)
2128 IID = Intrinsic::x86_avx512_mask_cmp_ps_512;
2129 else if (VecWidth == 128 && EltWidth == 64)
2130 IID = Intrinsic::x86_avx512_mask_cmp_pd_128;
2131 else if (VecWidth == 256 && EltWidth == 64)
2132 IID = Intrinsic::x86_avx512_mask_cmp_pd_256;
2133 else if (VecWidth == 512 && EltWidth == 64)
2134 IID = Intrinsic::x86_avx512_mask_cmp_pd_512;
2139 if (VecWidth == 512)
2145 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.cmp.")) {
2147 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2149 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.ucmp.")) {
2150 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2152 }
else if (IsX86 && (
Name.startswith(
"avx512.cvtb2mask.") ||
2153 Name.startswith(
"avx512.cvtw2mask.") ||
2154 Name.startswith(
"avx512.cvtd2mask.") ||
2155 Name.startswith(
"avx512.cvtq2mask."))) {
2160 }
else if(IsX86 && (
Name ==
"ssse3.pabs.b.128" ||
2161 Name ==
"ssse3.pabs.w.128" ||
2162 Name ==
"ssse3.pabs.d.128" ||
2163 Name.startswith(
"avx2.pabs") ||
2164 Name.startswith(
"avx512.mask.pabs"))) {
2166 }
else if (IsX86 && (
Name ==
"sse41.pmaxsb" ||
2167 Name ==
"sse2.pmaxs.w" ||
2168 Name ==
"sse41.pmaxsd" ||
2169 Name.startswith(
"avx2.pmaxs") ||
2170 Name.startswith(
"avx512.mask.pmaxs"))) {
2172 }
else if (IsX86 && (
Name ==
"sse2.pmaxu.b" ||
2173 Name ==
"sse41.pmaxuw" ||
2174 Name ==
"sse41.pmaxud" ||
2175 Name.startswith(
"avx2.pmaxu") ||
2176 Name.startswith(
"avx512.mask.pmaxu"))) {
2178 }
else if (IsX86 && (
Name ==
"sse41.pminsb" ||
2179 Name ==
"sse2.pmins.w" ||
2180 Name ==
"sse41.pminsd" ||
2181 Name.startswith(
"avx2.pmins") ||
2182 Name.startswith(
"avx512.mask.pmins"))) {
2184 }
else if (IsX86 && (
Name ==
"sse2.pminu.b" ||
2185 Name ==
"sse41.pminuw" ||
2186 Name ==
"sse41.pminud" ||
2187 Name.startswith(
"avx2.pminu") ||
2188 Name.startswith(
"avx512.mask.pminu"))) {
2190 }
else if (IsX86 && (
Name ==
"sse2.pmulu.dq" ||
2191 Name ==
"avx2.pmulu.dq" ||
2192 Name ==
"avx512.pmulu.dq.512" ||
2193 Name.startswith(
"avx512.mask.pmulu.dq."))) {
2195 }
else if (IsX86 && (
Name ==
"sse41.pmuldq" ||
2196 Name ==
"avx2.pmul.dq" ||
2197 Name ==
"avx512.pmul.dq.512" ||
2198 Name.startswith(
"avx512.mask.pmul.dq."))) {
2200 }
else if (IsX86 && (
Name ==
"sse.cvtsi2ss" ||
2201 Name ==
"sse2.cvtsi2sd" ||
2202 Name ==
"sse.cvtsi642ss" ||
2203 Name ==
"sse2.cvtsi642sd")) {
2206 cast<VectorType>(CI->
getType())->getElementType());
2208 }
else if (IsX86 &&
Name ==
"avx512.cvtusi2sd") {
2211 cast<VectorType>(CI->
getType())->getElementType());
2213 }
else if (IsX86 &&
Name ==
"sse2.cvtss2sd") {
2216 Rep, cast<VectorType>(CI->
getType())->getElementType());
2218 }
else if (IsX86 && (
Name ==
"sse2.cvtdq2pd" ||
2219 Name ==
"sse2.cvtdq2ps" ||
2220 Name ==
"avx.cvtdq2.pd.256" ||
2221 Name ==
"avx.cvtdq2.ps.256" ||
2222 Name.startswith(
"avx512.mask.cvtdq2pd.") ||
2223 Name.startswith(
"avx512.mask.cvtudq2pd.") ||
2224 Name.startswith(
"avx512.mask.cvtdq2ps.") ||
2225 Name.startswith(
"avx512.mask.cvtudq2ps.") ||
2226 Name.startswith(
"avx512.mask.cvtqq2pd.") ||
2227 Name.startswith(
"avx512.mask.cvtuqq2pd.") ||
2228 Name ==
"avx512.mask.cvtqq2ps.256" ||
2229 Name ==
"avx512.mask.cvtqq2ps.512" ||
2230 Name ==
"avx512.mask.cvtuqq2ps.256" ||
2231 Name ==
"avx512.mask.cvtuqq2ps.512" ||
2232 Name ==
"sse2.cvtps2pd" ||
2233 Name ==
"avx.cvt.ps2.pd.256" ||
2234 Name ==
"avx512.mask.cvtps2pd.128" ||
2235 Name ==
"avx512.mask.cvtps2pd.256")) {
2236 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2238 auto *SrcTy = cast<FixedVectorType>(Rep->
getType());
2240 unsigned NumDstElts = DstTy->getNumElements();
2241 if (NumDstElts < SrcTy->getNumElements()) {
2242 assert(NumDstElts == 2 &&
"Unexpected vector size");
2246 bool IsPS2PD = SrcTy->getElementType()->isFloatTy();
2249 Rep =
Builder.CreateFPExt(Rep, DstTy,
"cvtps2pd");
2252 cast<ConstantInt>(CI->
getArgOperand(3))->getZExtValue() != 4)) {
2253 Intrinsic::ID IID = IsUnsigned ? Intrinsic::x86_avx512_uitofp_round
2254 : Intrinsic::x86_avx512_sitofp_round;
2259 Rep = IsUnsigned ?
Builder.CreateUIToFP(Rep, DstTy,
"cvt")
2260 :
Builder.CreateSIToFP(Rep, DstTy,
"cvt");
2266 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vcvtph2ps.") ||
2267 Name.startswith(
"vcvtph2ps."))) {
2268 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2270 auto *SrcTy = cast<FixedVectorType>(Rep->
getType());
2271 unsigned NumDstElts = DstTy->getNumElements();
2272 if (NumDstElts != SrcTy->getNumElements()) {
2273 assert(NumDstElts == 4 &&
"Unexpected vector size");
2278 Rep =
Builder.CreateFPExt(Rep, DstTy,
"cvtph2ps");
2282 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.loadu."))) {
2286 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.load."))) {
2290 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.expand.load.")) {
2291 auto *ResultTy = cast<FixedVectorType>(CI->
getType());
2292 Type *PtrTy = ResultTy->getElementType();
2299 ResultTy->getNumElements());
2302 Intrinsic::masked_expandload,
2305 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.compress.store.")) {
2307 Type *PtrTy = ResultTy->getElementType();
2315 cast<FixedVectorType>(ResultTy)->getNumElements());
2318 Intrinsic::masked_compressstore,
2321 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.compress.") ||
2322 Name.startswith(
"avx512.mask.expand."))) {
2323 auto *ResultTy = cast<FixedVectorType>(CI->
getType());
2326 ResultTy->getNumElements());
2328 bool IsCompress =
Name[12] ==
'c';
2329 Intrinsic::ID IID = IsCompress ? Intrinsic::x86_avx512_mask_compress
2330 : Intrinsic::x86_avx512_mask_expand;
2334 }
else if (IsX86 &&
Name.startswith(
"xop.vpcom")) {
2336 if (
Name.endswith(
"ub") ||
Name.endswith(
"uw") ||
Name.endswith(
"ud") ||
2337 Name.endswith(
"uq"))
2339 else if (
Name.endswith(
"b") ||
Name.endswith(
"w") ||
Name.endswith(
"d") ||
2347 Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2350 if (
Name.startswith(
"lt"))
2352 else if (
Name.startswith(
"le"))
2354 else if (
Name.startswith(
"gt"))
2356 else if (
Name.startswith(
"ge"))
2358 else if (
Name.startswith(
"eq"))
2360 else if (
Name.startswith(
"ne"))
2362 else if (
Name.startswith(
"false"))
2364 else if (
Name.startswith(
"true"))
2371 }
else if (IsX86 &&
Name.startswith(
"xop.vpcmov")) {
2376 Rep =
Builder.CreateOr(Sel0, Sel1);
2377 }
else if (IsX86 && (
Name.startswith(
"xop.vprot") ||
2378 Name.startswith(
"avx512.prol") ||
2379 Name.startswith(
"avx512.mask.prol"))) {
2381 }
else if (IsX86 && (
Name.startswith(
"avx512.pror") ||
2382 Name.startswith(
"avx512.mask.pror"))) {
2384 }
else if (IsX86 && (
Name.startswith(
"avx512.vpshld.") ||
2385 Name.startswith(
"avx512.mask.vpshld") ||
2386 Name.startswith(
"avx512.maskz.vpshld"))) {
2387 bool ZeroMask =
Name[11] ==
'z';
2389 }
else if (IsX86 && (
Name.startswith(
"avx512.vpshrd.") ||
2390 Name.startswith(
"avx512.mask.vpshrd") ||
2391 Name.startswith(
"avx512.maskz.vpshrd"))) {
2392 bool ZeroMask =
Name[11] ==
'z';
2394 }
else if (IsX86 &&
Name ==
"sse42.crc32.64.8") {
2396 Intrinsic::x86_sse42_crc32_32_8);
2400 }
else if (IsX86 && (
Name.startswith(
"avx.vbroadcast.s") ||
2401 Name.startswith(
"avx512.vbroadcast.s"))) {
2403 auto *VecTy = cast<FixedVectorType>(CI->
getType());
2404 Type *EltTy = VecTy->getElementType();
2405 unsigned EltNum = VecTy->getNumElements();
2411 for (
unsigned I = 0;
I < EltNum; ++
I)
2414 }
else if (IsX86 && (
Name.startswith(
"sse41.pmovsx") ||
2415 Name.startswith(
"sse41.pmovzx") ||
2416 Name.startswith(
"avx2.pmovsx") ||
2417 Name.startswith(
"avx2.pmovzx") ||
2418 Name.startswith(
"avx512.mask.pmovsx") ||
2419 Name.startswith(
"avx512.mask.pmovzx"))) {
2420 auto *DstTy = cast<FixedVectorType>(CI->
getType());
2421 unsigned NumDstElts = DstTy->getNumElements();
2425 for (
unsigned i = 0;
i != NumDstElts; ++
i)
2432 Rep = DoSext ?
Builder.CreateSExt(SV, DstTy)
2433 :
Builder.CreateZExt(SV, DstTy);
2438 }
else if (
Name ==
"avx512.mask.pmov.qd.256" ||
2439 Name ==
"avx512.mask.pmov.qd.512" ||
2440 Name ==
"avx512.mask.pmov.wb.256" ||
2441 Name ==
"avx512.mask.pmov.wb.512") {
2446 }
else if (IsX86 && (
Name.startswith(
"avx.vbroadcastf128") ||
2447 Name ==
"avx2.vbroadcasti128")) {
2449 Type *EltTy = cast<VectorType>(CI->
getType())->getElementType();
2455 if (NumSrcElts == 2)
2458 Rep =
Builder.CreateShuffleVector(
2460 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.shuf.i") ||
2461 Name.startswith(
"avx512.mask.shuf.f"))) {
2462 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2466 unsigned ControlBitsMask = NumLanes - 1;
2467 unsigned NumControlBits = NumLanes / 2;
2470 for (
unsigned l = 0;
l != NumLanes; ++
l) {
2471 unsigned LaneMask = (Imm >> (
l * NumControlBits)) & ControlBitsMask;
2473 if (
l >= NumLanes / 2)
2474 LaneMask += NumLanes;
2475 for (
unsigned i = 0;
i != NumElementsInLane; ++
i)
2476 ShuffleMask.push_back(LaneMask * NumElementsInLane +
i);
2482 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.broadcastf") ||
2483 Name.startswith(
"avx512.mask.broadcasti"))) {
2484 unsigned NumSrcElts =
2487 unsigned NumDstElts =
2488 cast<FixedVectorType>(CI->
getType())->getNumElements();
2491 for (
unsigned i = 0;
i != NumDstElts; ++
i)
2492 ShuffleMask[
i] =
i % NumSrcElts;
2499 }
else if (IsX86 && (
Name.startswith(
"avx2.pbroadcast") ||
2500 Name.startswith(
"avx2.vbroadcast") ||
2501 Name.startswith(
"avx512.pbroadcast") ||
2502 Name.startswith(
"avx512.mask.broadcast.s"))) {
2514 }
else if (IsX86 && (
Name.startswith(
"sse2.padds.") ||
2515 Name.startswith(
"avx2.padds.") ||
2516 Name.startswith(
"avx512.padds.") ||
2517 Name.startswith(
"avx512.mask.padds."))) {
2519 }
else if (IsX86 && (
Name.startswith(
"sse2.psubs.") ||
2520 Name.startswith(
"avx2.psubs.") ||
2521 Name.startswith(
"avx512.psubs.") ||
2522 Name.startswith(
"avx512.mask.psubs."))) {
2524 }
else if (IsX86 && (
Name.startswith(
"sse2.paddus.") ||
2525 Name.startswith(
"avx2.paddus.") ||
2526 Name.startswith(
"avx512.mask.paddus."))) {
2528 }
else if (IsX86 && (
Name.startswith(
"sse2.psubus.") ||
2529 Name.startswith(
"avx2.psubus.") ||
2530 Name.startswith(
"avx512.mask.psubus."))) {
2532 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.palignr.")) {
2539 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.valign.")) {
2546 }
else if (IsX86 && (
Name ==
"sse2.psll.dq" ||
2547 Name ==
"avx2.psll.dq")) {
2552 }
else if (IsX86 && (
Name ==
"sse2.psrl.dq" ||
2553 Name ==
"avx2.psrl.dq")) {
2558 }
else if (IsX86 && (
Name ==
"sse2.psll.dq.bs" ||
2559 Name ==
"avx2.psll.dq.bs" ||
2560 Name ==
"avx512.psll.dq.512")) {
2564 }
else if (IsX86 && (
Name ==
"sse2.psrl.dq.bs" ||
2565 Name ==
"avx2.psrl.dq.bs" ||
2566 Name ==
"avx512.psrl.dq.512")) {
2570 }
else if (IsX86 && (
Name ==
"sse41.pblendw" ||
2571 Name.startswith(
"sse41.blendp") ||
2572 Name.startswith(
"avx.blend.p") ||
2573 Name ==
"avx2.pblendw" ||
2574 Name.startswith(
"avx2.pblendd."))) {
2577 unsigned Imm = cast <ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2578 auto *VecTy = cast<FixedVectorType>(CI->
getType());
2579 unsigned NumElts = VecTy->getNumElements();
2582 for (
unsigned i = 0;
i != NumElts; ++
i)
2583 Idxs[
i] = ((Imm >> (
i%8)) & 1) ?
i + NumElts :
i;
2585 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
2586 }
else if (IsX86 && (
Name.startswith(
"avx.vinsertf128.") ||
2587 Name ==
"avx2.vinserti128" ||
2588 Name.startswith(
"avx512.mask.insert"))) {
2591 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2592 unsigned DstNumElts =
2593 cast<FixedVectorType>(CI->
getType())->getNumElements();
2594 unsigned SrcNumElts =
2595 cast<FixedVectorType>(Op1->
getType())->getNumElements();
2596 unsigned Scale = DstNumElts / SrcNumElts;
2603 for (
unsigned i = 0;
i != SrcNumElts; ++
i)
2605 for (
unsigned i = SrcNumElts;
i != DstNumElts; ++
i)
2606 Idxs[
i] = SrcNumElts;
2607 Rep =
Builder.CreateShuffleVector(Op1, Idxs);
2621 for (
unsigned i = 0;
i != DstNumElts; ++
i)
2624 for (
unsigned i = 0;
i != SrcNumElts; ++
i)
2625 Idxs[
i + Imm * SrcNumElts] =
i + DstNumElts;
2626 Rep =
Builder.CreateShuffleVector(Op0, Rep, Idxs);
2632 }
else if (IsX86 && (
Name.startswith(
"avx.vextractf128.") ||
2633 Name ==
"avx2.vextracti128" ||
2634 Name.startswith(
"avx512.mask.vextract"))) {
2636 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2637 unsigned DstNumElts =
2638 cast<FixedVectorType>(CI->
getType())->getNumElements();
2639 unsigned SrcNumElts =
2640 cast<FixedVectorType>(Op0->
getType())->getNumElements();
2641 unsigned Scale = SrcNumElts / DstNumElts;
2648 for (
unsigned i = 0;
i != DstNumElts; ++
i) {
2649 Idxs[
i] =
i + (Imm * DstNumElts);
2651 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
2657 }
else if (!IsX86 &&
Name ==
"stackprotectorcheck") {
2659 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.perm.df.") ||
2660 Name.startswith(
"avx512.mask.perm.di."))) {
2662 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2663 auto *VecTy = cast<FixedVectorType>(CI->
getType());
2664 unsigned NumElts = VecTy->getNumElements();
2667 for (
unsigned i = 0;
i != NumElts; ++
i)
2668 Idxs[
i] = (
i & ~0
x3) + ((Imm >> (2 * (
i & 0x3))) & 3);
2670 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
2675 }
else if (IsX86 && (
Name.startswith(
"avx.vperm2f128.") ||
2676 Name ==
"avx2.vperm2i128")) {
2685 uint8_t Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2687 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2688 unsigned HalfSize = NumElts / 2;
2700 unsigned StartIndex = (Imm & 0x01) ? HalfSize : 0;
2701 for (
unsigned i = 0;
i < HalfSize; ++
i)
2702 ShuffleMask[
i] = StartIndex +
i;
2705 StartIndex = (Imm & 0x10) ? HalfSize : 0;
2706 for (
unsigned i = 0;
i < HalfSize; ++
i)
2707 ShuffleMask[
i + HalfSize] = NumElts + StartIndex +
i;
2709 Rep =
Builder.CreateShuffleVector(V0, V1, ShuffleMask);
2711 }
else if (IsX86 && (
Name.startswith(
"avx.vpermil.") ||
2712 Name ==
"sse2.pshuf.d" ||
2713 Name.startswith(
"avx512.mask.vpermil.p") ||
2714 Name.startswith(
"avx512.mask.pshuf.d."))) {
2716 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2717 auto *VecTy = cast<FixedVectorType>(CI->
getType());
2718 unsigned NumElts = VecTy->getNumElements();
2720 unsigned IdxSize = 64 / VecTy->getScalarSizeInBits();
2721 unsigned IdxMask = ((1 << IdxSize) - 1);
2727 for (
unsigned i = 0;
i != NumElts; ++
i)
2728 Idxs[
i] = ((Imm >> ((
i * IdxSize) % 8)) & IdxMask) | (
i & ~IdxMask);
2730 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
2735 }
else if (IsX86 && (
Name ==
"sse2.pshufl.w" ||
2736 Name.startswith(
"avx512.mask.pshufl.w."))) {
2738 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2739 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2742 for (
unsigned l = 0;
l != NumElts;
l += 8) {
2743 for (
unsigned i = 0;
i != 4; ++
i)
2744 Idxs[
i +
l] = ((Imm >> (2 *
i)) & 0
x3) +
l;
2745 for (
unsigned i = 4;
i != 8; ++
i)
2746 Idxs[
i +
l] =
i +
l;
2749 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
2754 }
else if (IsX86 && (
Name ==
"sse2.pshufh.w" ||
2755 Name.startswith(
"avx512.mask.pshufh.w."))) {
2757 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(1))->getZExtValue();
2758 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2761 for (
unsigned l = 0;
l != NumElts;
l += 8) {
2762 for (
unsigned i = 0;
i != 4; ++
i)
2763 Idxs[
i +
l] =
i +
l;
2764 for (
unsigned i = 0;
i != 4; ++
i)
2765 Idxs[
i +
l + 4] = ((Imm >> (2 *
i)) & 0
x3) + 4 +
l;
2768 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
2773 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.shuf.p")) {
2776 unsigned Imm = cast<ConstantInt>(CI->
getArgOperand(2))->getZExtValue();
2777 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2780 unsigned HalfLaneElts = NumLaneElts / 2;
2783 for (
unsigned i = 0;
i != NumElts; ++
i) {
2785 Idxs[
i] =
i - (
i % NumLaneElts);
2787 if ((
i % NumLaneElts) >= HalfLaneElts)
2791 Idxs[
i] += (Imm >> ((
i * HalfLaneElts) % 8)) & ((1 << HalfLaneElts) - 1);
2794 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
2798 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.movddup") ||
2799 Name.startswith(
"avx512.mask.movshdup") ||
2800 Name.startswith(
"avx512.mask.movsldup"))) {
2802 unsigned NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2806 if (
Name.startswith(
"avx512.mask.movshdup."))
2810 for (
unsigned l = 0;
l != NumElts;
l += NumLaneElts)
2811 for (
unsigned i = 0;
i != NumLaneElts;
i += 2) {
2816 Rep =
Builder.CreateShuffleVector(Op0, Op0, Idxs);
2820 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.punpckl") ||
2821 Name.startswith(
"avx512.mask.unpckl."))) {
2824 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2828 for (
int l = 0;
l != NumElts;
l += NumLaneElts)
2829 for (
int i = 0;
i != NumLaneElts; ++
i)
2830 Idxs[
i +
l] =
l + (
i / 2) + NumElts * (
i % 2);
2832 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
2836 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.punpckh") ||
2837 Name.startswith(
"avx512.mask.unpckh."))) {
2840 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
2844 for (
int l = 0;
l != NumElts;
l += NumLaneElts)
2845 for (
int i = 0;
i != NumLaneElts; ++
i)
2846 Idxs[
i +
l] = (NumLaneElts / 2) +
l + (
i / 2) + NumElts * (
i % 2);
2848 Rep =
Builder.CreateShuffleVector(Op0, Op1, Idxs);
2852 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.and.") ||
2853 Name.startswith(
"avx512.mask.pand."))) {
2858 Rep =
Builder.CreateBitCast(Rep, FTy);
2861 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.andn.") ||
2862 Name.startswith(
"avx512.mask.pandn."))) {
2868 Rep =
Builder.CreateBitCast(Rep, FTy);
2871 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.or.") ||
2872 Name.startswith(
"avx512.mask.por."))) {
2877 Rep =
Builder.CreateBitCast(Rep, FTy);
2880 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.xor.") ||
2881 Name.startswith(
"avx512.mask.pxor."))) {
2886 Rep =
Builder.CreateBitCast(Rep, FTy);
2889 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.padd.")) {
2893 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psub.")) {
2897 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.pmull.")) {
2901 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.add.p")) {
2902 if (
Name.endswith(
".512")) {
2904 if (
Name[17] ==
's')
2905 IID = Intrinsic::x86_avx512_add_ps_512;
2907 IID = Intrinsic::x86_avx512_add_pd_512;
2910 { CI->getArgOperand(0), CI->getArgOperand(1),
2911 CI->getArgOperand(4) });
2917 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.div.p")) {
2918 if (
Name.endswith(
".512")) {
2920 if (
Name[17] ==
's')
2921 IID = Intrinsic::x86_avx512_div_ps_512;
2923 IID = Intrinsic::x86_avx512_div_pd_512;
2926 { CI->getArgOperand(0), CI->getArgOperand(1),
2927 CI->getArgOperand(4) });
2933 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.mul.p")) {
2934 if (
Name.endswith(
".512")) {
2936 if (
Name[17] ==
's')
2937 IID = Intrinsic::x86_avx512_mul_ps_512;
2939 IID = Intrinsic::x86_avx512_mul_pd_512;
2942 { CI->getArgOperand(0), CI->getArgOperand(1),
2943 CI->getArgOperand(4) });
2949 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.sub.p")) {
2950 if (
Name.endswith(
".512")) {
2952 if (
Name[17] ==
's')
2953 IID = Intrinsic::x86_avx512_sub_ps_512;
2955 IID = Intrinsic::x86_avx512_sub_pd_512;
2958 { CI->getArgOperand(0), CI->getArgOperand(1),
2959 CI->getArgOperand(4) });
2965 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.max.p") ||
2966 Name.startswith(
"avx512.mask.min.p")) &&
2967 Name.drop_front(18) ==
".512") {
2968 bool IsDouble =
Name[17] ==
'd';
2969 bool IsMin =
Name[13] ==
'i';
2971 { Intrinsic::x86_avx512_max_ps_512, Intrinsic::x86_avx512_max_pd_512 },
2972 { Intrinsic::x86_avx512_min_ps_512, Intrinsic::x86_avx512_min_pd_512 }
2977 { CI->getArgOperand(0), CI->getArgOperand(1),
2978 CI->getArgOperand(4) });
2981 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.lzcnt.")) {
2985 { CI->getArgOperand(0), Builder.getInt1(false) });
2988 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psll")) {
2989 bool IsImmediate =
Name[16] ==
'i' ||
2990 (
Name.size() > 18 &&
Name[18] ==
'i');
2991 bool IsVariable =
Name[16] ==
'v';
2998 if (IsVariable &&
Name[17] !=
'.') {
2999 if (
Size ==
'd' &&
Name[17] ==
'2')
3000 IID = Intrinsic::x86_avx2_psllv_q;
3001 else if (
Size ==
'd' &&
Name[17] ==
'4')
3002 IID = Intrinsic::x86_avx2_psllv_q_256;
3003 else if (
Size ==
's' &&
Name[17] ==
'4')
3004 IID = Intrinsic::x86_avx2_psllv_d;
3005 else if (
Size ==
's' &&
Name[17] ==
'8')
3006 IID = Intrinsic::x86_avx2_psllv_d_256;
3007 else if (
Size ==
'h' &&
Name[17] ==
'8')
3008 IID = Intrinsic::x86_avx512_psllv_w_128;
3009 else if (
Size ==
'h' &&
Name[17] ==
'1')
3010 IID = Intrinsic::x86_avx512_psllv_w_256;
3011 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3012 IID = Intrinsic::x86_avx512_psllv_w_512;
3015 }
else if (
Name.endswith(
".128")) {
3017 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_d
3018 : Intrinsic::x86_sse2_psll_d;
3019 else if (
Size ==
'q')
3020 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_q
3021 : Intrinsic::x86_sse2_psll_q;
3022 else if (
Size ==
'w')
3023 IID = IsImmediate ? Intrinsic::x86_sse2_pslli_w
3024 : Intrinsic::x86_sse2_psll_w;
3027 }
else if (
Name.endswith(
".256")) {
3029 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_d
3030 : Intrinsic::x86_avx2_psll_d;
3031 else if (
Size ==
'q')
3032 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_q
3033 : Intrinsic::x86_avx2_psll_q;
3034 else if (
Size ==
'w')
3035 IID = IsImmediate ? Intrinsic::x86_avx2_pslli_w
3036 : Intrinsic::x86_avx2_psll_w;
3041 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_d_512 :
3042 IsVariable ? Intrinsic::x86_avx512_psllv_d_512 :
3043 Intrinsic::x86_avx512_psll_d_512;
3044 else if (
Size ==
'q')
3045 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_q_512 :
3046 IsVariable ? Intrinsic::x86_avx512_psllv_q_512 :
3047 Intrinsic::x86_avx512_psll_q_512;
3048 else if (
Size ==
'w')
3049 IID = IsImmediate ? Intrinsic::x86_avx512_pslli_w_512
3050 : Intrinsic::x86_avx512_psll_w_512;
3056 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psrl")) {
3057 bool IsImmediate =
Name[16] ==
'i' ||
3058 (
Name.size() > 18 &&
Name[18] ==
'i');
3059 bool IsVariable =
Name[16] ==
'v';
3066 if (IsVariable &&
Name[17] !=
'.') {
3067 if (
Size ==
'd' &&
Name[17] ==
'2')
3068 IID = Intrinsic::x86_avx2_psrlv_q;
3069 else if (
Size ==
'd' &&
Name[17] ==
'4')
3070 IID = Intrinsic::x86_avx2_psrlv_q_256;
3071 else if (
Size ==
's' &&
Name[17] ==
'4')
3072 IID = Intrinsic::x86_avx2_psrlv_d;
3073 else if (
Size ==
's' &&
Name[17] ==
'8')
3074 IID = Intrinsic::x86_avx2_psrlv_d_256;
3075 else if (
Size ==
'h' &&
Name[17] ==
'8')
3076 IID = Intrinsic::x86_avx512_psrlv_w_128;
3077 else if (
Size ==
'h' &&
Name[17] ==
'1')
3078 IID = Intrinsic::x86_avx512_psrlv_w_256;
3079 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3080 IID = Intrinsic::x86_avx512_psrlv_w_512;
3083 }
else if (
Name.endswith(
".128")) {
3085 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_d
3086 : Intrinsic::x86_sse2_psrl_d;
3087 else if (
Size ==
'q')
3088 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_q
3089 : Intrinsic::x86_sse2_psrl_q;
3090 else if (
Size ==
'w')
3091 IID = IsImmediate ? Intrinsic::x86_sse2_psrli_w
3092 : Intrinsic::x86_sse2_psrl_w;
3095 }
else if (
Name.endswith(
".256")) {
3097 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_d
3098 : Intrinsic::x86_avx2_psrl_d;
3099 else if (
Size ==
'q')
3100 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_q
3101 : Intrinsic::x86_avx2_psrl_q;
3102 else if (
Size ==
'w')
3103 IID = IsImmediate ? Intrinsic::x86_avx2_psrli_w
3104 : Intrinsic::x86_avx2_psrl_w;
3109 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_d_512 :
3110 IsVariable ? Intrinsic::x86_avx512_psrlv_d_512 :
3111 Intrinsic::x86_avx512_psrl_d_512;
3112 else if (
Size ==
'q')
3113 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_q_512 :
3114 IsVariable ? Intrinsic::x86_avx512_psrlv_q_512 :
3115 Intrinsic::x86_avx512_psrl_q_512;
3116 else if (
Size ==
'w')
3117 IID = IsImmediate ? Intrinsic::x86_avx512_psrli_w_512
3118 : Intrinsic::x86_avx512_psrl_w_512;
3124 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.psra")) {
3125 bool IsImmediate =
Name[16] ==
'i' ||
3126 (
Name.size() > 18 &&
Name[18] ==
'i');
3127 bool IsVariable =
Name[16] ==
'v';
3134 if (IsVariable &&
Name[17] !=
'.') {
3135 if (
Size ==
's' &&
Name[17] ==
'4')
3136 IID = Intrinsic::x86_avx2_psrav_d;
3137 else if (
Size ==
's' &&
Name[17] ==
'8')
3138 IID = Intrinsic::x86_avx2_psrav_d_256;
3139 else if (
Size ==
'h' &&
Name[17] ==
'8')
3140 IID = Intrinsic::x86_avx512_psrav_w_128;
3141 else if (
Size ==
'h' &&
Name[17] ==
'1')
3142 IID = Intrinsic::x86_avx512_psrav_w_256;
3143 else if (
Name[17] ==
'3' &&
Name[18] ==
'2')
3144 IID = Intrinsic::x86_avx512_psrav_w_512;
3147 }
else if (
Name.endswith(
".128")) {
3149 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_d
3150 : Intrinsic::x86_sse2_psra_d;
3151 else if (
Size ==
'q')
3152 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_128 :
3153 IsVariable ? Intrinsic::x86_avx512_psrav_q_128 :
3154 Intrinsic::x86_avx512_psra_q_128;
3155 else if (
Size ==
'w')
3156 IID = IsImmediate ? Intrinsic::x86_sse2_psrai_w
3157 : Intrinsic::x86_sse2_psra_w;
3160 }
else if (
Name.endswith(
".256")) {
3162 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_d
3163 : Intrinsic::x86_avx2_psra_d;
3164 else if (
Size ==
'q')
3165 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_256 :
3166 IsVariable ? Intrinsic::x86_avx512_psrav_q_256 :
3167 Intrinsic::x86_avx512_psra_q_256;
3168 else if (
Size ==
'w')
3169 IID = IsImmediate ? Intrinsic::x86_avx2_psrai_w
3170 : Intrinsic::x86_avx2_psra_w;
3175 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_d_512 :
3176 IsVariable ? Intrinsic::x86_avx512_psrav_d_512 :
3177 Intrinsic::x86_avx512_psra_d_512;
3178 else if (
Size ==
'q')
3179 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_q_512 :
3180 IsVariable ? Intrinsic::x86_avx512_psrav_q_512 :
3181 Intrinsic::x86_avx512_psra_q_512;
3182 else if (
Size ==
'w')
3183 IID = IsImmediate ? Intrinsic::x86_avx512_psrai_w_512
3184 : Intrinsic::x86_avx512_psra_w_512;
3190 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.move.s")) {
3192 }
else if (IsX86 &&
Name.startswith(
"avx512.cvtmask2")) {
3194 }
else if (IsX86 &&
Name.endswith(
".movntdqa")) {
3209 }
else if (IsX86 && (
Name.startswith(
"fma.vfmadd.") ||
3210 Name.startswith(
"fma.vfmsub.") ||
3211 Name.startswith(
"fma.vfnmadd.") ||
3212 Name.startswith(
"fma.vfnmsub."))) {
3213 bool NegMul =
Name[6] ==
'n';
3214 bool NegAcc = NegMul ?
Name[8] ==
's' :
Name[7] ==
's';
3215 bool IsScalar = NegMul ?
Name[12] ==
's' :
Name[11] ==
's';
3221 Ops[0] =
Builder.CreateExtractElement(Ops[0], (uint64_t)0);
3222 Ops[1] =
Builder.CreateExtractElement(Ops[1], (uint64_t)0);
3223 Ops[2] =
Builder.CreateExtractElement(Ops[2], (uint64_t)0);
3226 if (NegMul && !IsScalar)
3227 Ops[0] =
Builder.CreateFNeg(Ops[0]);
3228 if (NegMul && IsScalar)
3229 Ops[1] =
Builder.CreateFNeg(Ops[1]);
3231 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3241 }
else if (IsX86 &&
Name.startswith(
"fma4.vfmadd.s")) {
3245 Ops[0] =
Builder.CreateExtractElement(Ops[0], (uint64_t)0);
3246 Ops[1] =
Builder.CreateExtractElement(Ops[1], (uint64_t)0);
3247 Ops[2] =
Builder.CreateExtractElement(Ops[2], (uint64_t)0);
3256 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vfmadd.s") ||
3257 Name.startswith(
"avx512.maskz.vfmadd.s") ||
3258 Name.startswith(
"avx512.mask3.vfmadd.s") ||
3259 Name.startswith(
"avx512.mask3.vfmsub.s") ||
3260 Name.startswith(
"avx512.mask3.vfnmsub.s"))) {
3261 bool IsMask3 =
Name[11] ==
'3';
3262 bool IsMaskZ =
Name[11] ==
'z';
3264 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3265 bool NegMul =
Name[2] ==
'n';
3266 bool NegAcc = NegMul ?
Name[4] ==
's' :
Name[3] ==
's';
3272 if (NegMul && (IsMask3 || IsMaskZ))
3274 if (NegMul && !(IsMask3 || IsMaskZ))
3279 A =
Builder.CreateExtractElement(A, (uint64_t)0);
3280 B =
Builder.CreateExtractElement(
B, (uint64_t)0);
3281 C =
Builder.CreateExtractElement(
C, (uint64_t)0);
3284 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4) {
3288 if (
Name.back() ==
'd')
3289 IID = Intrinsic::x86_avx512_vfmadd_f64;
3291 IID = Intrinsic::x86_avx512_vfmadd_f32;
3306 if (NegAcc && IsMask3)
3314 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vfmadd.p") ||
3315 Name.startswith(
"avx512.mask.vfnmadd.p") ||
3316 Name.startswith(
"avx512.mask.vfnmsub.p") ||
3317 Name.startswith(
"avx512.mask3.vfmadd.p") ||
3318 Name.startswith(
"avx512.mask3.vfmsub.p") ||
3319 Name.startswith(
"avx512.mask3.vfnmsub.p") ||
3320 Name.startswith(
"avx512.maskz.vfmadd.p"))) {
3321 bool IsMask3 =
Name[11] ==
'3';
3322 bool IsMaskZ =
Name[11] ==
'z';
3324 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3325 bool NegMul =
Name[2] ==
'n';
3326 bool NegAcc = NegMul ?
Name[4] ==
's' :
Name[3] ==
's';
3332 if (NegMul && (IsMask3 || IsMaskZ))
3334 if (NegMul && !(IsMask3 || IsMaskZ))
3341 cast<ConstantInt>(CI->
getArgOperand(4))->getZExtValue() != 4)) {
3345 IID = Intrinsic::x86_avx512_vfmadd_ps_512;
3347 IID = Intrinsic::x86_avx512_vfmadd_pd_512;
3350 { A, B, C, CI->getArgOperand(4) });
3363 }
else if (IsX86 &&
Name.startswith(
"fma.vfmsubadd.p")) {
3367 if (VecWidth == 128 && EltWidth == 32)
3368 IID = Intrinsic::x86_fma_vfmaddsub_ps;
3369 else if (VecWidth == 256 && EltWidth == 32)
3370 IID = Intrinsic::x86_fma_vfmaddsub_ps_256;
3371 else if (VecWidth == 128 && EltWidth == 64)
3372 IID = Intrinsic::x86_fma_vfmaddsub_pd;
3373 else if (VecWidth == 256 && EltWidth == 64)
3374 IID = Intrinsic::x86_fma_vfmaddsub_pd_256;
3380 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3383 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vfmaddsub.p") ||
3384 Name.startswith(
"avx512.mask3.vfmaddsub.p") ||
3385 Name.startswith(
"avx512.maskz.vfmaddsub.p") ||
3386 Name.startswith(
"avx512.mask3.vfmsubadd.p"))) {
3387 bool IsMask3 =
Name[11] ==
'3';
3388 bool IsMaskZ =
Name[11] ==
'z';
3390 Name =
Name.drop_front(IsMask3 || IsMaskZ ? 13 : 12);
3391 bool IsSubAdd =
Name[3] ==
's';
3396 IID = Intrinsic::x86_avx512_vfmaddsub_ps_512;
3398 IID = Intrinsic::x86_avx512_vfmaddsub_pd_512;
3403 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3408 int NumElts = cast<FixedVectorType>(CI->
getType())->getNumElements();
3416 Ops[2] =
Builder.CreateFNeg(Ops[2]);
3423 for (
int i = 0;
i != NumElts; ++
i)
3424 Idxs[
i] =
i + (
i % 2) * NumElts;
3426 Rep =
Builder.CreateShuffleVector(Even, Odd, Idxs);
3434 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.pternlog.") ||
3435 Name.startswith(
"avx512.maskz.pternlog."))) {
3436 bool ZeroMask =
Name[11] ==
'z';
3440 if (VecWidth == 128 && EltWidth == 32)
3441 IID = Intrinsic::x86_avx512_pternlog_d_128;
3442 else if (VecWidth == 256 && EltWidth == 32)
3443 IID = Intrinsic::x86_avx512_pternlog_d_256;
3444 else if (VecWidth == 512 && EltWidth == 32)
3445 IID = Intrinsic::x86_avx512_pternlog_d_512;
3446 else if (VecWidth == 128 && EltWidth == 64)
3447 IID = Intrinsic::x86_avx512_pternlog_q_128;
3448 else if (VecWidth == 256 && EltWidth == 64)
3449 IID = Intrinsic::x86_avx512_pternlog_q_256;
3450 else if (VecWidth == 512 && EltWidth == 64)
3451 IID = Intrinsic::x86_avx512_pternlog_q_512;
3462 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpmadd52") ||
3463 Name.startswith(
"avx512.maskz.vpmadd52"))) {
3464 bool ZeroMask =
Name[11] ==
'z';
3468 if (VecWidth == 128 && !
High)
3469 IID = Intrinsic::x86_avx512_vpmadd52l_uq_128;
3470 else if (VecWidth == 256 && !
High)
3471 IID = Intrinsic::x86_avx512_vpmadd52l_uq_256;
3472 else if (VecWidth == 512 && !
High)
3473 IID = Intrinsic::x86_avx512_vpmadd52l_uq_512;
3474 else if (VecWidth == 128 &&
High)
3475 IID = Intrinsic::x86_avx512_vpmadd52h_uq_128;
3476 else if (VecWidth == 256 &&
High)
3477 IID = Intrinsic::x86_avx512_vpmadd52h_uq_256;
3478 else if (VecWidth == 512 &&
High)
3479 IID = Intrinsic::x86_avx512_vpmadd52h_uq_512;
3490 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpermi2var.") ||
3491 Name.startswith(
"avx512.mask.vpermt2var.") ||
3492 Name.startswith(
"avx512.maskz.vpermt2var."))) {
3493 bool ZeroMask =
Name[11] ==
'z';
3494 bool IndexForm =
Name[17] ==
'i';
3496 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpdpbusd.") ||
3497 Name.startswith(
"avx512.maskz.vpdpbusd.") ||
3498 Name.startswith(
"avx512.mask.vpdpbusds.") ||
3499 Name.startswith(
"avx512.maskz.vpdpbusds."))) {
3500 bool ZeroMask =
Name[11] ==
'z';
3501 bool IsSaturating =
Name[ZeroMask ? 21 : 20] ==
's';
3504 if (VecWidth == 128 && !IsSaturating)
3505 IID = Intrinsic::x86_avx512_vpdpbusd_128;
3506 else if (VecWidth == 256 && !IsSaturating)
3507 IID = Intrinsic::x86_avx512_vpdpbusd_256;
3508 else if (VecWidth == 512 && !IsSaturating)
3509 IID = Intrinsic::x86_avx512_vpdpbusd_512;
3510 else if (VecWidth == 128 && IsSaturating)
3511 IID = Intrinsic::x86_avx512_vpdpbusds_128;
3512 else if (VecWidth == 256 && IsSaturating)
3513 IID = Intrinsic::x86_avx512_vpdpbusds_256;
3514 else if (VecWidth == 512 && IsSaturating)
3515 IID = Intrinsic::x86_avx512_vpdpbusds_512;
3526 }
else if (IsX86 && (
Name.startswith(
"avx512.mask.vpdpwssd.") ||
3527 Name.startswith(
"avx512.maskz.vpdpwssd.") ||
3528 Name.startswith(
"avx512.mask.vpdpwssds.") ||
3529 Name.startswith(
"avx512.maskz.vpdpwssds."))) {
3530 bool ZeroMask =
Name[11] ==
'z';
3531 bool IsSaturating =
Name[ZeroMask ? 21 : 20] ==
's';
3534 if (VecWidth == 128 && !IsSaturating)
3535 IID = Intrinsic::x86_avx512_vpdpwssd_128;
3536 else if (VecWidth == 256 && !IsSaturating)
3537 IID = Intrinsic::x86_avx512_vpdpwssd_256;
3538 else if (VecWidth == 512 && !IsSaturating)
3539 IID = Intrinsic::x86_avx512_vpdpwssd_512;
3540 else if (VecWidth == 128 && IsSaturating)
3541 IID = Intrinsic::x86_avx512_vpdpwssds_128;
3542 else if (VecWidth == 256 && IsSaturating)
3543 IID = Intrinsic::x86_avx512_vpdpwssds_256;
3544 else if (VecWidth == 512 && IsSaturating)
3545 IID = Intrinsic::x86_avx512_vpdpwssds_512;
3556 }
else if (IsX86 && (
Name ==
"addcarryx.u32" ||
Name ==
"addcarryx.u64" ||
3557 Name ==
"addcarry.u32" ||
Name ==
"addcarry.u64" ||
3558 Name ==
"subborrow.u32" ||
Name ==
"subborrow.u64")) {
3560 if (
Name[0] ==
'a' &&
Name.back() ==
'2')
3561 IID = Intrinsic::x86_addcarry_32;
3562 else if (
Name[0] ==
'a' &&
Name.back() ==
'4')
3563 IID = Intrinsic::x86_addcarry_64;
3564 else if (
Name[0] ==
's' &&
Name.back() ==
'2')
3565 IID = Intrinsic::x86_subborrow_32;
3566 else if (
Name[0] ==
's' &&
Name.back() ==
'4')
3567 IID = Intrinsic::x86_subborrow_64;
3589 }
else if (IsX86 &&
Name.startswith(
"avx512.mask.") &&
3592 }
else if (IsNVVM && (
Name ==
"abs.i" ||
Name ==
"abs.ll")) {
3597 Rep =
Builder.CreateSelect(Cmp,
Arg, Neg,
"abs");
3598 }
else if (IsNVVM && (
Name.startswith(
"atomic.load.add.f32.p") ||
3599 Name.startswith(
"atomic.load.add.f64.p"))) {
3604 }
else if (IsNVVM && (
Name ==
"max.i" ||
Name ==
"max.ll" ||
3605 Name ==
"max.ui" ||
Name ==
"max.ull")) {
3609 ?
Builder.CreateICmpUGE(Arg0, Arg1,
"max.cond")
3610 :
Builder.CreateICmpSGE(Arg0, Arg1,
"max.cond");
3611 Rep =
Builder.CreateSelect(Cmp, Arg0, Arg1,
"max");
3612 }
else if (IsNVVM && (
Name ==
"min.i" ||
Name ==
"min.ll" ||
3613 Name ==
"min.ui" ||
Name ==
"min.ull")) {
3617 ?
Builder.CreateICmpULE(Arg0, Arg1,
"min.cond")
3618 :
Builder.CreateICmpSLE(Arg0, Arg1,
"min.cond");
3619 Rep =
Builder.CreateSelect(Cmp, Arg0, Arg1,
"min");
3620 }
else if (IsNVVM &&
Name ==
"clz.ll") {
3626 {Arg, Builder.getFalse()},
"ctlz");
3627 Rep =
Builder.CreateTrunc(Ctlz,
Builder.getInt32Ty(),
"ctlz.trunc");
3628 }
else if (IsNVVM &&
Name ==
"popc.ll") {
3636 Rep =
Builder.CreateTrunc(Popc,
Builder.getInt32Ty(),
"ctpop.trunc");
3637 }
else if (IsNVVM &&
Name ==
"h2f") {
3639 F->getParent(), Intrinsic::convert_from_fp16,
3640 {Builder.getFloatTy()}),
3652 const auto &DefaultCase = [&NewFn, &CI]() ->
void {
3656 "Unknown function for CallInst upgrade and isn't just a name change");
3665 case Intrinsic::arm_neon_vld1:
3666 case Intrinsic::arm_neon_vld2:
3667 case Intrinsic::arm_neon_vld3:
3668 case Intrinsic::arm_neon_vld4:
3669 case Intrinsic::arm_neon_vld2lane:
3670 case Intrinsic::arm_neon_vld3lane:
3671 case Intrinsic::arm_neon_vld4lane:
3672 case Intrinsic::arm_neon_vst1:
3673 case Intrinsic::arm_neon_vst2:
3674 case Intrinsic::arm_neon_vst3:
3675 case Intrinsic::arm_neon_vst4:
3676 case Intrinsic::arm_neon_vst2lane:
3677 case Intrinsic::arm_neon_vst3lane:
3678 case Intrinsic::arm_neon_vst4lane: {
3685 case Intrinsic::arm_neon_bfdot:
3686 case Intrinsic::arm_neon_bfmmla:
3687 case Intrinsic::arm_neon_bfmlalb:
3688 case Intrinsic::arm_neon_bfmlalt:
3689 case Intrinsic::aarch64_neon_bfdot:
3690 case Intrinsic::aarch64_neon_bfmmla:
3691 case Intrinsic::aarch64_neon_bfmlalb:
3692 case Intrinsic::aarch64_neon_bfmlalt: {
3695 "Mismatch between function args and call args");
3696 size_t OperandWidth =
3698 assert((OperandWidth == 64 || OperandWidth == 128) &&
3699 "Unexpected operand width");
3702 Args.push_back(*Iter++);
3703 Args.push_back(
Builder.CreateBitCast(*Iter++, NewTy));
3704 Args.push_back(
Builder.CreateBitCast(*Iter++, NewTy));
3709 case Intrinsic::bitreverse:
3713 case Intrinsic::ctlz:
3714 case Intrinsic::cttz:
3716 "Mismatch between function args and call args");
3721 case Intrinsic::objectsize: {
3732 case Intrinsic::ctpop:
3736 case Intrinsic::convert_from_fp16:
3740 case Intrinsic::dbg_value:
3745 if (
Offset->isZeroValue()) {
3754 case Intrinsic::ptr_annotation:
3757 "Before LLVM 12.0 this intrinsic took four arguments");
3768 case Intrinsic::var_annotation:
3771 "Before LLVM 12.0 this intrinsic took four arguments");
3780 case Intrinsic::x86_xop_vfrcz_ss:
3781 case Intrinsic::x86_xop_vfrcz_sd:
3785 case Intrinsic::x86_xop_vpermil2pd:
3786 case Intrinsic::x86_xop_vpermil2ps:
3787 case Intrinsic::x86_xop_vpermil2pd_256:
3788 case Intrinsic::x86_xop_vpermil2ps_256: {
3798 case Intrinsic::x86_sse41_ptestc:
3799 case Intrinsic::x86_sse41_ptestz:
3800 case Intrinsic::x86_sse41_ptestnzc: {
3814 Value *BC0 =
Builder.CreateBitCast(Arg0, NewVecTy,
"cast");
3815 Value *BC1 =
Builder.CreateBitCast(Arg1, NewVecTy,
"cast");
3817 NewCall =
Builder.CreateCall(NewFn, {BC0, BC1});
3821 case Intrinsic::x86_rdtscp: {
3827 NewCall =
Builder.CreateCall(NewFn);
3843 case Intrinsic::x86_sse41_insertps:
3844 case Intrinsic::x86_sse41_dppd:
3845 case Intrinsic::x86_sse41_dpps:
3846 case Intrinsic::x86_sse41_mpsadbw:
3847 case Intrinsic::x86_avx_dp_ps_256:
3848 case Intrinsic::x86_avx2_mpsadbw: {
3860 case Intrinsic::x86_avx512_mask_cmp_pd_128:
3861 case Intrinsic::x86_avx512_mask_cmp_pd_256:
3862 case Intrinsic::x86_avx512_mask_cmp_pd_512:
3863 case Intrinsic::x86_avx512_mask_cmp_ps_128:
3864 case Intrinsic::x86_avx512_mask_cmp_ps_256:
3865 case Intrinsic::x86_avx512_mask_cmp_ps_512: {
3869 cast<FixedVectorType>(
Args[0]->
getType())->getNumElements();
3881 case Intrinsic::thread_pointer: {
3882 NewCall =
Builder.CreateCall(NewFn, {});
3886 case Intrinsic::invariant_start:
3887 case Intrinsic::invariant_end:
3888 case Intrinsic::masked_load:
3889 case Intrinsic::masked_store:
3890 case Intrinsic::masked_gather:
3891 case Intrinsic::masked_scatter: {
3899 case Intrinsic::memmove:
3900 case Intrinsic::memset: {
3917 auto *MemCI = cast<MemIntrinsic>(NewCall);
3920 MemCI->setDestAlignment(
Align->getMaybeAlignValue());
3922 if (
auto *MTI = dyn_cast<MemTransferInst>(MemCI))
3923 MTI->setSourceAlignment(
Align->getMaybeAlignValue());
3927 assert(NewCall &&
"Should have either set this variable or returned through "
3928 "the default case");
3935 assert(
F &&
"Illegal attempt to upgrade a non-existent intrinsic.");
3944 if (
CallInst *CI = dyn_cast<CallInst>(U))
3948 F->eraseFromParent();
3962 Metadata *Elts2[] = {ScalarType, ScalarType,
3976 if (Opc != Instruction::BitCast)
3997 if (Opc != Instruction::BitCast)
4000 Type *SrcTy =
C->getType();
4021 bool BrokenDebugInfo =
false;
4024 if (!BrokenDebugInfo)
4030 M.getContext().diagnose(Diag);
4037 M.getContext().diagnose(DiagVersion);
4045 bool Changed =
false;
4046 const char *MarkerKey =
"clang.arc.retainAutoreleasedReturnValueMarker";
4047 NamedMDNode *ModRetainReleaseMarker =
M.getNamedMetadata(MarkerKey);
4048 if (ModRetainReleaseMarker) {
4051 MDString *
ID = dyn_cast_or_null<MDString>(
Op->getOperand(0));
4054 ID->getString().split(ValueComp,
"#");
4055 if (ValueComp.size() == 2) {
4056 std::string NewValue = ValueComp[0].str() +
";" + ValueComp[1].str();
4060 M.eraseNamedMetadata(ModRetainReleaseMarker);
4071 auto UpgradeToIntrinsic = [&](
const char *OldFunc,
4081 CallInst *CI = dyn_cast<CallInst>(U);
4096 bool InvalidCast =
false;
4103 if (I < NewFuncTy->getNumParams()) {
4138 UpgradeToIntrinsic(
"clang.arc.use", llvm::Intrinsic::objc_clang_arc_use);
4146 std::pair<const char *, llvm::Intrinsic::ID> RuntimeFuncs[] = {
4147 {
"objc_autorelease", llvm::Intrinsic::objc_autorelease},
4148 {
"objc_autoreleasePoolPop", llvm::Intrinsic::objc_autoreleasePoolPop},
4149 {
"objc_autoreleasePoolPush", llvm::Intrinsic::objc_autoreleasePoolPush},
4150 {
"objc_autoreleaseReturnValue",
4151 llvm::Intrinsic::objc_autoreleaseReturnValue},
4152 {
"objc_copyWeak", llvm::Intrinsic::objc_copyWeak},
4153 {
"objc_destroyWeak", llvm::Intrinsic::objc_destroyWeak},
4154 {
"objc_initWeak", llvm::Intrinsic::objc_initWeak},
4155 {
"objc_loadWeak", llvm::Intrinsic::objc_loadWeak},
4156 {
"objc_loadWeakRetained", llvm::Intrinsic::objc_loadWeakRetained},
4157 {
"objc_moveWeak", llvm::Intrinsic::objc_moveWeak},
4158 {
"objc_release", llvm::Intrinsic::objc_release},
4159 {
"objc_retain", llvm::Intrinsic::objc_retain},
4160 {
"objc_retainAutorelease", llvm::Intrinsic::objc_retainAutorelease},
4161 {
"objc_retainAutoreleaseReturnValue",
4162 llvm::Intrinsic::objc_retainAutoreleaseReturnValue},
4163 {
"objc_retainAutoreleasedReturnValue",
4164 llvm::Intrinsic::objc_retainAutoreleasedReturnValue},
4165 {
"objc_retainBlock", llvm::Intrinsic::objc_retainBlock},
4166 {
"objc_storeStrong", llvm::Intrinsic::objc_storeStrong},
4167 {
"objc_storeWeak", llvm::Intrinsic::objc_storeWeak},
4168 {
"objc_unsafeClaimAutoreleasedReturnValue",
4169 llvm::Intrinsic::objc_unsafeClaimAutoreleasedReturnValue},
4170 {
"objc_retainedObject", llvm::Intrinsic::objc_retainedObject},
4171 {
"objc_unretainedObject", llvm::Intrinsic::objc_unretainedObject},
4172 {
"objc_unretainedPointer", llvm::Intrinsic::objc_unretainedPointer},
4173 {
"objc_retain_autorelease", llvm::Intrinsic::objc_retain_autorelease},
4174 {
"objc_sync_enter", llvm::Intrinsic::objc_sync_enter},
4175 {
"objc_sync_exit", llvm::Intrinsic::objc_sync_exit},
4176 {
"objc_arc_annotation_topdown_bbstart",
4177 llvm::Intrinsic::objc_arc_annotation_topdown_bbstart},
4178 {
"objc_arc_annotation_topdown_bbend",
4179 llvm::Intrinsic::objc_arc_annotation_topdown_bbend},
4180 {
"objc_arc_annotation_bottomup_bbstart",
4181 llvm::Intrinsic::objc_arc_annotation_bottomup_bbstart},
4182 {
"objc_arc_annotation_bottomup_bbend",
4183 llvm::Intrinsic::objc_arc_annotation_bottomup_bbend}};
4185 for (
auto &
I : RuntimeFuncs)
4186 UpgradeToIntrinsic(
I.first,
I.second);
4194 bool HasObjCFlag =
false, HasClassProperties =
false, Changed =
false;
4195 bool HasSwiftVersionFlag =
false;
4196 uint8_t SwiftMajorVersion, SwiftMinorVersion;
4203 if (
Op->getNumOperands() != 3)
4205 MDString *
ID = dyn_cast_or_null<MDString>(
Op->getOperand(1));
4208 if (
ID->getString() ==
"Objective-C Image Info Version")
4210 if (
ID->getString() ==
"Objective-C Class Properties")
4211 HasClassProperties =
true;
4214 if (
ID->getString() ==
"PIC Level" ||
ID->getString() ==
"PIE Level") {
4215 if (
auto *Behavior =
4216 mdconst::dyn_extract_or_null<ConstantInt>(
Op->getOperand(0))) {
4231 if (
ID->getString() ==
"Objective-C Image Info Section") {
4232 if (
auto *
Value = dyn_cast_or_null<MDString>(
Op->getOperand(2))) {
4234 Value->getString().split(ValueComp,
" ");
4235 if (ValueComp.size() != 1) {
4236 std::string NewValue;
4237 for (
auto &
S : ValueComp)
4238 NewValue +=
S.str();
4239 Metadata *Ops[3] = {
Op->getOperand(0),
Op->getOperand(1),
4249 if (
ID->getString() ==
"Objective-C Garbage Collection") {
4250 auto Md = dyn_cast<ConstantAsMetadata>(
Op->getOperand(2));