63#define DEBUG_TYPE "x86tti"
79 std::optional<unsigned>
164 bool Vector = (ClassID == 1);
183 if (ST->
hasAVX512() && ST->hasEVEX512() && PreferVectorWidth >= 512)
185 if (ST->
hasAVX() && PreferVectorWidth >= 256)
187 if (ST->
hasSSE1() && PreferVectorWidth >= 128)
228 if (Opcode == Instruction::Mul && Ty->
isVectorTy() &&
245 assert(ISD &&
"Invalid opcode");
247 if (ISD ==
ISD::MUL && Args.size() == 2 && LT.second.isVector() &&
248 (LT.second.getScalarType() == MVT::i32 ||
249 LT.second.getScalarType() == MVT::i64)) {
251 bool Op1Signed =
false, Op2Signed =
false;
254 unsigned OpMinSize = std::max(Op1MinSize, Op2MinSize);
255 bool SignedMode = Op1Signed || Op2Signed;
260 if (OpMinSize <= 15 && !ST->isPMADDWDSlow() &&
261 LT.second.getScalarType() == MVT::i32) {
263 isa<ConstantDataVector>(Args[0]) || isa<ConstantVector>(Args[0]);
265 isa<ConstantDataVector>(Args[1]) || isa<ConstantVector>(Args[1]);
266 bool Op1Sext = isa<SExtInst>(Args[0]) &&
267 (Op1MinSize == 15 || (Op1MinSize < 15 && !ST->
hasSSE41()));
268 bool Op2Sext = isa<SExtInst>(Args[1]) &&
269 (Op2MinSize == 15 || (Op2MinSize < 15 && !ST->
hasSSE41()));
271 bool IsZeroExtended = !Op1Signed || !Op2Signed;
272 bool IsConstant = Op1Constant || Op2Constant;
273 bool IsSext = Op1Sext || Op2Sext;
274 if (IsConstant || IsZeroExtended || IsSext)
282 if (ST->useSLMArithCosts() && LT.second == MVT::v4i32) {
285 if (!SignedMode && OpMinSize <= 8)
289 if (!SignedMode && OpMinSize <= 16)
296 if (!SignedMode && OpMinSize <= 32 && LT.second.getScalarType() == MVT::i64)
349 {
ISD::SHL, MVT::v16i8, { 1, 7, 2, 3 } },
350 {
ISD::SRL, MVT::v16i8, { 1, 7, 2, 3 } },
351 {
ISD::SRA, MVT::v16i8, { 1, 8, 4, 5 } },
352 {
ISD::SHL, MVT::v32i8, { 1, 8, 2, 3 } },
353 {
ISD::SRL, MVT::v32i8, { 1, 8, 2, 3 } },
354 {
ISD::SRA, MVT::v32i8, { 1, 9, 4, 5 } },
355 {
ISD::SHL, MVT::v64i8, { 1, 8, 2, 3 } },
356 {
ISD::SRL, MVT::v64i8, { 1, 8, 2, 3 } },
357 {
ISD::SRA, MVT::v64i8, { 1, 9, 4, 6 } },
359 {
ISD::SHL, MVT::v16i16, { 1, 1, 1, 1 } },
360 {
ISD::SRL, MVT::v16i16, { 1, 1, 1, 1 } },
361 {
ISD::SRA, MVT::v16i16, { 1, 1, 1, 1 } },
362 {
ISD::SHL, MVT::v32i16, { 1, 1, 1, 1 } },
363 {
ISD::SRL, MVT::v32i16, { 1, 1, 1, 1 } },
364 {
ISD::SRA, MVT::v32i16, { 1, 1, 1, 1 } },
368 if (
const auto *Entry =
370 if (
auto KindCost = Entry->Cost[
CostKind])
371 return LT.first * *KindCost;
374 {
ISD::SHL, MVT::v64i8, { 2, 12, 5, 6 } },
375 {
ISD::SRL, MVT::v64i8, { 2, 12, 5, 6 } },
376 {
ISD::SRA, MVT::v64i8, { 3, 10, 12, 12 } },
378 {
ISD::SHL, MVT::v16i16, { 2, 7, 4, 4 } },
379 {
ISD::SRL, MVT::v16i16, { 2, 7, 4, 4 } },
380 {
ISD::SRA, MVT::v16i16, { 2, 7, 4, 4 } },
382 {
ISD::SHL, MVT::v8i32, { 1, 1, 1, 1 } },
383 {
ISD::SRL, MVT::v8i32, { 1, 1, 1, 1 } },
384 {
ISD::SRA, MVT::v8i32, { 1, 1, 1, 1 } },
385 {
ISD::SHL, MVT::v16i32, { 1, 1, 1, 1 } },
386 {
ISD::SRL, MVT::v16i32, { 1, 1, 1, 1 } },
387 {
ISD::SRA, MVT::v16i32, { 1, 1, 1, 1 } },
389 {
ISD::SRA, MVT::v2i64, { 1, 1, 1, 1 } },
390 {
ISD::SHL, MVT::v4i64, { 1, 1, 1, 1 } },
391 {
ISD::SRL, MVT::v4i64, { 1, 1, 1, 1 } },
392 {
ISD::SRA, MVT::v4i64, { 1, 1, 1, 1 } },
393 {
ISD::SHL, MVT::v8i64, { 1, 1, 1, 1 } },
394 {
ISD::SRL, MVT::v8i64, { 1, 1, 1, 1 } },
395 {
ISD::SRA, MVT::v8i64, { 1, 1, 1, 1 } },
404 if (
const auto *Entry =
406 if (
auto KindCost = Entry->Cost[
CostKind])
407 return LT.first * *KindCost;
410 {
ISD::SHL, MVT::v16i8, { 1, 8, 2, 3 } },
411 {
ISD::SRL, MVT::v16i8, { 1, 8, 2, 3 } },
412 {
ISD::SRA, MVT::v16i8, { 2, 10, 5, 6 } },
413 {
ISD::SHL, MVT::v32i8, { 2, 8, 2, 4 } },
414 {
ISD::SRL, MVT::v32i8, { 2, 8, 2, 4 } },
415 {
ISD::SRA, MVT::v32i8, { 3, 10, 5, 9 } },
417 {
ISD::SHL, MVT::v8i16, { 1, 1, 1, 1 } },
418 {
ISD::SRL, MVT::v8i16, { 1, 1, 1, 1 } },
419 {
ISD::SRA, MVT::v8i16, { 1, 1, 1, 1 } },
420 {
ISD::SHL, MVT::v16i16,{ 2, 2, 1, 2 } },
421 {
ISD::SRL, MVT::v16i16,{ 2, 2, 1, 2 } },
422 {
ISD::SRA, MVT::v16i16,{ 2, 2, 1, 2 } },
424 {
ISD::SHL, MVT::v4i32, { 1, 1, 1, 1 } },
425 {
ISD::SRL, MVT::v4i32, { 1, 1, 1, 1 } },
426 {
ISD::SRA, MVT::v4i32, { 1, 1, 1, 1 } },
427 {
ISD::SHL, MVT::v8i32, { 2, 2, 1, 2 } },
428 {
ISD::SRL, MVT::v8i32, { 2, 2, 1, 2 } },
429 {
ISD::SRA, MVT::v8i32, { 2, 2, 1, 2 } },
431 {
ISD::SHL, MVT::v2i64, { 1, 1, 1, 1 } },
432 {
ISD::SRL, MVT::v2i64, { 1, 1, 1, 1 } },
433 {
ISD::SRA, MVT::v2i64, { 2, 3, 3, 3 } },
434 {
ISD::SHL, MVT::v4i64, { 2, 2, 1, 2 } },
435 {
ISD::SRL, MVT::v4i64, { 2, 2, 1, 2 } },
436 {
ISD::SRA, MVT::v4i64, { 4, 4, 3, 6 } },
445 if (
const auto *Entry =
447 if (
auto KindCost = Entry->Cost[
CostKind])
448 return LT.first * *KindCost;
451 {
ISD::SHL, MVT::v16i8, { 2, 7, 2, 3 } },
452 {
ISD::SRL, MVT::v16i8, { 2, 7, 2, 3 } },
453 {
ISD::SRA, MVT::v16i8, { 3, 9, 5, 6 } },
454 {
ISD::SHL, MVT::v32i8, { 4, 7, 7, 8 } },
455 {
ISD::SRL, MVT::v32i8, { 4, 7, 7, 8 } },
456 {
ISD::SRA, MVT::v32i8, { 7, 7, 12, 13 } },
458 {
ISD::SHL, MVT::v8i16, { 1, 2, 1, 1 } },
459 {
ISD::SRL, MVT::v8i16, { 1, 2, 1, 1 } },
460 {
ISD::SRA, MVT::v8i16, { 1, 2, 1, 1 } },
461 {
ISD::SHL, MVT::v16i16,{ 3, 6, 4, 5 } },
462 {
ISD::SRL, MVT::v16i16,{ 3, 6, 4, 5 } },
463 {
ISD::SRA, MVT::v16i16,{ 3, 6, 4, 5 } },
465 {
ISD::SHL, MVT::v4i32, { 1, 2, 1, 1 } },
466 {
ISD::SRL, MVT::v4i32, { 1, 2, 1, 1 } },
467 {
ISD::SRA, MVT::v4i32, { 1, 2, 1, 1 } },
468 {
ISD::SHL, MVT::v8i32, { 3, 6, 4, 5 } },
469 {
ISD::SRL, MVT::v8i32, { 3, 6, 4, 5 } },
470 {
ISD::SRA, MVT::v8i32, { 3, 6, 4, 5 } },
472 {
ISD::SHL, MVT::v2i64, { 1, 2, 1, 1 } },
473 {
ISD::SRL, MVT::v2i64, { 1, 2, 1, 1 } },
474 {
ISD::SRA, MVT::v2i64, { 2, 3, 3, 3 } },
475 {
ISD::SHL, MVT::v4i64, { 3, 6, 4, 5 } },
476 {
ISD::SRL, MVT::v4i64, { 3, 6, 4, 5 } },
477 {
ISD::SRA, MVT::v4i64, { 5, 7, 8, 9 } },
487 (!ST->hasXOP() || LT.second.getScalarSizeInBits() != 8))
488 if (
const auto *Entry =
490 if (
auto KindCost = Entry->Cost[
CostKind])
491 return LT.first * *KindCost;
494 {
ISD::SHL, MVT::v16i8, { 1, 7, 2, 3 } },
495 {
ISD::SRL, MVT::v16i8, { 1, 7, 2, 3 } },
496 {
ISD::SRA, MVT::v16i8, { 3, 9, 5, 6 } },
498 {
ISD::SHL, MVT::v8i16, { 1, 1, 1, 1 } },
499 {
ISD::SRL, MVT::v8i16, { 1, 1, 1, 1 } },
500 {
ISD::SRA, MVT::v8i16, { 1, 1, 1, 1 } },
502 {
ISD::SHL, MVT::v4i32, { 1, 1, 1, 1 } },
503 {
ISD::SRL, MVT::v4i32, { 1, 1, 1, 1 } },
504 {
ISD::SRA, MVT::v4i32, { 1, 1, 1, 1 } },
506 {
ISD::SHL, MVT::v2i64, { 1, 1, 1, 1 } },
507 {
ISD::SRL, MVT::v2i64, { 1, 1, 1, 1 } },
508 {
ISD::SRA, MVT::v2i64, { 3, 5, 6, 6 } },
518 (!ST->hasXOP() || LT.second.getScalarSizeInBits() != 8))
519 if (
const auto *Entry =
521 if (
auto KindCost = Entry->Cost[
CostKind])
522 return LT.first * *KindCost;
537 if (
const auto *Entry =
539 if (
auto KindCost = Entry->Cost[
CostKind])
540 return LT.first * *KindCost;
560 if (
const auto *Entry =
562 if (
auto KindCost = Entry->Cost[
CostKind])
563 return LT.first * *KindCost;
583 if (
const auto *Entry =
CostTableLookup(AVX2ConstCostTable, ISD, LT.second))
584 if (
auto KindCost = Entry->Cost[
CostKind])
585 return LT.first * *KindCost;
605 if (
const auto *Entry =
CostTableLookup(AVXConstCostTable, ISD, LT.second))
606 if (
auto KindCost = Entry->Cost[
CostKind])
607 return LT.first * *KindCost;
615 if (
const auto *Entry =
617 if (
auto KindCost = Entry->Cost[
CostKind])
618 return LT.first * *KindCost;
638 if (
const auto *Entry =
CostTableLookup(SSE2ConstCostTable, ISD, LT.second))
639 if (
auto KindCost = Entry->Cost[
CostKind])
640 return LT.first * *KindCost;
643 {
ISD::SHL, MVT::v16i8, { 3, 5, 5, 7 } },
644 {
ISD::SRL, MVT::v16i8, { 3,10, 5, 8 } },
645 {
ISD::SRA, MVT::v16i8, { 4,12, 8,12 } },
646 {
ISD::SHL, MVT::v32i8, { 4, 7, 6, 8 } },
647 {
ISD::SRL, MVT::v32i8, { 4, 8, 7, 9 } },
648 {
ISD::SRA, MVT::v32i8, { 5,10,10,13 } },
649 {
ISD::SHL, MVT::v64i8, { 4, 7, 6, 8 } },
650 {
ISD::SRL, MVT::v64i8, { 4, 8, 7,10 } },
651 {
ISD::SRA, MVT::v64i8, { 5,10,10,15 } },
653 {
ISD::SHL, MVT::v32i16, { 2, 4, 2, 3 } },
654 {
ISD::SRL, MVT::v32i16, { 2, 4, 2, 3 } },
655 {
ISD::SRA, MVT::v32i16, { 2, 4, 2, 3 } },
659 if (
const auto *Entry =
661 if (
auto KindCost = Entry->Cost[
CostKind])
662 return LT.first * *KindCost;
665 {
ISD::SHL, MVT::v32i16, { 5,10, 5, 7 } },
666 {
ISD::SRL, MVT::v32i16, { 5,10, 5, 7 } },
667 {
ISD::SRA, MVT::v32i16, { 5,10, 5, 7 } },
669 {
ISD::SHL, MVT::v16i32, { 2, 4, 2, 3 } },
670 {
ISD::SRL, MVT::v16i32, { 2, 4, 2, 3 } },
671 {
ISD::SRA, MVT::v16i32, { 2, 4, 2, 3 } },
673 {
ISD::SRA, MVT::v2i64, { 1, 2, 1, 2 } },
674 {
ISD::SHL, MVT::v4i64, { 1, 4, 1, 2 } },
675 {
ISD::SRL, MVT::v4i64, { 1, 4, 1, 2 } },
676 {
ISD::SRA, MVT::v4i64, { 1, 4, 1, 2 } },
677 {
ISD::SHL, MVT::v8i64, { 1, 4, 1, 2 } },
678 {
ISD::SRL, MVT::v8i64, { 1, 4, 1, 2 } },
679 {
ISD::SRA, MVT::v8i64, { 1, 4, 1, 2 } },
683 if (
const auto *Entry =
685 if (
auto KindCost = Entry->Cost[
CostKind])
686 return LT.first * *KindCost;
690 {
ISD::SHL, MVT::v16i8, { 3, 5, 5, 7 } },
691 {
ISD::SRL, MVT::v16i8, { 3, 9, 5, 8 } },
692 {
ISD::SRA, MVT::v16i8, { 4, 5, 9,13 } },
693 {
ISD::SHL, MVT::v32i8, { 4, 7, 6, 8 } },
694 {
ISD::SRL, MVT::v32i8, { 4, 8, 7, 9 } },
695 {
ISD::SRA, MVT::v32i8, { 6, 9,11,16 } },
697 {
ISD::SHL, MVT::v8i16, { 1, 2, 1, 2 } },
698 {
ISD::SRL, MVT::v8i16, { 1, 2, 1, 2 } },
699 {
ISD::SRA, MVT::v8i16, { 1, 2, 1, 2 } },
700 {
ISD::SHL, MVT::v16i16, { 2, 4, 2, 3 } },
701 {
ISD::SRL, MVT::v16i16, { 2, 4, 2, 3 } },
702 {
ISD::SRA, MVT::v16i16, { 2, 4, 2, 3 } },
704 {
ISD::SHL, MVT::v4i32, { 1, 2, 1, 2 } },
705 {
ISD::SRL, MVT::v4i32, { 1, 2, 1, 2 } },
706 {
ISD::SRA, MVT::v4i32, { 1, 2, 1, 2 } },
707 {
ISD::SHL, MVT::v8i32, { 2, 4, 2, 3 } },
708 {
ISD::SRL, MVT::v8i32, { 2, 4, 2, 3 } },
709 {
ISD::SRA, MVT::v8i32, { 2, 4, 2, 3 } },
711 {
ISD::SHL, MVT::v2i64, { 1, 2, 1, 2 } },
712 {
ISD::SRL, MVT::v2i64, { 1, 2, 1, 2 } },
713 {
ISD::SRA, MVT::v2i64, { 2, 4, 5, 7 } },
714 {
ISD::SHL, MVT::v4i64, { 2, 4, 1, 2 } },
715 {
ISD::SRL, MVT::v4i64, { 2, 4, 1, 2 } },
716 {
ISD::SRA, MVT::v4i64, { 4, 6, 5, 9 } },
720 if (
const auto *Entry =
722 if (
auto KindCost = Entry->Cost[
CostKind])
723 return LT.first * *KindCost;
726 {
ISD::SHL, MVT::v16i8, { 4, 4, 6, 8 } },
727 {
ISD::SRL, MVT::v16i8, { 4, 8, 5, 8 } },
728 {
ISD::SRA, MVT::v16i8, { 6, 6, 9,13 } },
729 {
ISD::SHL, MVT::v32i8, { 7, 8,11,14 } },
730 {
ISD::SRL, MVT::v32i8, { 7, 9,10,14 } },
731 {
ISD::SRA, MVT::v32i8, { 10,11,16,21 } },
733 {
ISD::SHL, MVT::v8i16, { 1, 3, 1, 2 } },
734 {
ISD::SRL, MVT::v8i16, { 1, 3, 1, 2 } },
735 {
ISD::SRA, MVT::v8i16, { 1, 3, 1, 2 } },
736 {
ISD::SHL, MVT::v16i16, { 3, 7, 5, 7 } },
737 {
ISD::SRL, MVT::v16i16, { 3, 7, 5, 7 } },
738 {
ISD::SRA, MVT::v16i16, { 3, 7, 5, 7 } },
740 {
ISD::SHL, MVT::v4i32, { 1, 3, 1, 2 } },
741 {
ISD::SRL, MVT::v4i32, { 1, 3, 1, 2 } },
742 {
ISD::SRA, MVT::v4i32, { 1, 3, 1, 2 } },
743 {
ISD::SHL, MVT::v8i32, { 3, 7, 5, 7 } },
744 {
ISD::SRL, MVT::v8i32, { 3, 7, 5, 7 } },
745 {
ISD::SRA, MVT::v8i32, { 3, 7, 5, 7 } },
747 {
ISD::SHL, MVT::v2i64, { 1, 3, 1, 2 } },
748 {
ISD::SRL, MVT::v2i64, { 1, 3, 1, 2 } },
749 {
ISD::SRA, MVT::v2i64, { 3, 4, 5, 7 } },
750 {
ISD::SHL, MVT::v4i64, { 3, 7, 4, 6 } },
751 {
ISD::SRL, MVT::v4i64, { 3, 7, 4, 6 } },
752 {
ISD::SRA, MVT::v4i64, { 6, 7,10,13 } },
757 (!ST->hasXOP() || LT.second.getScalarSizeInBits() != 8))
758 if (
const auto *Entry =
760 if (
auto KindCost = Entry->Cost[
CostKind])
761 return LT.first * *KindCost;
765 {
ISD::SHL, MVT::v16i8, { 9, 10, 6, 9 } },
766 {
ISD::SRL, MVT::v16i8, { 9, 13, 5, 9 } },
767 {
ISD::SRA, MVT::v16i8, { 11, 15, 9,13 } },
769 {
ISD::SHL, MVT::v8i16, { 2, 2, 1, 2 } },
770 {
ISD::SRL, MVT::v8i16, { 2, 2, 1, 2 } },
771 {
ISD::SRA, MVT::v8i16, { 2, 2, 1, 2 } },
773 {
ISD::SHL, MVT::v4i32, { 2, 2, 1, 2 } },
774 {
ISD::SRL, MVT::v4i32, { 2, 2, 1, 2 } },
775 {
ISD::SRA, MVT::v4i32, { 2, 2, 1, 2 } },
777 {
ISD::SHL, MVT::v2i64, { 2, 2, 1, 2 } },
778 {
ISD::SRL, MVT::v2i64, { 2, 2, 1, 2 } },
779 {
ISD::SRA, MVT::v2i64, { 5, 9, 5, 7 } },
783 (!ST->hasXOP() || LT.second.getScalarSizeInBits() != 8))
784 if (
const auto *Entry =
786 if (
auto KindCost = Entry->Cost[
CostKind])
787 return LT.first * *KindCost;
790 {
ISD::MUL, MVT::v2i64, { 2, 15, 1, 3 } },
791 {
ISD::MUL, MVT::v4i64, { 2, 15, 1, 3 } },
792 {
ISD::MUL, MVT::v8i64, { 3, 15, 1, 3 } }
797 if (
const auto *Entry =
CostTableLookup(AVX512DQCostTable, ISD, LT.second))
798 if (
auto KindCost = Entry->Cost[
CostKind])
799 return LT.first * *KindCost;
802 {
ISD::SHL, MVT::v16i8, { 4, 8, 4, 5 } },
803 {
ISD::SRL, MVT::v16i8, { 4, 8, 4, 5 } },
804 {
ISD::SRA, MVT::v16i8, { 4, 8, 4, 5 } },
805 {
ISD::SHL, MVT::v32i8, { 4, 23,11,16 } },
806 {
ISD::SRL, MVT::v32i8, { 4, 30,12,18 } },
807 {
ISD::SRA, MVT::v32i8, { 6, 13,24,30 } },
808 {
ISD::SHL, MVT::v64i8, { 6, 19,13,15 } },
809 {
ISD::SRL, MVT::v64i8, { 7, 27,15,18 } },
810 {
ISD::SRA, MVT::v64i8, { 15, 15,30,30 } },
812 {
ISD::SHL, MVT::v8i16, { 1, 1, 1, 1 } },
813 {
ISD::SRL, MVT::v8i16, { 1, 1, 1, 1 } },
814 {
ISD::SRA, MVT::v8i16, { 1, 1, 1, 1 } },
815 {
ISD::SHL, MVT::v16i16, { 1, 1, 1, 1 } },
816 {
ISD::SRL, MVT::v16i16, { 1, 1, 1, 1 } },
817 {
ISD::SRA, MVT::v16i16, { 1, 1, 1, 1 } },
818 {
ISD::SHL, MVT::v32i16, { 1, 1, 1, 1 } },
819 {
ISD::SRL, MVT::v32i16, { 1, 1, 1, 1 } },
820 {
ISD::SRA, MVT::v32i16, { 1, 1, 1, 1 } },
822 {
ISD::ADD, MVT::v64i8, { 1, 1, 1, 1 } },
823 {
ISD::ADD, MVT::v32i16, { 1, 1, 1, 1 } },
825 {
ISD::ADD, MVT::v32i8, { 1, 1, 1, 1 } },
826 {
ISD::ADD, MVT::v16i16, { 1, 1, 1, 1 } },
827 {
ISD::ADD, MVT::v8i32, { 1, 1, 1, 1 } },
828 {
ISD::ADD, MVT::v4i64, { 1, 1, 1, 1 } },
830 {
ISD::SUB, MVT::v64i8, { 1, 1, 1, 1 } },
831 {
ISD::SUB, MVT::v32i16, { 1, 1, 1, 1 } },
833 {
ISD::MUL, MVT::v64i8, { 5, 10,10,11 } },
834 {
ISD::MUL, MVT::v32i16, { 1, 5, 1, 1 } },
836 {
ISD::SUB, MVT::v32i8, { 1, 1, 1, 1 } },
837 {
ISD::SUB, MVT::v16i16, { 1, 1, 1, 1 } },
838 {
ISD::SUB, MVT::v8i32, { 1, 1, 1, 1 } },
839 {
ISD::SUB, MVT::v4i64, { 1, 1, 1, 1 } },
844 if (
const auto *Entry =
CostTableLookup(AVX512BWCostTable, ISD, LT.second))
845 if (
auto KindCost = Entry->Cost[
CostKind])
846 return LT.first * *KindCost;
849 {
ISD::SHL, MVT::v64i8, { 15, 19,27,33 } },
850 {
ISD::SRL, MVT::v64i8, { 15, 19,30,36 } },
851 {
ISD::SRA, MVT::v64i8, { 37, 37,51,63 } },
853 {
ISD::SHL, MVT::v32i16, { 11, 16,11,15 } },
854 {
ISD::SRL, MVT::v32i16, { 11, 16,11,15 } },
855 {
ISD::SRA, MVT::v32i16, { 11, 16,11,15 } },
857 {
ISD::SHL, MVT::v4i32, { 1, 1, 1, 1 } },
858 {
ISD::SRL, MVT::v4i32, { 1, 1, 1, 1 } },
859 {
ISD::SRA, MVT::v4i32, { 1, 1, 1, 1 } },
860 {
ISD::SHL, MVT::v8i32, { 1, 1, 1, 1 } },
861 {
ISD::SRL, MVT::v8i32, { 1, 1, 1, 1 } },
862 {
ISD::SRA, MVT::v8i32, { 1, 1, 1, 1 } },
863 {
ISD::SHL, MVT::v16i32, { 1, 1, 1, 1 } },
864 {
ISD::SRL, MVT::v16i32, { 1, 1, 1, 1 } },
865 {
ISD::SRA, MVT::v16i32, { 1, 1, 1, 1 } },
867 {
ISD::SHL, MVT::v2i64, { 1, 1, 1, 1 } },
868 {
ISD::SRL, MVT::v2i64, { 1, 1, 1, 1 } },
869 {
ISD::SRA, MVT::v2i64, { 1, 1, 1, 1 } },
870 {
ISD::SHL, MVT::v4i64, { 1, 1, 1, 1 } },
871 {
ISD::SRL, MVT::v4i64, { 1, 1, 1, 1 } },
872 {
ISD::SRA, MVT::v4i64, { 1, 1, 1, 1 } },
873 {
ISD::SHL, MVT::v8i64, { 1, 1, 1, 1 } },
874 {
ISD::SRL, MVT::v8i64, { 1, 1, 1, 1 } },
875 {
ISD::SRA, MVT::v8i64, { 1, 1, 1, 1 } },
877 {
ISD::ADD, MVT::v64i8, { 3, 7, 5, 5 } },
878 {
ISD::ADD, MVT::v32i16, { 3, 7, 5, 5 } },
880 {
ISD::SUB, MVT::v64i8, { 3, 7, 5, 5 } },
881 {
ISD::SUB, MVT::v32i16, { 3, 7, 5, 5 } },
883 {
ISD::AND, MVT::v32i8, { 1, 1, 1, 1 } },
884 {
ISD::AND, MVT::v16i16, { 1, 1, 1, 1 } },
885 {
ISD::AND, MVT::v8i32, { 1, 1, 1, 1 } },
886 {
ISD::AND, MVT::v4i64, { 1, 1, 1, 1 } },
888 {
ISD::OR, MVT::v32i8, { 1, 1, 1, 1 } },
889 {
ISD::OR, MVT::v16i16, { 1, 1, 1, 1 } },
890 {
ISD::OR, MVT::v8i32, { 1, 1, 1, 1 } },
891 {
ISD::OR, MVT::v4i64, { 1, 1, 1, 1 } },
893 {
ISD::XOR, MVT::v32i8, { 1, 1, 1, 1 } },
894 {
ISD::XOR, MVT::v16i16, { 1, 1, 1, 1 } },
895 {
ISD::XOR, MVT::v8i32, { 1, 1, 1, 1 } },
896 {
ISD::XOR, MVT::v4i64, { 1, 1, 1, 1 } },
898 {
ISD::MUL, MVT::v16i32, { 1, 10, 1, 2 } },
899 {
ISD::MUL, MVT::v8i32, { 1, 10, 1, 2 } },
900 {
ISD::MUL, MVT::v4i32, { 1, 10, 1, 2 } },
901 {
ISD::MUL, MVT::v8i64, { 6, 9, 8, 8 } },
906 {
ISD::FNEG, MVT::v8f64, { 1, 1, 1, 2 } },
907 {
ISD::FADD, MVT::v8f64, { 1, 4, 1, 1 } },
908 {
ISD::FADD, MVT::v4f64, { 1, 4, 1, 1 } },
909 {
ISD::FSUB, MVT::v8f64, { 1, 4, 1, 1 } },
910 {
ISD::FSUB, MVT::v4f64, { 1, 4, 1, 1 } },
911 {
ISD::FMUL, MVT::v8f64, { 1, 4, 1, 1 } },
912 {
ISD::FMUL, MVT::v4f64, { 1, 4, 1, 1 } },
913 {
ISD::FMUL, MVT::v2f64, { 1, 4, 1, 1 } },
916 {
ISD::FDIV, MVT::f64, { 4, 14, 1, 1 } },
917 {
ISD::FDIV, MVT::v2f64, { 4, 14, 1, 1 } },
918 {
ISD::FDIV, MVT::v4f64, { 8, 14, 1, 1 } },
919 {
ISD::FDIV, MVT::v8f64, { 16, 23, 1, 3 } },
921 {
ISD::FNEG, MVT::v16f32, { 1, 1, 1, 2 } },
922 {
ISD::FADD, MVT::v16f32, { 1, 4, 1, 1 } },
923 {
ISD::FADD, MVT::v8f32, { 1, 4, 1, 1 } },
924 {
ISD::FSUB, MVT::v16f32, { 1, 4, 1, 1 } },
925 {
ISD::FSUB, MVT::v8f32, { 1, 4, 1, 1 } },
926 {
ISD::FMUL, MVT::v16f32, { 1, 4, 1, 1 } },
927 {
ISD::FMUL, MVT::v8f32, { 1, 4, 1, 1 } },
928 {
ISD::FMUL, MVT::v4f32, { 1, 4, 1, 1 } },
931 {
ISD::FDIV, MVT::f32, { 3, 11, 1, 1 } },
932 {
ISD::FDIV, MVT::v4f32, { 3, 11, 1, 1 } },
933 {
ISD::FDIV, MVT::v8f32, { 5, 11, 1, 1 } },
934 {
ISD::FDIV, MVT::v16f32, { 10, 18, 1, 3 } },
938 if (
const auto *Entry =
CostTableLookup(AVX512CostTable, ISD, LT.second))
939 if (
auto KindCost = Entry->Cost[
CostKind])
940 return LT.first * *KindCost;
945 {
ISD::SHL, MVT::v4i32, { 2, 3, 1, 3 } },
946 {
ISD::SRL, MVT::v4i32, { 2, 3, 1, 3 } },
947 {
ISD::SRA, MVT::v4i32, { 2, 3, 1, 3 } },
948 {
ISD::SHL, MVT::v8i32, { 4, 4, 1, 3 } },
949 {
ISD::SRL, MVT::v8i32, { 4, 4, 1, 3 } },
950 {
ISD::SRA, MVT::v8i32, { 4, 4, 1, 3 } },
951 {
ISD::SHL, MVT::v2i64, { 2, 3, 1, 1 } },
952 {
ISD::SRL, MVT::v2i64, { 2, 3, 1, 1 } },
953 {
ISD::SHL, MVT::v4i64, { 4, 4, 1, 2 } },
954 {
ISD::SRL, MVT::v4i64, { 4, 4, 1, 2 } },
966 if (ST->
hasAVX2() && !(ST->hasXOP() && LT.second == MVT::v4i32)) {
967 if (ISD ==
ISD::SHL && LT.second == MVT::v16i16 &&
974 if (
const auto *Entry =
CostTableLookup(AVX2ShiftCostTable, ISD, LT.second))
975 if (
auto KindCost = Entry->Cost[
CostKind])
976 return LT.first * *KindCost;
981 {
ISD::SHL, MVT::v16i8, { 1, 3, 1, 1 } },
982 {
ISD::SRL, MVT::v16i8, { 2, 3, 1, 1 } },
983 {
ISD::SRA, MVT::v16i8, { 2, 3, 1, 1 } },
984 {
ISD::SHL, MVT::v8i16, { 1, 3, 1, 1 } },
985 {
ISD::SRL, MVT::v8i16, { 2, 3, 1, 1 } },
986 {
ISD::SRA, MVT::v8i16, { 2, 3, 1, 1 } },
987 {
ISD::SHL, MVT::v4i32, { 1, 3, 1, 1 } },
988 {
ISD::SRL, MVT::v4i32, { 2, 3, 1, 1 } },
989 {
ISD::SRA, MVT::v4i32, { 2, 3, 1, 1 } },
990 {
ISD::SHL, MVT::v2i64, { 1, 3, 1, 1 } },
991 {
ISD::SRL, MVT::v2i64, { 2, 3, 1, 1 } },
992 {
ISD::SRA, MVT::v2i64, { 2, 3, 1, 1 } },
994 {
ISD::SHL, MVT::v32i8, { 4, 7, 5, 6 } },
995 {
ISD::SRL, MVT::v32i8, { 6, 7, 5, 6 } },
996 {
ISD::SRA, MVT::v32i8, { 6, 7, 5, 6 } },
997 {
ISD::SHL, MVT::v16i16, { 4, 7, 5, 6 } },
998 {
ISD::SRL, MVT::v16i16, { 6, 7, 5, 6 } },
999 {
ISD::SRA, MVT::v16i16, { 6, 7, 5, 6 } },
1000 {
ISD::SHL, MVT::v8i32, { 4, 7, 5, 6 } },
1001 {
ISD::SRL, MVT::v8i32, { 6, 7, 5, 6 } },
1002 {
ISD::SRA, MVT::v8i32, { 6, 7, 5, 6 } },
1003 {
ISD::SHL, MVT::v4i64, { 4, 7, 5, 6 } },
1004 {
ISD::SRL, MVT::v4i64, { 6, 7, 5, 6 } },
1005 {
ISD::SRA, MVT::v4i64, { 6, 7, 5, 6 } },
1015 if (
const auto *Entry =
1017 if (
auto KindCost = Entry->Cost[
CostKind])
1018 return LT.first * *KindCost;
1025 if (((VT == MVT::v8i16 || VT == MVT::v4i32) && ST->
hasSSE2()) ||
1026 ((VT == MVT::v16i16 || VT == MVT::v8i32) && ST->
hasAVX()))
1031 {
ISD::FDIV, MVT::f32, { 18, 19, 1, 1 } },
1032 {
ISD::FDIV, MVT::v4f32, { 35, 36, 1, 1 } },
1033 {
ISD::FDIV, MVT::f64, { 33, 34, 1, 1 } },
1034 {
ISD::FDIV, MVT::v2f64, { 65, 66, 1, 1 } },
1037 if (ST->useGLMDivSqrtCosts())
1038 if (
const auto *Entry =
CostTableLookup(GLMCostTable, ISD, LT.second))
1039 if (
auto KindCost = Entry->Cost[
CostKind])
1040 return LT.first * *KindCost;
1043 {
ISD::MUL, MVT::v4i32, { 11, 11, 1, 7 } },
1044 {
ISD::MUL, MVT::v8i16, { 2, 5, 1, 1 } },
1045 {
ISD::FMUL, MVT::f64, { 2, 5, 1, 1 } },
1046 {
ISD::FMUL, MVT::f32, { 1, 4, 1, 1 } },
1047 {
ISD::FMUL, MVT::v2f64, { 4, 7, 1, 1 } },
1048 {
ISD::FMUL, MVT::v4f32, { 2, 5, 1, 1 } },
1049 {
ISD::FDIV, MVT::f32, { 17, 19, 1, 1 } },
1050 {
ISD::FDIV, MVT::v4f32, { 39, 39, 1, 6 } },
1051 {
ISD::FDIV, MVT::f64, { 32, 34, 1, 1 } },
1052 {
ISD::FDIV, MVT::v2f64, { 69, 69, 1, 6 } },
1053 {
ISD::FADD, MVT::v2f64, { 2, 4, 1, 1 } },
1054 {
ISD::FSUB, MVT::v2f64, { 2, 4, 1, 1 } },
1060 {
ISD::MUL, MVT::v2i64, { 17, 22, 9, 9 } },
1062 {
ISD::ADD, MVT::v2i64, { 4, 2, 1, 2 } },
1063 {
ISD::SUB, MVT::v2i64, { 4, 2, 1, 2 } },
1066 if (ST->useSLMArithCosts())
1067 if (
const auto *Entry =
CostTableLookup(SLMCostTable, ISD, LT.second))
1068 if (
auto KindCost = Entry->Cost[
CostKind])
1069 return LT.first * *KindCost;
1072 {
ISD::SHL, MVT::v16i8, { 6, 21,11,16 } },
1073 {
ISD::SHL, MVT::v32i8, { 6, 23,11,22 } },
1074 {
ISD::SHL, MVT::v8i16, { 5, 18, 5,10 } },
1075 {
ISD::SHL, MVT::v16i16, { 8, 10,10,14 } },
1077 {
ISD::SRL, MVT::v16i8, { 6, 27,12,18 } },
1078 {
ISD::SRL, MVT::v32i8, { 8, 30,12,24 } },
1079 {
ISD::SRL, MVT::v8i16, { 5, 11, 5,10 } },
1080 {
ISD::SRL, MVT::v16i16, { 8, 10,10,14 } },
1082 {
ISD::SRA, MVT::v16i8, { 17, 17,24,30 } },
1083 {
ISD::SRA, MVT::v32i8, { 18, 20,24,43 } },
1084 {
ISD::SRA, MVT::v8i16, { 5, 11, 5,10 } },
1085 {
ISD::SRA, MVT::v16i16, { 8, 10,10,14 } },
1086 {
ISD::SRA, MVT::v2i64, { 4, 5, 5, 5 } },
1087 {
ISD::SRA, MVT::v4i64, { 8, 8, 5, 9 } },
1089 {
ISD::SUB, MVT::v32i8, { 1, 1, 1, 2 } },
1090 {
ISD::ADD, MVT::v32i8, { 1, 1, 1, 2 } },
1091 {
ISD::SUB, MVT::v16i16, { 1, 1, 1, 2 } },
1092 {
ISD::ADD, MVT::v16i16, { 1, 1, 1, 2 } },
1093 {
ISD::SUB, MVT::v8i32, { 1, 1, 1, 2 } },
1094 {
ISD::ADD, MVT::v8i32, { 1, 1, 1, 2 } },
1095 {
ISD::SUB, MVT::v4i64, { 1, 1, 1, 2 } },
1096 {
ISD::ADD, MVT::v4i64, { 1, 1, 1, 2 } },
1098 {
ISD::MUL, MVT::v16i8, { 5, 18, 6,12 } },
1099 {
ISD::MUL, MVT::v32i8, { 6, 11,10,19 } },
1100 {
ISD::MUL, MVT::v16i16, { 2, 5, 1, 2 } },
1101 {
ISD::MUL, MVT::v8i32, { 4, 10, 1, 2 } },
1102 {
ISD::MUL, MVT::v4i32, { 2, 10, 1, 2 } },
1103 {
ISD::MUL, MVT::v4i64, { 6, 10, 8,13 } },
1104 {
ISD::MUL, MVT::v2i64, { 6, 10, 8, 8 } },
1108 {
ISD::FNEG, MVT::v4f64, { 1, 1, 1, 2 } },
1109 {
ISD::FNEG, MVT::v8f32, { 1, 1, 1, 2 } },
1111 {
ISD::FADD, MVT::f64, { 1, 4, 1, 1 } },
1112 {
ISD::FADD, MVT::f32, { 1, 4, 1, 1 } },
1113 {
ISD::FADD, MVT::v2f64, { 1, 4, 1, 1 } },
1114 {
ISD::FADD, MVT::v4f32, { 1, 4, 1, 1 } },
1115 {
ISD::FADD, MVT::v4f64, { 1, 4, 1, 2 } },
1116 {
ISD::FADD, MVT::v8f32, { 1, 4, 1, 2 } },
1118 {
ISD::FSUB, MVT::f64, { 1, 4, 1, 1 } },
1119 {
ISD::FSUB, MVT::f32, { 1, 4, 1, 1 } },
1120 {
ISD::FSUB, MVT::v2f64, { 1, 4, 1, 1 } },
1121 {
ISD::FSUB, MVT::v4f32, { 1, 4, 1, 1 } },
1122 {
ISD::FSUB, MVT::v4f64, { 1, 4, 1, 2 } },
1123 {
ISD::FSUB, MVT::v8f32, { 1, 4, 1, 2 } },
1125 {
ISD::FMUL, MVT::f64, { 1, 5, 1, 1 } },
1126 {
ISD::FMUL, MVT::f32, { 1, 5, 1, 1 } },
1127 {
ISD::FMUL, MVT::v2f64, { 1, 5, 1, 1 } },
1128 {
ISD::FMUL, MVT::v4f32, { 1, 5, 1, 1 } },
1129 {
ISD::FMUL, MVT::v4f64, { 1, 5, 1, 2 } },
1130 {
ISD::FMUL, MVT::v8f32, { 1, 5, 1, 2 } },
1132 {
ISD::FDIV, MVT::f32, { 7, 13, 1, 1 } },
1133 {
ISD::FDIV, MVT::v4f32, { 7, 13, 1, 1 } },
1134 {
ISD::FDIV, MVT::v8f32, { 14, 21, 1, 3 } },
1135 {
ISD::FDIV, MVT::f64, { 14, 20, 1, 1 } },
1136 {
ISD::FDIV, MVT::v2f64, { 14, 20, 1, 1 } },
1137 {
ISD::FDIV, MVT::v4f64, { 28, 35, 1, 3 } },
1142 if (
const auto *Entry =
CostTableLookup(AVX2CostTable, ISD, LT.second))
1143 if (
auto KindCost = Entry->Cost[
CostKind])
1144 return LT.first * *KindCost;
1150 {
ISD::MUL, MVT::v32i8, { 12, 13, 22, 23 } },
1151 {
ISD::MUL, MVT::v16i16, { 4, 8, 5, 6 } },
1152 {
ISD::MUL, MVT::v8i32, { 5, 8, 5, 10 } },
1153 {
ISD::MUL, MVT::v4i32, { 2, 5, 1, 3 } },
1154 {
ISD::MUL, MVT::v4i64, { 12, 15, 19, 20 } },
1156 {
ISD::AND, MVT::v32i8, { 1, 1, 1, 2 } },
1157 {
ISD::AND, MVT::v16i16, { 1, 1, 1, 2 } },
1158 {
ISD::AND, MVT::v8i32, { 1, 1, 1, 2 } },
1159 {
ISD::AND, MVT::v4i64, { 1, 1, 1, 2 } },
1161 {
ISD::OR, MVT::v32i8, { 1, 1, 1, 2 } },
1162 {
ISD::OR, MVT::v16i16, { 1, 1, 1, 2 } },
1163 {
ISD::OR, MVT::v8i32, { 1, 1, 1, 2 } },
1164 {
ISD::OR, MVT::v4i64, { 1, 1, 1, 2 } },
1166 {
ISD::XOR, MVT::v32i8, { 1, 1, 1, 2 } },
1167 {
ISD::XOR, MVT::v16i16, { 1, 1, 1, 2 } },
1168 {
ISD::XOR, MVT::v8i32, { 1, 1, 1, 2 } },
1169 {
ISD::XOR, MVT::v4i64, { 1, 1, 1, 2 } },
1171 {
ISD::SUB, MVT::v32i8, { 4, 2, 5, 6 } },
1172 {
ISD::ADD, MVT::v32i8, { 4, 2, 5, 6 } },
1173 {
ISD::SUB, MVT::v16i16, { 4, 2, 5, 6 } },
1174 {
ISD::ADD, MVT::v16i16, { 4, 2, 5, 6 } },
1175 {
ISD::SUB, MVT::v8i32, { 4, 2, 5, 6 } },
1176 {
ISD::ADD, MVT::v8i32, { 4, 2, 5, 6 } },
1177 {
ISD::SUB, MVT::v4i64, { 4, 2, 5, 6 } },
1178 {
ISD::ADD, MVT::v4i64, { 4, 2, 5, 6 } },
1179 {
ISD::SUB, MVT::v2i64, { 1, 1, 1, 1 } },
1180 {
ISD::ADD, MVT::v2i64, { 1, 1, 1, 1 } },
1182 {
ISD::SHL, MVT::v16i8, { 10, 21,11,17 } },
1183 {
ISD::SHL, MVT::v32i8, { 22, 22,27,40 } },
1184 {
ISD::SHL, MVT::v8i16, { 6, 9,11,11 } },
1185 {
ISD::SHL, MVT::v16i16, { 13, 16,24,25 } },
1186 {
ISD::SHL, MVT::v4i32, { 3, 11, 4, 6 } },
1187 {
ISD::SHL, MVT::v8i32, { 9, 11,12,17 } },
1188 {
ISD::SHL, MVT::v2i64, { 2, 4, 4, 6 } },
1189 {
ISD::SHL, MVT::v4i64, { 6, 7,11,15 } },
1191 {
ISD::SRL, MVT::v16i8, { 11, 27,12,18 } },
1192 {
ISD::SRL, MVT::v32i8, { 23, 23,30,43 } },
1193 {
ISD::SRL, MVT::v8i16, { 13, 16,14,22 } },
1194 {
ISD::SRL, MVT::v16i16, { 28, 30,31,48 } },
1195 {
ISD::SRL, MVT::v4i32, { 6, 7,12,16 } },
1196 {
ISD::SRL, MVT::v8i32, { 14, 14,26,34 } },
1197 {
ISD::SRL, MVT::v2i64, { 2, 4, 4, 6 } },
1198 {
ISD::SRL, MVT::v4i64, { 6, 7,11,15 } },
1200 {
ISD::SRA, MVT::v16i8, { 21, 22,24,36 } },
1201 {
ISD::SRA, MVT::v32i8, { 44, 45,51,76 } },
1202 {
ISD::SRA, MVT::v8i16, { 13, 16,14,22 } },
1203 {
ISD::SRA, MVT::v16i16, { 28, 30,31,48 } },
1204 {
ISD::SRA, MVT::v4i32, { 6, 7,12,16 } },
1205 {
ISD::SRA, MVT::v8i32, { 14, 14,26,34 } },
1206 {
ISD::SRA, MVT::v2i64, { 5, 6,10,14 } },
1207 {
ISD::SRA, MVT::v4i64, { 12, 12,22,30 } },
1209 {
ISD::FNEG, MVT::v4f64, { 2, 2, 1, 2 } },
1210 {
ISD::FNEG, MVT::v8f32, { 2, 2, 1, 2 } },
1212 {
ISD::FADD, MVT::f64, { 1, 5, 1, 1 } },
1213 {
ISD::FADD, MVT::f32, { 1, 5, 1, 1 } },
1214 {
ISD::FADD, MVT::v2f64, { 1, 5, 1, 1 } },
1215 {
ISD::FADD, MVT::v4f32, { 1, 5, 1, 1 } },
1216 {
ISD::FADD, MVT::v4f64, { 2, 5, 1, 2 } },
1217 {
ISD::FADD, MVT::v8f32, { 2, 5, 1, 2 } },
1219 {
ISD::FSUB, MVT::f64, { 1, 5, 1, 1 } },
1220 {
ISD::FSUB, MVT::f32, { 1, 5, 1, 1 } },
1221 {
ISD::FSUB, MVT::v2f64, { 1, 5, 1, 1 } },
1222 {
ISD::FSUB, MVT::v4f32, { 1, 5, 1, 1 } },
1223 {
ISD::FSUB, MVT::v4f64, { 2, 5, 1, 2 } },
1224 {
ISD::FSUB, MVT::v8f32, { 2, 5, 1, 2 } },
1226 {
ISD::FMUL, MVT::f64, { 2, 5, 1, 1 } },
1227 {
ISD::FMUL, MVT::f32, { 1, 5, 1, 1 } },
1228 {
ISD::FMUL, MVT::v2f64, { 2, 5, 1, 1 } },
1229 {
ISD::FMUL, MVT::v4f32, { 1, 5, 1, 1 } },
1230 {
ISD::FMUL, MVT::v4f64, { 4, 5, 1, 2 } },
1231 {
ISD::FMUL, MVT::v8f32, { 2, 5, 1, 2 } },
1233 {
ISD::FDIV, MVT::f32, { 14, 14, 1, 1 } },
1234 {
ISD::FDIV, MVT::v4f32, { 14, 14, 1, 1 } },
1235 {
ISD::FDIV, MVT::v8f32, { 28, 29, 1, 3 } },
1236 {
ISD::FDIV, MVT::f64, { 22, 22, 1, 1 } },
1237 {
ISD::FDIV, MVT::v2f64, { 22, 22, 1, 1 } },
1238 {
ISD::FDIV, MVT::v4f64, { 44, 45, 1, 3 } },
1242 if (
const auto *Entry =
CostTableLookup(AVX1CostTable, ISD, LT.second))
1243 if (
auto KindCost = Entry->Cost[
CostKind])
1244 return LT.first * *KindCost;
1247 {
ISD::FADD, MVT::f64, { 1, 3, 1, 1 } },
1248 {
ISD::FADD, MVT::f32, { 1, 3, 1, 1 } },
1249 {
ISD::FADD, MVT::v2f64, { 1, 3, 1, 1 } },
1250 {
ISD::FADD, MVT::v4f32, { 1, 3, 1, 1 } },
1252 {
ISD::FSUB, MVT::f64, { 1, 3, 1, 1 } },
1253 {
ISD::FSUB, MVT::f32 , { 1, 3, 1, 1 } },
1254 {
ISD::FSUB, MVT::v2f64, { 1, 3, 1, 1 } },
1255 {
ISD::FSUB, MVT::v4f32, { 1, 3, 1, 1 } },
1257 {
ISD::FMUL, MVT::f64, { 1, 5, 1, 1 } },
1258 {
ISD::FMUL, MVT::f32, { 1, 5, 1, 1 } },
1259 {
ISD::FMUL, MVT::v2f64, { 1, 5, 1, 1 } },
1260 {
ISD::FMUL, MVT::v4f32, { 1, 5, 1, 1 } },
1262 {
ISD::FDIV, MVT::f32, { 14, 14, 1, 1 } },
1263 {
ISD::FDIV, MVT::v4f32, { 14, 14, 1, 1 } },
1264 {
ISD::FDIV, MVT::f64, { 22, 22, 1, 1 } },
1265 {
ISD::FDIV, MVT::v2f64, { 22, 22, 1, 1 } },
1267 {
ISD::MUL, MVT::v2i64, { 6, 10,10,10 } }
1271 if (
const auto *Entry =
CostTableLookup(SSE42CostTable, ISD, LT.second))
1272 if (
auto KindCost = Entry->Cost[
CostKind])
1273 return LT.first * *KindCost;
1276 {
ISD::SHL, MVT::v16i8, { 15, 24,17,22 } },
1277 {
ISD::SHL, MVT::v8i16, { 11, 14,11,11 } },
1278 {
ISD::SHL, MVT::v4i32, { 14, 20, 4,10 } },
1280 {
ISD::SRL, MVT::v16i8, { 16, 27,18,24 } },
1281 {
ISD::SRL, MVT::v8i16, { 22, 26,23,27 } },
1282 {
ISD::SRL, MVT::v4i32, { 16, 17,15,19 } },
1283 {
ISD::SRL, MVT::v2i64, { 4, 6, 5, 7 } },
1285 {
ISD::SRA, MVT::v16i8, { 38, 41,30,36 } },
1286 {
ISD::SRA, MVT::v8i16, { 22, 26,23,27 } },
1287 {
ISD::SRA, MVT::v4i32, { 16, 17,15,19 } },
1288 {
ISD::SRA, MVT::v2i64, { 8, 17, 5, 7 } },
1290 {
ISD::MUL, MVT::v16i8, { 5, 18,10,12 } },
1291 {
ISD::MUL, MVT::v4i32, { 2, 11, 1, 1 } }
1295 if (
const auto *Entry =
CostTableLookup(SSE41CostTable, ISD, LT.second))
1296 if (
auto KindCost = Entry->Cost[
CostKind])
1297 return LT.first * *KindCost;
1302 {
ISD::SHL, MVT::v16i8, { 13, 21,26,28 } },
1303 {
ISD::SHL, MVT::v8i16, { 24, 27,16,20 } },
1304 {
ISD::SHL, MVT::v4i32, { 17, 19,10,12 } },
1305 {
ISD::SHL, MVT::v2i64, { 4, 6, 5, 7 } },
1307 {
ISD::SRL, MVT::v16i8, { 14, 28,27,30 } },
1308 {
ISD::SRL, MVT::v8i16, { 16, 19,31,31 } },
1309 {
ISD::SRL, MVT::v4i32, { 12, 12,15,19 } },
1310 {
ISD::SRL, MVT::v2i64, { 4, 6, 5, 7 } },
1312 {
ISD::SRA, MVT::v16i8, { 27, 30,54,54 } },
1313 {
ISD::SRA, MVT::v8i16, { 16, 19,31,31 } },
1314 {
ISD::SRA, MVT::v4i32, { 12, 12,15,19 } },
1315 {
ISD::SRA, MVT::v2i64, { 8, 11,12,16 } },
1317 {
ISD::AND, MVT::v16i8, { 1, 1, 1, 1 } },
1318 {
ISD::AND, MVT::v8i16, { 1, 1, 1, 1 } },
1319 {
ISD::AND, MVT::v4i32, { 1, 1, 1, 1 } },
1320 {
ISD::AND, MVT::v2i64, { 1, 1, 1, 1 } },
1322 {
ISD::OR, MVT::v16i8, { 1, 1, 1, 1 } },
1323 {
ISD::OR, MVT::v8i16, { 1, 1, 1, 1 } },
1324 {
ISD::OR, MVT::v4i32, { 1, 1, 1, 1 } },
1325 {
ISD::OR, MVT::v2i64, { 1, 1, 1, 1 } },
1327 {
ISD::XOR, MVT::v16i8, { 1, 1, 1, 1 } },
1328 {
ISD::XOR, MVT::v8i16, { 1, 1, 1, 1 } },
1329 {
ISD::XOR, MVT::v4i32, { 1, 1, 1, 1 } },
1330 {
ISD::XOR, MVT::v2i64, { 1, 1, 1, 1 } },
1332 {
ISD::ADD, MVT::v2i64, { 1, 2, 1, 2 } },
1333 {
ISD::SUB, MVT::v2i64, { 1, 2, 1, 2 } },
1335 {
ISD::MUL, MVT::v16i8, { 5, 18,12,12 } },
1336 {
ISD::MUL, MVT::v8i16, { 1, 5, 1, 1 } },
1337 {
ISD::MUL, MVT::v4i32, { 6, 8, 7, 7 } },
1338 {
ISD::MUL, MVT::v2i64, { 7, 10,10,10 } },
1342 {
ISD::FDIV, MVT::f32, { 23, 23, 1, 1 } },
1343 {
ISD::FDIV, MVT::v4f32, { 39, 39, 1, 1 } },
1344 {
ISD::FDIV, MVT::f64, { 38, 38, 1, 1 } },
1345 {
ISD::FDIV, MVT::v2f64, { 69, 69, 1, 1 } },
1347 {
ISD::FNEG, MVT::f32, { 1, 1, 1, 1 } },
1348 {
ISD::FNEG, MVT::f64, { 1, 1, 1, 1 } },
1349 {
ISD::FNEG, MVT::v4f32, { 1, 1, 1, 1 } },
1350 {
ISD::FNEG, MVT::v2f64, { 1, 1, 1, 1 } },
1352 {
ISD::FADD, MVT::f32, { 2, 3, 1, 1 } },
1353 {
ISD::FADD, MVT::f64, { 2, 3, 1, 1 } },
1354 {
ISD::FADD, MVT::v2f64, { 2, 3, 1, 1 } },
1356 {
ISD::FSUB, MVT::f32, { 2, 3, 1, 1 } },
1357 {
ISD::FSUB, MVT::f64, { 2, 3, 1, 1 } },
1358 {
ISD::FSUB, MVT::v2f64, { 2, 3, 1, 1 } },
1360 {
ISD::FMUL, MVT::f64, { 2, 5, 1, 1 } },
1361 {
ISD::FMUL, MVT::v2f64, { 2, 5, 1, 1 } },
1365 if (
const auto *Entry =
CostTableLookup(SSE2CostTable, ISD, LT.second))
1366 if (
auto KindCost = Entry->Cost[
CostKind])
1367 return LT.first * *KindCost;
1370 {
ISD::FDIV, MVT::f32, { 17, 18, 1, 1 } },
1371 {
ISD::FDIV, MVT::v4f32, { 34, 48, 1, 1 } },
1373 {
ISD::FNEG, MVT::f32, { 2, 2, 1, 2 } },
1374 {
ISD::FNEG, MVT::v4f32, { 2, 2, 1, 2 } },
1376 {
ISD::FADD, MVT::f32, { 1, 3, 1, 1 } },
1377 {
ISD::FADD, MVT::v4f32, { 2, 3, 1, 1 } },
1379 {
ISD::FSUB, MVT::f32, { 1, 3, 1, 1 } },
1380 {
ISD::FSUB, MVT::v4f32, { 2, 3, 1, 1 } },
1382 {
ISD::FMUL, MVT::f32, { 2, 5, 1, 1 } },
1383 {
ISD::FMUL, MVT::v4f32, { 2, 5, 1, 1 } },
1387 if (
const auto *Entry =
CostTableLookup(SSE1CostTable, ISD, LT.second))
1388 if (
auto KindCost = Entry->Cost[
CostKind])
1389 return LT.first * *KindCost;
1394 {
ISD::MUL, MVT::i64, { 2, 6, 1, 2 } },
1399 if (
auto KindCost = Entry->Cost[
CostKind])
1400 return LT.first * *KindCost;
1411 {
ISD::MUL, MVT::i8, { 3, 4, 1, 1 } },
1412 {
ISD::MUL, MVT::i16, { 2, 4, 1, 1 } },
1413 {
ISD::MUL, MVT::i32, { 1, 4, 1, 1 } },
1415 {
ISD::FNEG, MVT::f64, { 2, 2, 1, 3 } },
1416 {
ISD::FADD, MVT::f64, { 2, 3, 1, 1 } },
1417 {
ISD::FSUB, MVT::f64, { 2, 3, 1, 1 } },
1418 {
ISD::FMUL, MVT::f64, { 2, 5, 1, 1 } },
1419 {
ISD::FDIV, MVT::f64, { 38, 38, 1, 1 } },
1423 if (
auto KindCost = Entry->Cost[
CostKind])
1424 return LT.first * *KindCost;
1438 return 20 * LT.first * LT.second.getVectorNumElements() * ScalarCost;
1487 CostKind, Mask.size() / 2, BaseTp);
1500 if (LT.second.isVector() && LT.second.getScalarType() == MVT::bf16)
1501 LT.second = LT.second.changeVectorElementType(MVT::f16);
1506 int NumElts = LT.second.getVectorNumElements();
1507 if ((
Index % NumElts) == 0)
1510 if (SubLT.second.isVector()) {
1511 int NumSubElts = SubLT.second.getVectorNumElements();
1512 if ((
Index % NumSubElts) == 0 && (NumElts % NumSubElts) == 0)
1520 int OrigSubElts = cast<FixedVectorType>(SubTp)->getNumElements();
1521 if (NumSubElts > OrigSubElts && (
Index % OrigSubElts) == 0 &&
1522 (NumSubElts % OrigSubElts) == 0 &&
1523 LT.second.getVectorElementType() ==
1524 SubLT.second.getVectorElementType() &&
1525 LT.second.getVectorElementType().getSizeInBits() ==
1527 assert(NumElts >= NumSubElts && NumElts > OrigSubElts &&
1528 "Unexpected number of elements!");
1530 LT.second.getVectorNumElements());
1532 SubLT.second.getVectorNumElements());
1541 return ExtractCost + 1;
1544 "Unexpected vector size");
1546 return ExtractCost + 2;
1557 int NumElts = LT.second.getVectorNumElements();
1559 if (SubLT.second.isVector()) {
1560 int NumSubElts = SubLT.second.getVectorNumElements();
1561 if ((
Index % NumSubElts) == 0 && (NumElts % NumSubElts) == 0)
1574 static const CostTblEntry SSE2SubVectorShuffleTbl[] = {
1605 if (
const auto *Entry =
1614 MVT LegalVT = LT.second;
1619 cast<FixedVectorType>(BaseTp)->getNumElements()) {
1623 unsigned NumOfSrcs = (VecTySize + LegalVTSize - 1) / LegalVTSize;
1630 if (!Mask.empty() && NumOfDests.
isValid()) {
1648 unsigned E = *NumOfDests.
getValue();
1649 unsigned NormalizedVF =
1655 unsigned PrevSrcReg = 0;
1659 NormalizedMask, NumOfSrcRegs, NumOfDestRegs, NumOfDestRegs, []() {},
1660 [
this, SingleOpTy,
CostKind, &PrevSrcReg, &PrevRegMask,
1665 if (PrevRegMask.
empty() || PrevSrcReg != SrcReg ||
1666 PrevRegMask != RegMask)
1674 if (SrcReg != DestReg &&
1679 PrevSrcReg = SrcReg;
1680 PrevRegMask = RegMask;
1693 std::nullopt,
CostKind, 0,
nullptr);
1704 LT.first = NumOfDests * NumOfShufflesPerDest;
1720 if (
const auto *Entry =
1722 return LT.first * Entry->Cost;
1755 if (
const auto *Entry =
1757 return LT.first * Entry->Cost;
1834 if (
const auto *Entry =
CostTableLookup(AVX512ShuffleTbl, Kind, LT.second))
1835 if (
auto KindCost = Entry->Cost[
CostKind])
1836 return LT.first * *KindCost;
1889 if (
const auto *Entry =
CostTableLookup(AVX2ShuffleTbl, Kind, LT.second))
1890 return LT.first * Entry->Cost;
1911 if (
const auto *Entry =
CostTableLookup(XOPShuffleTbl, Kind, LT.second))
1912 return LT.first * Entry->Cost;
1974 if (
const auto *Entry =
CostTableLookup(AVX1ShuffleTbl, Kind, LT.second))
1975 return LT.first * Entry->Cost;
1988 if (
const auto *Entry =
CostTableLookup(SSE41ShuffleTbl, Kind, LT.second))
1989 return LT.first * Entry->Cost;
2020 if (
const auto *Entry =
CostTableLookup(SSSE3ShuffleTbl, Kind, LT.second))
2021 return LT.first * Entry->Cost;
2077 llvm::any_of(Args, [](
const auto &V) {
return isa<LoadInst>(V); });
2079 if (
const auto *Entry =
2082 LT.second.getVectorElementCount()) &&
2083 "Table entry missing from isLegalBroadcastLoad()");
2084 return LT.first * Entry->Cost;
2087 if (
const auto *Entry =
CostTableLookup(SSE2ShuffleTbl, Kind, LT.second))
2088 return LT.first * Entry->Cost;
2101 if (
const auto *Entry =
CostTableLookup(SSE1ShuffleTbl, Kind, LT.second))
2102 return LT.first * Entry->Cost;
2113 assert(ISD &&
"Invalid opcode");
2118 return Cost == 0 ? 0 : 1;
2933 AVX512BWConversionTbl, ISD, SimpleDstTy, SimpleSrcTy))
2934 return AdjustCost(Entry->Cost);
2938 AVX512DQConversionTbl, ISD, SimpleDstTy, SimpleSrcTy))
2939 return AdjustCost(Entry->Cost);
2943 AVX512FConversionTbl, ISD, SimpleDstTy, SimpleSrcTy))
2944 return AdjustCost(Entry->Cost);
2949 AVX512BWVLConversionTbl, ISD, SimpleDstTy, SimpleSrcTy))
2950 return AdjustCost(Entry->Cost);
2954 AVX512DQVLConversionTbl, ISD, SimpleDstTy, SimpleSrcTy))
2955 return AdjustCost(Entry->Cost);
2959 SimpleDstTy, SimpleSrcTy))
2960 return AdjustCost(Entry->Cost);
2964 SimpleDstTy, SimpleSrcTy))
2965 return AdjustCost(Entry->Cost);
2970 SimpleDstTy, SimpleSrcTy))
2971 return AdjustCost(Entry->Cost);
2976 SimpleDstTy, SimpleSrcTy))
2977 return AdjustCost(Entry->Cost);
2982 SimpleDstTy, SimpleSrcTy))
2983 return AdjustCost(Entry->Cost);
2998 AVX512BWConversionTbl, ISD, LTDest.second, LTSrc.second))
2999 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3003 AVX512DQConversionTbl, ISD, LTDest.second, LTSrc.second))
3004 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3008 AVX512FConversionTbl, ISD, LTDest.second, LTSrc.second))
3009 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3014 LTDest.second, LTSrc.second))
3015 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3019 LTDest.second, LTSrc.second))
3020 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3024 LTDest.second, LTSrc.second))
3025 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3029 LTDest.second, LTSrc.second))
3030 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3034 LTDest.second, LTSrc.second))
3035 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3039 LTDest.second, LTSrc.second))
3040 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3044 LTDest.second, LTSrc.second))
3045 return AdjustCost(std::max(LTSrc.first, LTDest.first) * Entry->Cost);
3050 1 < Src->getScalarSizeInBits() && Src->getScalarSizeInBits() < 32) {
3051 Type *ExtSrc = Src->getWithNewBitWidth(32);
3057 if (!(Src->isIntegerTy() &&
I && isa<LoadInst>(
I->getOperand(0))))
3067 1 < Dst->getScalarSizeInBits() && Dst->getScalarSizeInBits() < 32) {
3068 Type *TruncDst = Dst->getWithNewBitWidth(32);
3091 MVT MTy = LT.second;
3094 assert(ISD &&
"Invalid opcode");
3097 if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp) {
3110 Pred = cast<CmpInst>(
I)->getPredicate();
3112 bool CmpWithConstant =
false;
3113 if (
auto *CmpInstr = dyn_cast_or_null<CmpInst>(
I))
3114 CmpWithConstant = isa<Constant>(CmpInstr->getOperand(1));
3119 ExtraCost = CmpWithConstant ? 0 : 1;
3124 ExtraCost = CmpWithConstant ? 0 : 1;
3130 ExtraCost = CmpWithConstant ? 1 : 2;
3141 ExtraCost = CmpWithConstant ? 2 : 3;
3148 if (CondTy && !ST->
hasAVX())
3317 if (ST->useSLMArithCosts())
3319 if (
auto KindCost = Entry->Cost[
CostKind])
3320 return LT.first * (ExtraCost + *KindCost);
3324 if (
auto KindCost = Entry->Cost[
CostKind])
3325 return LT.first * (ExtraCost + *KindCost);
3329 if (
auto KindCost = Entry->Cost[
CostKind])
3330 return LT.first * (ExtraCost + *KindCost);
3334 if (
auto KindCost = Entry->Cost[
CostKind])
3335 return LT.first * (ExtraCost + *KindCost);
3339 if (
auto KindCost = Entry->Cost[
CostKind])
3340 return LT.first * (ExtraCost + *KindCost);
3344 if (
auto KindCost = Entry->Cost[
CostKind])
3345 return LT.first * (ExtraCost + *KindCost);
3349 if (
auto KindCost = Entry->Cost[
CostKind])
3350 return LT.first * (ExtraCost + *KindCost);
3354 if (
auto KindCost = Entry->Cost[
CostKind])
3355 return LT.first * (ExtraCost + *KindCost);
3359 if (
auto KindCost = Entry->Cost[
CostKind])
3360 return LT.first * (ExtraCost + *KindCost);
3364 if (
auto KindCost = Entry->Cost[
CostKind])
3365 return LT.first * (ExtraCost + *KindCost);
3390 {
ISD::FSHL, MVT::v8i64, { 1, 1, 1, 1 } },
3391 {
ISD::FSHL, MVT::v4i64, { 1, 1, 1, 1 } },
3392 {
ISD::FSHL, MVT::v2i64, { 1, 1, 1, 1 } },
3393 {
ISD::FSHL, MVT::v16i32, { 1, 1, 1, 1 } },
3394 {
ISD::FSHL, MVT::v8i32, { 1, 1, 1, 1 } },
3395 {
ISD::FSHL, MVT::v4i32, { 1, 1, 1, 1 } },
3396 {
ISD::FSHL, MVT::v32i16, { 1, 1, 1, 1 } },
3397 {
ISD::FSHL, MVT::v16i16, { 1, 1, 1, 1 } },
3398 {
ISD::FSHL, MVT::v8i16, { 1, 1, 1, 1 } },
3399 {
ISD::ROTL, MVT::v32i16, { 1, 1, 1, 1 } },
3400 {
ISD::ROTL, MVT::v16i16, { 1, 1, 1, 1 } },
3401 {
ISD::ROTL, MVT::v8i16, { 1, 1, 1, 1 } },
3402 {
ISD::ROTR, MVT::v32i16, { 1, 1, 1, 1 } },
3403 {
ISD::ROTR, MVT::v16i16, { 1, 1, 1, 1 } },
3404 {
ISD::ROTR, MVT::v8i16, { 1, 1, 1, 1 } },
3426 {
ISD::CTLZ, MVT::v8i64, { 1, 5, 1, 1 } },
3427 {
ISD::CTLZ, MVT::v16i32, { 1, 5, 1, 1 } },
3428 {
ISD::CTLZ, MVT::v32i16, { 18, 27, 23, 27 } },
3429 {
ISD::CTLZ, MVT::v64i8, { 3, 16, 9, 11 } },
3430 {
ISD::CTLZ, MVT::v4i64, { 1, 5, 1, 1 } },
3431 {
ISD::CTLZ, MVT::v8i32, { 1, 5, 1, 1 } },
3432 {
ISD::CTLZ, MVT::v16i16, { 8, 19, 11, 13 } },
3433 {
ISD::CTLZ, MVT::v32i8, { 2, 11, 9, 10 } },
3434 {
ISD::CTLZ, MVT::v2i64, { 1, 5, 1, 1 } },
3435 {
ISD::CTLZ, MVT::v4i32, { 1, 5, 1, 1 } },
3436 {
ISD::CTLZ, MVT::v8i16, { 3, 15, 4, 6 } },
3437 {
ISD::CTLZ, MVT::v16i8, { 2, 10, 9, 10 } },
3439 {
ISD::CTTZ, MVT::v8i64, { 2, 8, 6, 7 } },
3440 {
ISD::CTTZ, MVT::v16i32, { 2, 8, 6, 7 } },
3441 {
ISD::CTTZ, MVT::v4i64, { 1, 8, 6, 6 } },
3442 {
ISD::CTTZ, MVT::v8i32, { 1, 8, 6, 6 } },
3443 {
ISD::CTTZ, MVT::v2i64, { 1, 8, 6, 6 } },
3444 {
ISD::CTTZ, MVT::v4i32, { 1, 8, 6, 6 } },
3447 {
ISD::ABS, MVT::v32i16, { 1, 1, 1, 1 } },
3448 {
ISD::ABS, MVT::v64i8, { 1, 1, 1, 1 } },
3470 {
ISD::CTLZ, MVT::v8i64, { 8, 22, 23, 23 } },
3471 {
ISD::CTLZ, MVT::v16i32, { 8, 23, 25, 25 } },
3472 {
ISD::CTLZ, MVT::v32i16, { 4, 15, 15, 16 } },
3473 {
ISD::CTLZ, MVT::v64i8, { 3, 12, 10, 9 } },
3474 {
ISD::CTPOP, MVT::v2i64, { 3, 7, 10, 10 } },
3475 {
ISD::CTPOP, MVT::v4i64, { 3, 7, 10, 10 } },
3476 {
ISD::CTPOP, MVT::v8i64, { 3, 8, 10, 12 } },
3477 {
ISD::CTPOP, MVT::v4i32, { 7, 11, 14, 14 } },
3478 {
ISD::CTPOP, MVT::v8i32, { 7, 11, 14, 14 } },
3479 {
ISD::CTPOP, MVT::v16i32, { 7, 12, 14, 16 } },
3480 {
ISD::CTPOP, MVT::v8i16, { 2, 7, 11, 11 } },
3481 {
ISD::CTPOP, MVT::v16i16, { 2, 7, 11, 11 } },
3482 {
ISD::CTPOP, MVT::v32i16, { 3, 7, 11, 13 } },
3486 {
ISD::CTTZ, MVT::v8i16, { 3, 9, 14, 14 } },
3487 {
ISD::CTTZ, MVT::v16i16, { 3, 9, 14, 14 } },
3488 {
ISD::CTTZ, MVT::v32i16, { 3, 10, 14, 16 } },
3489 {
ISD::CTTZ, MVT::v16i8, { 2, 6, 11, 11 } },
3490 {
ISD::CTTZ, MVT::v32i8, { 2, 6, 11, 11 } },
3491 {
ISD::CTTZ, MVT::v64i8, { 3, 7, 11, 13 } },
3492 {
ISD::ROTL, MVT::v32i16, { 2, 8, 6, 8 } },
3493 {
ISD::ROTL, MVT::v16i16, { 2, 8, 6, 7 } },
3494 {
ISD::ROTL, MVT::v8i16, { 2, 7, 6, 7 } },
3495 {
ISD::ROTL, MVT::v64i8, { 5, 6, 11, 12 } },
3496 {
ISD::ROTL, MVT::v32i8, { 5, 15, 7, 10 } },
3497 {
ISD::ROTL, MVT::v16i8, { 5, 15, 7, 10 } },
3498 {
ISD::ROTR, MVT::v32i16, { 2, 8, 6, 8 } },
3499 {
ISD::ROTR, MVT::v16i16, { 2, 8, 6, 7 } },
3500 {
ISD::ROTR, MVT::v8i16, { 2, 7, 6, 7 } },
3501 {
ISD::ROTR, MVT::v64i8, { 5, 6, 12, 14 } },
3502 {
ISD::ROTR, MVT::v32i8, { 5, 14, 6, 9 } },
3503 {
ISD::ROTR, MVT::v16i8, { 5, 14, 6, 9 } },
3512 {
ISD::SMAX, MVT::v32i16, { 1, 1, 1, 1 } },
3513 {
ISD::SMAX, MVT::v64i8, { 1, 1, 1, 1 } },
3514 {
ISD::SMIN, MVT::v32i16, { 1, 1, 1, 1 } },
3515 {
ISD::SMIN, MVT::v64i8, { 1, 1, 1, 1 } },
3520 {
ISD::UMAX, MVT::v32i16, { 1, 1, 1, 1 } },
3521 {
ISD::UMAX, MVT::v64i8, { 1, 1, 1, 1 } },
3522 {
ISD::UMIN, MVT::v32i16, { 1, 1, 1, 1 } },
3523 {
ISD::UMIN, MVT::v64i8, { 1, 1, 1, 1 } },
3528 {
ISD::ABS, MVT::v8i64, { 1, 1, 1, 1 } },
3529 {
ISD::ABS, MVT::v4i64, { 1, 1, 1, 1 } },
3530 {
ISD::ABS, MVT::v2i64, { 1, 1, 1, 1 } },
3531 {
ISD::ABS, MVT::v16i32, { 1, 1, 1, 1 } },
3532 {
ISD::ABS, MVT::v8i32, { 1, 1, 1, 1 } },
3533 {
ISD::ABS, MVT::v32i16, { 2, 7, 4, 4 } },
3534 {
ISD::ABS, MVT::v16i16, { 1, 1, 1, 1 } },
3535 {
ISD::ABS, MVT::v64i8, { 2, 7, 4, 4 } },
3536 {
ISD::ABS, MVT::v32i8, { 1, 1, 1, 1 } },
3544 {
ISD::CTLZ, MVT::v8i64, { 10, 28, 32, 32 } },
3545 {
ISD::CTLZ, MVT::v16i32, { 12, 30, 38, 38 } },
3546 {
ISD::CTLZ, MVT::v32i16, { 8, 15, 29, 29 } },
3547 {
ISD::CTLZ, MVT::v64i8, { 6, 11, 19, 19 } },
3548 {
ISD::CTPOP, MVT::v8i64, { 16, 16, 19, 19 } },
3549 {
ISD::CTPOP, MVT::v16i32, { 24, 19, 27, 27 } },
3550 {
ISD::CTPOP, MVT::v32i16, { 18, 15, 22, 22 } },
3551 {
ISD::CTPOP, MVT::v64i8, { 12, 11, 16, 16 } },
3552 {
ISD::CTTZ, MVT::v8i64, { 2, 8, 6, 7 } },
3553 {
ISD::CTTZ, MVT::v16i32, { 2, 8, 6, 7 } },
3554 {
ISD::CTTZ, MVT::v32i16, { 7, 17, 27, 27 } },
3555 {
ISD::CTTZ, MVT::v64i8, { 6, 13, 21, 21 } },
3556 {
ISD::ROTL, MVT::v8i64, { 1, 1, 1, 1 } },
3557 {
ISD::ROTL, MVT::v4i64, { 1, 1, 1, 1 } },
3558 {
ISD::ROTL, MVT::v2i64, { 1, 1, 1, 1 } },
3559 {
ISD::ROTL, MVT::v16i32, { 1, 1, 1, 1 } },
3560 {
ISD::ROTL, MVT::v8i32, { 1, 1, 1, 1 } },
3561 {
ISD::ROTL, MVT::v4i32, { 1, 1, 1, 1 } },
3562 {
ISD::ROTR, MVT::v8i64, { 1, 1, 1, 1 } },
3563 {
ISD::ROTR, MVT::v4i64, { 1, 1, 1, 1 } },
3564 {
ISD::ROTR, MVT::v2i64, { 1, 1, 1, 1 } },
3565 {
ISD::ROTR, MVT::v16i32, { 1, 1, 1, 1 } },
3566 {
ISD::ROTR, MVT::v8i32, { 1, 1, 1, 1 } },
3567 {
ISD::ROTR, MVT::v4i32, { 1, 1, 1, 1 } },
3574 {
ISD::SMAX, MVT::v8i64, { 1, 3, 1, 1 } },
3575 {
ISD::SMAX, MVT::v16i32, { 1, 1, 1, 1 } },
3576 {
ISD::SMAX, MVT::v32i16, { 3, 7, 5, 5 } },
3577 {
ISD::SMAX, MVT::v64i8, { 3, 7, 5, 5 } },
3578 {
ISD::SMAX, MVT::v4i64, { 1, 3, 1, 1 } },
3579 {
ISD::SMAX, MVT::v2i64, { 1, 3, 1, 1 } },
3580 {
ISD::SMIN, MVT::v8i64, { 1, 3, 1, 1 } },
3581 {
ISD::SMIN, MVT::v16i32, { 1, 1, 1, 1 } },
3582 {
ISD::SMIN, MVT::v32i16, { 3, 7, 5, 5 } },
3583 {
ISD::SMIN, MVT::v64i8, { 3, 7, 5, 5 } },
3584 {
ISD::SMIN, MVT::v4i64, { 1, 3, 1, 1 } },
3585 {
ISD::SMIN, MVT::v2i64, { 1, 3, 1, 1 } },
3586 {
ISD::UMAX, MVT::v8i64, { 1, 3, 1, 1 } },
3587 {
ISD::UMAX, MVT::v16i32, { 1, 1, 1, 1 } },
3588 {
ISD::UMAX, MVT::v32i16, { 3, 7, 5, 5 } },
3589 {
ISD::UMAX, MVT::v64i8, { 3, 7, 5, 5 } },
3590 {
ISD::UMAX, MVT::v4i64, { 1, 3, 1, 1 } },
3591 {
ISD::UMAX, MVT::v2i64, { 1, 3, 1, 1 } },
3592 {
ISD::UMIN, MVT::v8i64, { 1, 3, 1, 1 } },
3593 {
ISD::UMIN, MVT::v16i32, { 1, 1, 1, 1 } },
3594 {
ISD::UMIN, MVT::v32i16, { 3, 7, 5, 5 } },
3595 {
ISD::UMIN, MVT::v64i8, { 3, 7, 5, 5 } },
3596 {
ISD::UMIN, MVT::v4i64, { 1, 3, 1, 1 } },
3597 {
ISD::UMIN, MVT::v2i64, { 1, 3, 1, 1 } },
3625 {
ISD::FSQRT, MVT::v16f32, { 12, 20, 1, 3 } },
3628 {
ISD::FSQRT, MVT::v4f64, { 12, 18, 1, 1 } },
3629 {
ISD::FSQRT, MVT::v8f64, { 24, 32, 1, 3 } },
3645 {
ISD::ROTL, MVT::v4i64, { 4, 7, 5, 6 } },
3646 {
ISD::ROTL, MVT::v8i32, { 4, 7, 5, 6 } },
3647 {
ISD::ROTL, MVT::v16i16, { 4, 7, 5, 6 } },
3648 {
ISD::ROTL, MVT::v32i8, { 4, 7, 5, 6 } },
3649 {
ISD::ROTL, MVT::v2i64, { 1, 3, 1, 1 } },
3650 {
ISD::ROTL, MVT::v4i32, { 1, 3, 1, 1 } },
3651 {
ISD::ROTL, MVT::v8i16, { 1, 3, 1, 1 } },
3652 {
ISD::ROTL, MVT::v16i8, { 1, 3, 1, 1 } },
3653 {
ISD::ROTR, MVT::v4i64, { 4, 7, 8, 9 } },
3654 {
ISD::ROTR, MVT::v8i32, { 4, 7, 8, 9 } },
3655 {
ISD::ROTR, MVT::v16i16, { 4, 7, 8, 9 } },
3656 {
ISD::ROTR, MVT::v32i8, { 4, 7, 8, 9 } },
3657 {
ISD::ROTR, MVT::v2i64, { 1, 3, 3, 3 } },
3658 {
ISD::ROTR, MVT::v4i32, { 1, 3, 3, 3 } },
3659 {
ISD::ROTR, MVT::v8i16, { 1, 3, 3, 3 } },
3660 {
ISD::ROTR, MVT::v16i8, { 1, 3, 3, 3 } },
3671 {
ISD::ABS, MVT::v2i64, { 2, 4, 3, 5 } },
3672 {
ISD::ABS, MVT::v4i64, { 2, 4, 3, 5 } },
3673 {
ISD::ABS, MVT::v4i32, { 1, 1, 1, 1 } },
3674 {
ISD::ABS, MVT::v8i32, { 1, 1, 1, 2 } },
3675 {
ISD::ABS, MVT::v8i16, { 1, 1, 1, 1 } },
3676 {
ISD::ABS, MVT::v16i16, { 1, 1, 1, 2 } },
3677 {
ISD::ABS, MVT::v16i8, { 1, 1, 1, 1 } },
3678 {
ISD::ABS, MVT::v32i8, { 1, 1, 1, 2 } },
3693 {
ISD::CTLZ, MVT::v2i64, { 7, 18, 24, 25 } },
3694 {
ISD::CTLZ, MVT::v4i64, { 14, 18, 24, 44 } },
3695 {
ISD::CTLZ, MVT::v4i32, { 5, 16, 19, 20 } },
3696 {
ISD::CTLZ, MVT::v8i32, { 10, 16, 19, 34 } },
3697 {
ISD::CTLZ, MVT::v8i16, { 4, 13, 14, 15 } },
3698 {
ISD::CTLZ, MVT::v16i16, { 6, 14, 14, 24 } },
3699 {
ISD::CTLZ, MVT::v16i8, { 3, 12, 9, 10 } },
3700 {
ISD::CTLZ, MVT::v32i8, { 4, 12, 9, 14 } },
3701 {
ISD::CTPOP, MVT::v2i64, { 3, 9, 10, 10 } },
3702 {
ISD::CTPOP, MVT::v4i64, { 4, 9, 10, 14 } },
3703 {
ISD::CTPOP, MVT::v4i32, { 7, 12, 14, 14 } },
3704 {
ISD::CTPOP, MVT::v8i32, { 7, 12, 14, 18 } },
3705 {
ISD::CTPOP, MVT::v8i16, { 3, 7, 11, 11 } },
3706 {
ISD::CTPOP, MVT::v16i16, { 6, 8, 11, 18 } },
3709 {
ISD::CTTZ, MVT::v2i64, { 4, 11, 13, 13 } },
3710 {
ISD::CTTZ, MVT::v4i64, { 5, 11, 13, 20 } },
3711 {
ISD::CTTZ, MVT::v4i32, { 7, 14, 17, 17 } },
3712 {
ISD::CTTZ, MVT::v8i32, { 7, 15, 17, 24 } },
3713 {
ISD::CTTZ, MVT::v8i16, { 4, 9, 14, 14 } },
3714 {
ISD::CTTZ, MVT::v16i16, { 6, 9, 14, 24 } },
3715 {
ISD::CTTZ, MVT::v16i8, { 3, 7, 11, 11 } },
3716 {
ISD::CTTZ, MVT::v32i8, { 5, 7, 11, 18 } },
3719 {
ISD::SMAX, MVT::v2i64, { 2, 7, 2, 3 } },
3720 {
ISD::SMAX, MVT::v4i64, { 2, 7, 2, 3 } },
3721 {
ISD::SMAX, MVT::v8i32, { 1, 1, 1, 2 } },
3722 {
ISD::SMAX, MVT::v16i16, { 1, 1, 1, 2 } },
3723 {
ISD::SMAX, MVT::v32i8, { 1, 1, 1, 2 } },
3724 {
ISD::SMIN, MVT::v2i64, { 2, 7, 2, 3 } },
3725 {
ISD::SMIN, MVT::v4i64, { 2, 7, 2, 3 } },
3726 {
ISD::SMIN, MVT::v8i32, { 1, 1, 1, 2 } },
3727 {
ISD::SMIN, MVT::v16i16, { 1, 1, 1, 2 } },
3728 {
ISD::SMIN, MVT::v32i8, { 1, 1, 1, 2 } },
3734 {
ISD::UMAX, MVT::v2i64, { 2, 8, 5, 6 } },
3735 {
ISD::UMAX, MVT::v4i64, { 2, 8, 5, 8 } },
3736 {
ISD::UMAX, MVT::v8i32, { 1, 1, 1, 2 } },
3737 {
ISD::UMAX, MVT::v16i16, { 1, 1, 1, 2 } },
3738 {
ISD::UMAX, MVT::v32i8, { 1, 1, 1, 2 } },
3739 {
ISD::UMIN, MVT::v2i64, { 2, 8, 5, 6 } },
3740 {
ISD::UMIN, MVT::v4i64, { 2, 8, 5, 8 } },
3741 {
ISD::UMIN, MVT::v8i32, { 1, 1, 1, 2 } },
3742 {
ISD::UMIN, MVT::v16i16, { 1, 1, 1, 2 } },
3743 {
ISD::UMIN, MVT::v32i8, { 1, 1, 1, 2 } },
3755 {
ISD::FSQRT, MVT::v8f32, { 14, 21, 1, 3 } },
3757 {
ISD::FSQRT, MVT::v2f64, { 14, 21, 1, 1 } },
3758 {
ISD::FSQRT, MVT::v4f64, { 28, 35, 1, 3 } },
3761 {
ISD::ABS, MVT::v4i64, { 6, 8, 6, 12 } },
3762 {
ISD::ABS, MVT::v8i32, { 3, 6, 4, 5 } },
3763 {
ISD::ABS, MVT::v16i16, { 3, 6, 4, 5 } },
3764 {
ISD::ABS, MVT::v32i8, { 3, 6, 4, 5 } },
3777 {
ISD::BSWAP, MVT::v16i16, { 5, 6, 5, 10 } },
3779 {
ISD::CTLZ, MVT::v4i64, { 29, 33, 49, 58 } },
3780 {
ISD::CTLZ, MVT::v2i64, { 14, 24, 24, 28 } },
3781 {
ISD::CTLZ, MVT::v8i32, { 24, 28, 39, 48 } },
3782 {
ISD::CTLZ, MVT::v4i32, { 12, 20, 19, 23 } },
3783 {
ISD::CTLZ, MVT::v16i16, { 19, 22, 29, 38 } },
3784 {
ISD::CTLZ, MVT::v8i16, { 9, 16, 14, 18 } },
3785 {
ISD::CTLZ, MVT::v32i8, { 14, 15, 19, 28 } },
3786 {
ISD::CTLZ, MVT::v16i8, { 7, 12, 9, 13 } },
3787 {
ISD::CTPOP, MVT::v4i64, { 14, 18, 19, 28 } },
3788 {
ISD::CTPOP, MVT::v2i64, { 7, 14, 10, 14 } },
3789 {
ISD::CTPOP, MVT::v8i32, { 18, 24, 27, 36 } },
3790 {
ISD::CTPOP, MVT::v4i32, { 9, 20, 14, 18 } },
3791 {
ISD::CTPOP, MVT::v16i16, { 16, 21, 22, 31 } },
3792 {
ISD::CTPOP, MVT::v8i16, { 8, 18, 11, 15 } },
3793 {
ISD::CTPOP, MVT::v32i8, { 13, 15, 16, 25 } },
3794 {
ISD::CTPOP, MVT::v16i8, { 6, 12, 8, 12 } },
3795 {
ISD::CTTZ, MVT::v4i64, { 17, 22, 24, 33 } },
3796 {
ISD::CTTZ, MVT::v2i64, { 9, 19, 13, 17 } },
3797 {
ISD::CTTZ, MVT::v8i32, { 21, 27, 32, 41 } },
3798 {
ISD::CTTZ, MVT::v4i32, { 11, 24, 17, 21 } },
3799 {
ISD::CTTZ, MVT::v16i16, { 18, 24, 27, 36 } },
3800 {
ISD::CTTZ, MVT::v8i16, { 9, 21, 14, 18 } },
3801 {
ISD::CTTZ, MVT::v32i8, { 15, 18, 21, 30 } },
3802 {
ISD::CTTZ, MVT::v16i8, { 8, 16, 11, 15 } },
3805 {
ISD::SMAX, MVT::v4i64, { 6, 9, 6, 12 } },
3806 {
ISD::SMAX, MVT::v2i64, { 3, 7, 2, 4 } },
3807 {
ISD::SMAX, MVT::v8i32, { 4, 6, 5, 6 } },
3808 {
ISD::SMAX, MVT::v16i16, { 4, 6, 5, 6 } },
3809 {
ISD::SMAX, MVT::v32i8, { 4, 6, 5, 6 } },
3810 {
ISD::SMIN, MVT::v4i64, { 6, 9, 6, 12 } },
3811 {
ISD::SMIN, MVT::v2i64, { 3, 7, 2, 3 } },
3812 {
ISD::SMIN, MVT::v8i32, { 4, 6, 5, 6 } },
3813 {
ISD::SMIN, MVT::v16i16, { 4, 6, 5, 6 } },
3814 {
ISD::SMIN, MVT::v32i8, { 4, 6, 5, 6 } },
3820 {
ISD::UMAX, MVT::v4i64, { 9, 10, 11, 17 } },
3821 {
ISD::UMAX, MVT::v2i64, { 4, 8, 5, 7 } },
3822 {
ISD::UMAX, MVT::v8i32, { 4, 6, 5, 6 } },
3823 {
ISD::UMAX, MVT::v16i16, { 4, 6, 5, 6 } },
3824 {
ISD::UMAX, MVT::v32i8, { 4, 6, 5, 6 } },
3825 {
ISD::UMIN, MVT::v4i64, { 9, 10, 11, 17 } },
3826 {
ISD::UMIN, MVT::v2i64, { 4, 8, 5, 7 } },
3827 {
ISD::UMIN, MVT::v8i32, { 4, 6, 5, 6 } },
3828 {
ISD::UMIN, MVT::v16i16, { 4, 6, 5, 6 } },
3829 {
ISD::UMIN, MVT::v32i8, { 4, 6, 5, 6 } },
3840 {
ISD::FSQRT, MVT::v4f32, { 21, 21, 1, 1 } },
3841 {
ISD::FSQRT, MVT::v8f32, { 42, 42, 1, 3 } },
3843 {
ISD::FSQRT, MVT::v2f64, { 27, 27, 1, 1 } },
3844 {
ISD::FSQRT, MVT::v4f64, { 54, 54, 1, 3 } },
3866 {
ISD::FSQRT, MVT::v4f32, { 37, 41, 1, 5 } },
3868 {
ISD::FSQRT, MVT::v2f64, { 67, 71, 1, 5 } },
3875 {
ISD::FSQRT, MVT::v4f32, { 40, 41, 1, 5 } },
3877 {
ISD::FSQRT, MVT::v2f64, { 70, 71, 1, 5 } },
3887 {
ISD::FSQRT, MVT::v4f32, { 18, 18, 1, 1 } },
3890 {
ISD::ABS, MVT::v2i64, { 3, 4, 3, 5 } },
3891 {
ISD::SMAX, MVT::v2i64, { 3, 7, 2, 3 } },
3892 {
ISD::SMAX, MVT::v4i32, { 1, 1, 1, 1 } },
3893 {
ISD::SMAX, MVT::v16i8, { 1, 1, 1, 1 } },
3894 {
ISD::SMIN, MVT::v2i64, { 3, 7, 2, 3 } },
3895 {
ISD::SMIN, MVT::v4i32, { 1, 1, 1, 1 } },
3896 {
ISD::SMIN, MVT::v16i8, { 1, 1, 1, 1 } },
3897 {
ISD::UMAX, MVT::v2i64, { 2, 11, 6, 7 } },
3898 {
ISD::UMAX, MVT::v4i32, { 1, 1, 1, 1 } },
3899 {
ISD::UMAX, MVT::v8i16, { 1, 1, 1, 1 } },
3900 {
ISD::UMIN, MVT::v2i64, { 2, 11, 6, 7 } },
3901 {
ISD::UMIN, MVT::v4i32, { 1, 1, 1, 1 } },
3902 {
ISD::UMIN, MVT::v8i16, { 1, 1, 1, 1 } },
3905 {
ISD::ABS, MVT::v4i32, { 1, 2, 1, 1 } },
3906 {
ISD::ABS, MVT::v8i16, { 1, 2, 1, 1 } },
3907 {
ISD::ABS, MVT::v16i8, { 1, 2, 1, 1 } },
3915 {
ISD::CTLZ, MVT::v2i64, { 18, 28, 28, 35 } },
3916 {
ISD::CTLZ, MVT::v4i32, { 15, 20, 22, 28 } },
3917 {
ISD::CTLZ, MVT::v8i16, { 13, 17, 16, 22 } },
3918 {
ISD::CTLZ, MVT::v16i8, { 11, 15, 10, 16 } },
3919 {
ISD::CTPOP, MVT::v2i64, { 13, 19, 12, 18 } },
3920 {
ISD::CTPOP, MVT::v4i32, { 18, 24, 16, 22 } },
3921 {
ISD::CTPOP, MVT::v8i16, { 13, 18, 14, 20 } },
3922 {
ISD::CTPOP, MVT::v16i8, { 11, 12, 10, 16 } },
3923 {
ISD::CTTZ, MVT::v2i64, { 13, 25, 15, 22 } },
3924 {
ISD::CTTZ, MVT::v4i32, { 18, 26, 19, 25 } },
3925 {
ISD::CTTZ, MVT::v8i16, { 13, 20, 17, 23 } },
3926 {
ISD::CTTZ, MVT::v16i8, { 11, 16, 13, 19 } }
3929 {
ISD::ABS, MVT::v2i64, { 3, 6, 5, 5 } },
3930 {
ISD::ABS, MVT::v4i32, { 1, 4, 4, 4 } },
3931 {
ISD::ABS, MVT::v8i16, { 1, 2, 3, 3 } },
3932 {
ISD::ABS, MVT::v16i8, { 1, 2, 3, 3 } },
3937 {
ISD::BSWAP, MVT::v2i64, { 5, 6, 11, 11 } },
3940 {
ISD::CTLZ, MVT::v2i64, { 10, 45, 36, 38 } },
3941 {
ISD::CTLZ, MVT::v4i32, { 10, 45, 38, 40 } },
3942 {
ISD::CTLZ, MVT::v8i16, { 9, 38, 32, 34 } },
3943 {
ISD::CTLZ, MVT::v16i8, { 8, 39, 29, 32 } },
3944 {
ISD::CTPOP, MVT::v2i64, { 12, 26, 16, 18 } },
3945 {
ISD::CTPOP, MVT::v4i32, { 15, 29, 21, 23 } },
3946 {
ISD::CTPOP, MVT::v8i16, { 13, 25, 18, 20 } },
3947 {
ISD::CTPOP, MVT::v16i8, { 10, 21, 14, 16 } },
3948 {
ISD::CTTZ, MVT::v2i64, { 14, 28, 19, 21 } },
3949 {
ISD::CTTZ, MVT::v4i32, { 18, 31, 24, 26 } },
3950 {
ISD::CTTZ, MVT::v8i16, { 16, 27, 21, 23 } },
3951 {
ISD::CTTZ, MVT::v16i8, { 13, 23, 17, 19 } },
3954 {
ISD::SMAX, MVT::v2i64, { 4, 8, 15, 15 } },
3955 {
ISD::SMAX, MVT::v4i32, { 2, 4, 5, 5 } },
3956 {
ISD::SMAX, MVT::v8i16, { 1, 1, 1, 1 } },
3957 {
ISD::SMAX, MVT::v16i8, { 2, 4, 5, 5 } },
3958 {
ISD::SMIN, MVT::v2i64, { 4, 8, 15, 15 } },
3959 {
ISD::SMIN, MVT::v4i32, { 2, 4, 5, 5 } },
3960 {
ISD::SMIN, MVT::v8i16, { 1, 1, 1, 1 } },
3961 {
ISD::SMIN, MVT::v16i8, { 2, 4, 5, 5 } },
3966 {
ISD::UMAX, MVT::v2i64, { 4, 8, 15, 15 } },
3967 {
ISD::UMAX, MVT::v4i32, { 2, 5, 8, 8 } },
3968 {
ISD::UMAX, MVT::v8i16, { 1, 3, 3, 3 } },
3969 {
ISD::UMAX, MVT::v16i8, { 1, 1, 1, 1 } },
3970 {
ISD::UMIN, MVT::v2i64, { 4, 8, 15, 15 } },
3971 {
ISD::UMIN, MVT::v4i32, { 2, 5, 8, 8 } },
3972 {
ISD::UMIN, MVT::v8i16, { 1, 3, 3, 3 } },
3973 {
ISD::UMIN, MVT::v16i8, { 1, 1, 1, 1 } },
3979 {
ISD::FSQRT, MVT::v2f64, { 32, 32, 1, 1 } },
3985 {
ISD::FSQRT, MVT::v4f32, { 56, 56, 1, 2 } },
4012 {
ISD::ABS, MVT::i64, { 1, 2, 3, 4 } },
4020 {
ISD::ROTL, MVT::i64, { 2, 3, 1, 3 } },
4021 {
ISD::ROTR, MVT::i64, { 2, 3, 1, 3 } },
4023 {
ISD::FSHL, MVT::i64, { 4, 4, 1, 4 } },
4024 {
ISD::SMAX, MVT::i64, { 1, 3, 2, 3 } },
4025 {
ISD::SMIN, MVT::i64, { 1, 3, 2, 3 } },
4026 {
ISD::UMAX, MVT::i64, { 1, 3, 2, 3 } },
4027 {
ISD::UMIN, MVT::i64, { 1, 3, 2, 3 } },
4033 {
ISD::ABS, MVT::i32, { 1, 2, 3, 4 } },
4034 {
ISD::ABS, MVT::i16, { 2, 2, 3, 4 } },
4035 {
ISD::ABS, MVT::i8, { 2, 4, 4, 4 } },
4056 {
ISD::ROTL, MVT::i32, { 2, 3, 1, 3 } },
4057 {
ISD::ROTL, MVT::i16, { 2, 3, 1, 3 } },
4059 {
ISD::ROTR, MVT::i32, { 2, 3, 1, 3 } },
4060 {
ISD::ROTR, MVT::i16, { 2, 3, 1, 3 } },
4065 {
ISD::FSHL, MVT::i32, { 4, 4, 1, 4 } },
4066 {
ISD::FSHL, MVT::i16, { 4, 4, 2, 5 } },
4068 {
ISD::SMAX, MVT::i32, { 1, 2, 2, 3 } },
4069 {
ISD::SMAX, MVT::i16, { 1, 4, 2, 4 } },
4071 {
ISD::SMIN, MVT::i32, { 1, 2, 2, 3 } },
4072 {
ISD::SMIN, MVT::i16, { 1, 4, 2, 4 } },
4074 {
ISD::UMAX, MVT::i32, { 1, 2, 2, 3 } },
4075 {
ISD::UMAX, MVT::i16, { 1, 4, 2, 4 } },
4077 {
ISD::UMIN, MVT::i32, { 1, 2, 2, 3 } },
4078 {
ISD::UMIN, MVT::i16, { 1, 4, 2, 4 } },
4098 case Intrinsic::abs:
4101 case Intrinsic::bitreverse:
4104 case Intrinsic::bswap:
4107 case Intrinsic::ctlz:
4110 case Intrinsic::ctpop:
4113 case Intrinsic::cttz:
4116 case Intrinsic::fshl:
4120 if (Args[0] == Args[1]) {
4131 case Intrinsic::fshr:
4136 if (Args[0] == Args[1]) {
4147 case Intrinsic::maxnum:
4148 case Intrinsic::minnum:
4152 case Intrinsic::sadd_sat:
4155 case Intrinsic::smax:
4158 case Intrinsic::smin:
4161 case Intrinsic::ssub_sat:
4164 case Intrinsic::uadd_sat:
4167 case Intrinsic::umax:
4170 case Intrinsic::umin:
4173 case Intrinsic::usub_sat:
4176 case Intrinsic::sqrt:
4179 case Intrinsic::sadd_with_overflow:
4180 case Intrinsic::ssub_with_overflow:
4183 OpTy =
RetTy->getContainedType(0);
4185 case Intrinsic::uadd_with_overflow:
4186 case Intrinsic::usub_with_overflow:
4189 OpTy =
RetTy->getContainedType(0);
4191 case Intrinsic::umul_with_overflow:
4192 case Intrinsic::smul_with_overflow:
4195 OpTy =
RetTy->getContainedType(0);
4202 MVT MTy = LT.second;
4205 if (((ISD ==
ISD::CTTZ && !ST->hasBMI()) ||
4206 (ISD ==
ISD::CTLZ && !ST->hasLZCNT())) &&
4209 if (
auto *Cst = dyn_cast<ConstantInt>(Args[1]))
4210 if (Cst->isAllOnesValue())
4218 auto adjustTableCost = [](
int ISD,
unsigned Cost,
4226 return LegalizationCost * 1;
4228 return LegalizationCost * (int)
Cost;
4231 if (ST->useGLMDivSqrtCosts())
4233 if (
auto KindCost = Entry->Cost[
CostKind])
4234 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4237 if (ST->useSLMArithCosts())
4239 if (
auto KindCost = Entry->Cost[
CostKind])
4240 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4244 if (
const auto *Entry =
CostTableLookup(AVX512VBMI2CostTbl, ISD, MTy))
4245 if (
auto KindCost = Entry->Cost[
CostKind])
4246 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4249 if (ST->hasBITALG())
4250 if (
const auto *Entry =
CostTableLookup(AVX512BITALGCostTbl, ISD, MTy))
4251 if (
auto KindCost = Entry->Cost[
CostKind])
4252 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4255 if (ST->hasVPOPCNTDQ())
4256 if (
const auto *Entry =
CostTableLookup(AVX512VPOPCNTDQCostTbl, ISD, MTy))
4257 if (
auto KindCost = Entry->Cost[
CostKind])
4258 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4263 if (
auto KindCost = Entry->Cost[
CostKind])
4264 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4269 if (
auto KindCost = Entry->Cost[
CostKind])
4270 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4275 if (
auto KindCost = Entry->Cost[
CostKind])
4276 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4281 if (
auto KindCost = Entry->Cost[
CostKind])
4282 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4287 if (
auto KindCost = Entry->Cost[
CostKind])
4288 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4293 if (
auto KindCost = Entry->Cost[
CostKind])
4294 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4299 if (
auto KindCost = Entry->Cost[
CostKind])
4300 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4305 if (
auto KindCost = Entry->Cost[
CostKind])
4306 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4311 if (
auto KindCost = Entry->Cost[
CostKind])
4312 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4317 if (
auto KindCost = Entry->Cost[
CostKind])
4318 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4323 if (
auto KindCost = Entry->Cost[
CostKind])
4324 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4329 if (
auto KindCost = Entry->Cost[
CostKind])
4330 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4336 if (
auto KindCost = Entry->Cost[
CostKind])
4337 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4341 if (
auto KindCost = Entry->Cost[
CostKind])
4342 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4346 if (ST->hasLZCNT()) {
4349 if (
auto KindCost = Entry->Cost[
CostKind])
4350 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4354 if (
auto KindCost = Entry->Cost[
CostKind])
4355 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4359 if (ST->hasPOPCNT()) {
4362 if (
auto KindCost = Entry->Cost[
CostKind])
4363 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4367 if (
auto KindCost = Entry->Cost[
CostKind])
4368 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4372 if (ISD ==
ISD::BSWAP && ST->hasMOVBE() && ST->hasFastMOVBE()) {
4374 if (II->hasOneUse() && isa<StoreInst>(II->user_back()))
4376 if (
auto *LI = dyn_cast<LoadInst>(II->getOperand(0))) {
4377 if (LI->hasOneUse())
4385 if (
auto KindCost = Entry->Cost[
CostKind])
4386 return adjustTableCost(Entry->ISD, *KindCost, LT.first,
4390 if (
auto KindCost = Entry->Cost[
CostKind])
4391 return adjustTableCost(Entry->ISD, *KindCost, LT.first, ICA.
getFlags());
4414 if (
Index == -1U && (Opcode == Instruction::ExtractElement ||
4415 Opcode == Instruction::InsertElement)) {
4420 assert(isa<FixedVectorType>(Val) &&
"Fixed vector type expected");
4425 if (Opcode == Instruction::ExtractElement) {
4431 if (Opcode == Instruction::InsertElement) {
4439 if (
Index != -1U && (Opcode == Instruction::ExtractElement ||
4440 Opcode == Instruction::InsertElement)) {
4442 if (Opcode == Instruction::ExtractElement &&
4444 cast<FixedVectorType>(Val)->getNumElements() > 1)
4451 if (!LT.second.isVector())
4455 unsigned SizeInBits = LT.second.getSizeInBits();
4456 unsigned NumElts = LT.second.getVectorNumElements();
4457 unsigned SubNumElts = NumElts;
4462 if (SizeInBits > 128) {
4463 assert((SizeInBits % 128) == 0 &&
"Illegal vector");
4464 unsigned NumSubVecs = SizeInBits / 128;
4465 SubNumElts = NumElts / NumSubVecs;
4466 if (SubNumElts <=
Index) {
4467 RegisterFileMoveCost += (Opcode == Instruction::InsertElement ? 2 : 1);
4468 Index %= SubNumElts;
4472 MVT MScalarTy = LT.second.getScalarType();
4473 auto IsCheapPInsrPExtrInsertPS = [&]() {
4476 return (MScalarTy == MVT::i16 && ST->
hasSSE2()) ||
4478 (MScalarTy == MVT::f32 && ST->
hasSSE41() &&
4479 Opcode == Instruction::InsertElement);
4487 (Opcode != Instruction::InsertElement || !Op0 ||
4488 isa<UndefValue>(Op0)))
4489 return RegisterFileMoveCost;
4491 if (Opcode == Instruction::InsertElement &&
4492 isa_and_nonnull<UndefValue>(Op0)) {
4494 if (isa_and_nonnull<LoadInst>(Op1))
4495 return RegisterFileMoveCost;
4496 if (!IsCheapPInsrPExtrInsertPS()) {
4499 return 2 + RegisterFileMoveCost;
4501 return 1 + RegisterFileMoveCost;
4506 if (ScalarType->
isIntegerTy() && Opcode == Instruction::ExtractElement)
4507 return 1 + RegisterFileMoveCost;
4511 assert(ISD &&
"Unexpected vector opcode");
4512 if (ST->useSLMArithCosts())
4514 return Entry->Cost + RegisterFileMoveCost;
4517 if (IsCheapPInsrPExtrInsertPS())
4518 return 1 + RegisterFileMoveCost;
4527 if (Opcode == Instruction::InsertElement) {
4528 auto *SubTy = cast<VectorType>(Val);
4536 return ShuffleCost + IntOrFpCost + RegisterFileMoveCost;
4540 RegisterFileMoveCost;
4545 bool Insert,
bool Extract,
4548 cast<FixedVectorType>(Ty)->getNumElements() &&
4549 "Vector size mismatch");
4552 MVT MScalarTy = LT.second.getScalarType();
4553 unsigned LegalVectorBitWidth = LT.second.getSizeInBits();
4556 constexpr unsigned LaneBitWidth = 128;
4557 assert((LegalVectorBitWidth < LaneBitWidth ||
4558 (LegalVectorBitWidth % LaneBitWidth) == 0) &&
4561 const int NumLegalVectors = *LT.first.getValue();
4562 assert(NumLegalVectors >= 0 &&
"Negative cost!");
4567 if ((MScalarTy == MVT::i16 && ST->
hasSSE2()) ||
4569 (MScalarTy == MVT::f32 && ST->
hasSSE41())) {
4572 if (LegalVectorBitWidth <= LaneBitWidth) {
4588 assert((LegalVectorBitWidth % LaneBitWidth) == 0 &&
"Illegal vector");
4589 unsigned NumLegalLanes = LegalVectorBitWidth / LaneBitWidth;
4590 unsigned NumLanesTotal = NumLegalLanes * NumLegalVectors;
4591 unsigned NumLegalElts =
4592 LT.second.getVectorNumElements() * NumLegalVectors;
4594 "Vector has been legalized to smaller element count");
4595 assert((NumLegalElts % NumLanesTotal) == 0 &&
4596 "Unexpected elts per lane");
4597 unsigned NumEltsPerLane = NumLegalElts / NumLanesTotal;
4599 APInt WidenedDemandedElts = DemandedElts.
zext(NumLegalElts);
4603 for (
unsigned I = 0;
I != NumLanesTotal; ++
I) {
4605 NumEltsPerLane, NumEltsPerLane *
I);
4606 if (LaneEltMask.
isZero())
4617 APInt AffectedLanes =
4620 AffectedLanes, NumLegalVectors,
true);
4621 for (
int LegalVec = 0; LegalVec != NumLegalVectors; ++LegalVec) {
4622 for (
unsigned Lane = 0; Lane != NumLegalLanes; ++Lane) {
4623 unsigned I = NumLegalLanes * LegalVec + Lane;
4626 if (!AffectedLanes[
I] ||
4627 (Lane == 0 && FullyAffectedLegalVectors[LegalVec]))
4634 }
else if (LT.second.isVector()) {
4645 unsigned NumElts = LT.second.getVectorNumElements();
4647 PowerOf2Ceil(cast<FixedVectorType>(Ty)->getNumElements());
4648 Cost += (std::min<unsigned>(NumElts, Pow2Elts) - 1) * LT.first;
4657 unsigned NumElts = cast<FixedVectorType>(Ty)->getNumElements();
4658 unsigned MaxElts = ST->
hasAVX2() ? 32 : 16;
4659 unsigned MOVMSKCost = (NumElts + MaxElts - 1) / MaxElts;
4663 if (LT.second.isVector()) {
4664 unsigned NumLegalElts =
4665 LT.second.getVectorNumElements() * NumLegalVectors;
4667 "Vector has been legalized to smaller element count");
4671 if (LegalVectorBitWidth > LaneBitWidth) {
4672 unsigned NumLegalLanes = LegalVectorBitWidth / LaneBitWidth;
4673 unsigned NumLanesTotal = NumLegalLanes * NumLegalVectors;
4674 assert((NumLegalElts % NumLanesTotal) == 0 &&
4675 "Unexpected elts per lane");
4676 unsigned NumEltsPerLane = NumLegalElts / NumLanesTotal;
4680 APInt WidenedDemandedElts = DemandedElts.
zext(NumLegalElts);
4684 for (
unsigned I = 0;
I != NumLanesTotal; ++
I) {
4686 NumEltsPerLane,
I * NumEltsPerLane);
4687 if (LaneEltMask.
isZero())
4692 LaneTy, LaneEltMask,
false, Extract,
CostKind);
4709 int VF,
const APInt &DemandedDstElts,
4715 auto bailout = [&]() {
4725 unsigned PromEltTyBits = EltTyBits;
4726 switch (EltTyBits) {
4757 int NumDstElements = VF * ReplicationFactor;
4771 if (PromEltTyBits != EltTyBits) {
4777 Instruction::SExt, PromSrcVecTy, SrcVecTy,
4784 ReplicationFactor, VF,
4790 "We expect that the legalization doesn't affect the element width, "
4791 "doesn't coalesce/split elements.");
4794 unsigned NumDstVectors =
4795 divideCeil(DstVecTy->getNumElements(), NumEltsPerDstVec);
4804 DemandedDstElts.
zext(NumDstVectors * NumEltsPerDstVec), NumDstVectors);
4805 unsigned NumDstVectorsDemanded = DemandedDstVectors.
popcount();
4810 return NumDstVectorsDemanded * SingleShuffleCost;
4821 if (
auto *SI = dyn_cast_or_null<StoreInst>(
I)) {
4824 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(SI->getPointerOperand())) {
4825 if (!
all_of(
GEP->indices(), [](
Value *V) { return isa<Constant>(V); }))
4832 assert((Opcode == Instruction::Load || Opcode == Instruction::Store) &&
4842 auto *VTy = dyn_cast<FixedVectorType>(Src);
4847 if (Opcode == Instruction::Store && OpInfo.
isConstant())
4853 if (!VTy || !LT.second.isVector()) {
4855 return (LT.second.isFloatingPoint() ?
Cost : 0) + LT.first * 1;
4858 bool IsLoad = Opcode == Instruction::Load;
4860 Type *EltTy = VTy->getElementType();
4865 const unsigned SrcNumElt = VTy->getNumElements();
4868 int NumEltRemaining = SrcNumElt;
4870 auto NumEltDone = [&]() {
return SrcNumElt - NumEltRemaining; };
4872 const int MaxLegalOpSizeBytes =
divideCeil(LT.second.getSizeInBits(), 8);
4875 const unsigned XMMBits = 128;
4876 if (XMMBits % EltTyBits != 0)
4880 const int NumEltPerXMM = XMMBits / EltTyBits;
4884 for (
int CurrOpSizeBytes = MaxLegalOpSizeBytes, SubVecEltsLeft = 0;
4885 NumEltRemaining > 0; CurrOpSizeBytes /= 2) {
4887 if ((8 * CurrOpSizeBytes) % EltTyBits != 0)
4891 int CurrNumEltPerOp = (8 * CurrOpSizeBytes) / EltTyBits;
4893 assert(CurrOpSizeBytes > 0 && CurrNumEltPerOp > 0 &&
"How'd we get here?");
4894 assert((((NumEltRemaining * EltTyBits) < (2 * 8 * CurrOpSizeBytes)) ||
4895 (CurrOpSizeBytes == MaxLegalOpSizeBytes)) &&
4896 "Unless we haven't halved the op size yet, "
4897 "we have less than two op's sized units of work left.");
4899 auto *CurrVecTy = CurrNumEltPerOp > NumEltPerXMM
4903 assert(CurrVecTy->getNumElements() % CurrNumEltPerOp == 0 &&
4904 "After halving sizes, the vector elt count is no longer a multiple "
4905 "of number of elements per operation?");
4906 auto *CoalescedVecTy =
4907 CurrNumEltPerOp == 1
4911 EltTyBits * CurrNumEltPerOp),
4912 CurrVecTy->getNumElements() / CurrNumEltPerOp);
4915 "coalesciing elements doesn't change vector width.");
4917 while (NumEltRemaining > 0) {
4918 assert(SubVecEltsLeft >= 0 &&
"Subreg element count overconsumtion?");
4922 if (NumEltRemaining < CurrNumEltPerOp &&
4923 (!IsLoad || Alignment.
valueOrOne() < CurrOpSizeBytes) &&
4924 CurrOpSizeBytes != 1)
4927 bool Is0thSubVec = (NumEltDone() % LT.second.getVectorNumElements()) == 0;
4930 if (SubVecEltsLeft == 0) {
4931 SubVecEltsLeft += CurrVecTy->getNumElements();
4936 VTy, std::nullopt,
CostKind, NumEltDone(),
4944 if (CurrOpSizeBytes <= 32 / 8 && !Is0thSubVec) {
4945 int NumEltDoneInCurrXMM = NumEltDone() % NumEltPerXMM;
4946 assert(NumEltDoneInCurrXMM % CurrNumEltPerOp == 0 &&
"");
4947 int CoalescedVecEltIdx = NumEltDoneInCurrXMM / CurrNumEltPerOp;
4948 APInt DemandedElts =
4950 CoalescedVecEltIdx, CoalescedVecEltIdx + 1);
4951 assert(DemandedElts.
popcount() == 1 &&
"Inserting single value");
4961 if (CurrOpSizeBytes == 32 && ST->isUnalignedMem32Slow())
4963 else if (CurrOpSizeBytes < 4)
4968 SubVecEltsLeft -= CurrNumEltPerOp;
4969 NumEltRemaining -= CurrNumEltPerOp;
4974 assert(NumEltRemaining <= 0 &&
"Should have processed all the elements.");
4983 bool IsLoad = (Instruction::Load == Opcode);
4984 bool IsStore = (Instruction::Store == Opcode);
4986 auto *SrcVTy = dyn_cast<FixedVectorType>(SrcTy);
4991 unsigned NumElem = SrcVTy->getNumElements();
4999 MaskTy, DemandedElts,
false,
true,
CostKind);
5004 InstructionCost MaskCmpCost = NumElem * (BranchCost + ScalarCompareCost);
5006 SrcVTy, DemandedElts, IsLoad, IsStore,
CostKind);
5010 return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost;
5017 if (VT.isSimple() && LT.second != VT.getSimpleVT() &&
5018 LT.second.getVectorNumElements() == NumElem)
5025 else if (LT.first * LT.second.getVectorNumElements() > NumElem) {
5027 LT.second.getVectorNumElements());
5035 return Cost + LT.first * (IsLoad ? 2 : 8);
5038 return Cost + LT.first;
5046 if (
Info.isSameBase() &&
Info.isKnownStride()) {
5050 if (
const auto *BaseGEP = dyn_cast<GetElementPtrInst>(
Base)) {
5052 return getGEPCost(BaseGEP->getSourceElementType(),
5053 BaseGEP->getPointerOperand(), Indices,
nullptr,
5068 const unsigned NumVectorInstToHideOverhead = 10;
5081 return NumVectorInstToHideOverhead;
5091 std::optional<FastMathFlags> FMF,
5132 assert(ISD &&
"Invalid opcode");
5140 if (ST->useSLMArithCosts())
5155 MVT MTy = LT.second;
5157 auto *ValVTy = cast<FixedVectorType>(ValTy);
5170 if (LT.first != 1 && MTy.
isVector() &&
5176 ArithmeticCost *= LT.first - 1;
5179 if (ST->useSLMArithCosts())
5181 return ArithmeticCost + Entry->Cost;
5185 return ArithmeticCost + Entry->Cost;
5189 return ArithmeticCost + Entry->Cost;
5238 if (ValVTy->getElementType()->isIntegerTy(1)) {
5240 if (LT.first != 1 && MTy.
isVector() &&
5246 ArithmeticCost *= LT.first - 1;
5250 if (
const auto *Entry =
CostTableLookup(AVX512BoolReduction, ISD, MTy))
5251 return ArithmeticCost + Entry->Cost;
5254 return ArithmeticCost + Entry->Cost;
5257 return ArithmeticCost + Entry->Cost;
5260 return ArithmeticCost + Entry->Cost;
5265 unsigned NumVecElts = ValVTy->getNumElements();
5266 unsigned ScalarSize = ValVTy->getScalarSizeInBits();
5276 if (LT.first != 1 && MTy.
isVector() &&
5282 ReductionCost *= LT.first - 1;
5288 while (NumVecElts > 1) {
5290 unsigned Size = NumVecElts * ScalarSize;
5299 }
else if (
Size == 128) {
5302 if (ValVTy->isFloatingPointTy())
5309 std::nullopt,
CostKind, 0,
nullptr);
5310 }
else if (
Size == 64) {
5313 if (ValVTy->isFloatingPointTy())
5320 std::nullopt,
CostKind, 0,
nullptr);
5326 Instruction::LShr, ShiftTy,
CostKind,
5353 MVT MTy = LT.second;
5357 ISD = (IID == Intrinsic::umin || IID == Intrinsic::umax) ?
ISD::UMIN
5361 "Expected float point or integer vector type.");
5362 ISD = (IID == Intrinsic::minnum || IID == Intrinsic::maxnum)
5430 auto *ValVTy = cast<FixedVectorType>(ValTy);
5431 unsigned NumVecElts = ValVTy->getNumElements();
5435 if (LT.first != 1 && MTy.
isVector() &&
5441 MinMaxCost *= LT.first - 1;
5447 return MinMaxCost + Entry->Cost;
5451 return MinMaxCost + Entry->Cost;
5455 return MinMaxCost + Entry->Cost;
5459 return MinMaxCost + Entry->Cost;
5471 while (NumVecElts > 1) {
5473 unsigned Size = NumVecElts * ScalarSize;
5481 }
else if (
Size == 128) {
5490 std::nullopt,
CostKind, 0,
nullptr);
5491 }
else if (
Size == 64) {
5499 std::nullopt,
CostKind, 0,
nullptr);
5552 if (BitSize % 64 != 0)
5553 ImmVal = Imm.sext(
alignTo(BitSize, 64));
5558 for (
unsigned ShiftVal = 0; ShiftVal < BitSize; ShiftVal += 64) {
5564 return std::max<InstructionCost>(1,
Cost);
5579 unsigned ImmIdx = ~0U;
5583 case Instruction::GetElementPtr:
5590 case Instruction::Store:
5593 case Instruction::ICmp:
5599 if (
Idx == 1 && Imm.getBitWidth() == 64) {
5600 uint64_t ImmVal = Imm.getZExtValue();
5601 if (ImmVal == 0x100000000ULL || ImmVal == 0xffffffff)
5606 case Instruction::And:
5610 if (
Idx == 1 && Imm.getBitWidth() == 64 && Imm.isIntN(32))
5614 case Instruction::Add:
5615 case Instruction::Sub:
5617 if (
Idx == 1 && Imm.getBitWidth() == 64 && Imm.getZExtValue() == 0x80000000)
5621 case Instruction::UDiv:
5622 case Instruction::SDiv:
5623 case Instruction::URem:
5624 case Instruction::SRem:
5629 case Instruction::Mul:
5630 case Instruction::Or:
5631 case Instruction::Xor:
5635 case Instruction::Shl:
5636 case Instruction::LShr:
5637 case Instruction::AShr:
5641 case Instruction::Trunc:
5642 case Instruction::ZExt:
5643 case Instruction::SExt:
5644 case Instruction::IntToPtr:
5645 case Instruction::PtrToInt:
5646 case Instruction::BitCast:
5647 case Instruction::PHI:
5648 case Instruction::Call:
5649 case Instruction::Select:
5650 case Instruction::Ret:
5651 case Instruction::Load:
5655 if (
Idx == ImmIdx) {
5680 case Intrinsic::sadd_with_overflow:
5681 case Intrinsic::uadd_with_overflow:
5682 case Intrinsic::ssub_with_overflow:
5683 case Intrinsic::usub_with_overflow:
5684 case Intrinsic::smul_with_overflow:
5685 case Intrinsic::umul_with_overflow:
5686 if ((
Idx == 1) && Imm.getBitWidth() <= 64 && Imm.isSignedIntN(32))
5689 case Intrinsic::experimental_stackmap:
5690 if ((
Idx < 2) || (Imm.getBitWidth() <= 64 && Imm.isSignedIntN(64)))
5693 case Intrinsic::experimental_patchpoint_void:
5694 case Intrinsic::experimental_patchpoint:
5695 if ((
Idx < 4) || (Imm.getBitWidth() <= 64 && Imm.isSignedIntN(64)))
5706 return Opcode == Instruction::PHI ? 0 : 1;
5711int X86TTIImpl::getGatherOverhead()
const {
5724int X86TTIImpl::getScatterOverhead()
const {
5739 assert(isa<VectorType>(SrcVTy) &&
"Unexpected type in getGSVectorCost");
5740 unsigned VF = cast<FixedVectorType>(SrcVTy)->getNumElements();
5750 if (IndexSize < 64 || !
GEP)
5753 unsigned NumOfVarIndices = 0;
5754 const Value *Ptrs =
GEP->getPointerOperand();
5757 for (
unsigned I = 1, E =
GEP->getNumOperands();
I != E; ++
I) {
5758 if (isa<Constant>(
GEP->getOperand(
I)))
5760 Type *IndxTy =
GEP->getOperand(
I)->getType();
5761 if (
auto *IndexVTy = dyn_cast<VectorType>(IndxTy))
5762 IndxTy = IndexVTy->getElementType();
5764 !isa<SExtInst>(
GEP->getOperand(
I))) ||
5765 ++NumOfVarIndices > 1)
5768 return (
unsigned)32;
5773 unsigned IndexSize = (ST->
hasAVX512() && VF >= 16)
5774 ? getIndexSizeInBits(
Ptr,
DL)
5782 *std::max(IdxsLT.first, SrcLT.first).getValue();
5783 if (SplitFactor > 1) {
5787 return SplitFactor * getGSVectorCost(Opcode,
CostKind, SplitSrcTy,
Ptr,
5793 const int GSOverhead = (Opcode == Instruction::Load)
5794 ? getGatherOverhead()
5795 : getScatterOverhead();
5811 Type *SrcVTy,
bool VariableMask,
5815 unsigned VF = cast<FixedVectorType>(SrcVTy)->getNumElements();
5823 MaskTy, DemandedElts,
false,
true,
CostKind);
5828 MaskUnpackCost += VF * (BranchCost + ScalarCompareCost);
5833 DemandedElts,
false,
true,
CostKind);
5843 cast<FixedVectorType>(SrcVTy), DemandedElts,
5844 Opcode == Instruction::Load,
5845 Opcode == Instruction::Store,
CostKind);
5847 return AddressUnpackCost + MemoryOpCost + MaskUnpackCost + InsertExtractCost;
5852 unsigned Opcode,
Type *SrcVTy,
const Value *
Ptr,
bool VariableMask,
5856 if ((Opcode == Instruction::Load &&
5859 Align(Alignment))) ||
5860 (Opcode == Instruction::Store &&
5871 if (!PtrTy &&
Ptr->getType()->isVectorTy())
5872 PtrTy = dyn_cast<PointerType>(
5873 cast<VectorType>(
Ptr->getType())->getElementType());
5874 assert(PtrTy &&
"Unexpected type for Ptr argument");
5877 if ((Opcode == Instruction::Load &&
5880 Align(Alignment)))) ||
5881 (Opcode == Instruction::Store &&
5884 Align(Alignment)))))
5885 return getGSScalarCost(Opcode,
CostKind, SrcVTy, VariableMask, Alignment,
5888 return getGSVectorCost(Opcode,
CostKind, SrcVTy,
Ptr, Alignment,
5904 return ST->hasMacroFusion() || ST->hasBranchFusion();
5912 if (isa<VectorType>(DataTy) &&
5913 cast<FixedVectorType>(DataTy)->getNumElements() == 1)
5923 if (ScalarTy->
isHalfTy() && ST->hasBWI())
5933 return IntWidth == 32 || IntWidth == 64 ||
5934 ((IntWidth == 8 || IntWidth == 16) && ST->hasBWI());
5946 if (Alignment >= DataSize && (DataSize == 16 || DataSize == 32))
5963 if (Alignment < DataSize || DataSize < 4 || DataSize > 32 ||
5985 if (!isa<VectorType>(DataTy))
5992 if (cast<FixedVectorType>(DataTy)->getNumElements() == 1)
5995 Type *ScalarTy = cast<VectorType>(DataTy)->getElementType();
6004 return IntWidth == 32 || IntWidth == 64 ||
6005 ((IntWidth == 8 || IntWidth == 16) && ST->hasVBMI2());
6012bool X86TTIImpl::supportsGather()
const {
6026 unsigned NumElts = cast<FixedVectorType>(VTy)->getNumElements();
6027 return NumElts == 1 ||
6028 (ST->
hasAVX512() && (NumElts == 2 || (NumElts == 4 && !ST->hasVLX())));
6043 return IntWidth == 32 || IntWidth == 64;
6047 if (!supportsGather() || !ST->preferGather())
6062 unsigned NumElements = cast<FixedVectorType>(VecTy)->getNumElements();
6063 assert(OpcodeMask.
size() == NumElements &&
"Mask and VecTy are incompatible");
6068 for (
int Lane : seq<int>(0, NumElements)) {
6069 unsigned Opc = OpcodeMask.
test(Lane) ? Opcode1 : Opcode0;
6071 if (Lane % 2 == 0 && Opc != Instruction::FSub)
6073 if (Lane % 2 == 1 && Opc != Instruction::FAdd)
6077 Type *ElemTy = cast<VectorType>(VecTy)->getElementType();
6079 return ST->
hasSSE3() && NumElements % 4 == 0;
6081 return ST->
hasSSE3() && NumElements % 2 == 0;
6087 if (!ST->
hasAVX512() || !ST->preferScatter())
6100 if (
I->getOpcode() == Instruction::FDiv)
6116 TM.getSubtargetImpl(*Caller)->getFeatureBits();
6118 TM.getSubtargetImpl(*Callee)->getFeatureBits();
6121 FeatureBitset RealCallerBits = CallerBits & ~InlineFeatureIgnoreList;
6122 FeatureBitset RealCalleeBits = CalleeBits & ~InlineFeatureIgnoreList;
6123 if (RealCallerBits == RealCalleeBits)
6128 if ((RealCallerBits & RealCalleeBits) != RealCalleeBits)
6132 if (
const auto *CB = dyn_cast<CallBase>(&
I)) {
6134 if (CB->isInlineAsm())
6138 for (
Value *Arg : CB->args())
6139 Types.push_back(Arg->getType());
6140 if (!CB->getType()->isVoidTy())
6141 Types.push_back(CB->getType());
6144 auto IsSimpleTy = [](
Type *Ty) {
6145 return !Ty->isVectorTy() && !Ty->isAggregateType();
6147 if (
all_of(Types, IsSimpleTy))
6150 if (
Function *NestedCallee = CB->getCalledFunction()) {
6152 if (NestedCallee->isIntrinsic())
6187 [](
Type *
T) {
return T->isVectorTy() ||
T->isAggregateType(); });
6196 Options.AllowOverlappingLoads =
true;
6201 if (PreferredWidth >= 512 && ST->
hasAVX512() && ST->hasEVEX512())
6202 Options.LoadSizes.push_back(64);
6203 if (PreferredWidth >= 256 && ST->
hasAVX())
Options.LoadSizes.push_back(32);
6204 if (PreferredWidth >= 128 && ST->
hasSSE2())
Options.LoadSizes.push_back(16);
6206 if (ST->is64Bit()) {
6207 Options.LoadSizes.push_back(8);
6209 Options.LoadSizes.push_back(4);
6210 Options.LoadSizes.push_back(2);
6211 Options.LoadSizes.push_back(1);
6216 return supportsGather();
6227 return !(ST->isAtom());
6247 unsigned NumOfMemOps = (VecTySize + LegalVTSize - 1) / LegalVTSize;
6253 bool UseMaskedMemOp = UseMaskForCond || UseMaskForGaps;
6265 if (UseMaskedMemOp) {
6267 for (
unsigned Index : Indices) {
6268 assert(
Index < Factor &&
"Invalid index for interleaved memory op");
6269 for (
unsigned Elm = 0; Elm < VF; Elm++)
6270 DemandedLoadStoreElts.
setBit(
Index + Elm * Factor);
6277 UseMaskForGaps ? DemandedLoadStoreElts
6286 if (UseMaskForGaps) {
6292 if (Opcode == Instruction::Load) {
6299 static const CostTblEntry AVX512InterleavedLoadTbl[] = {
6300 {3, MVT::v16i8, 12},
6301 {3, MVT::v32i8, 14},
6302 {3, MVT::v64i8, 22},
6305 if (
const auto *Entry =
6307 return MaskCost + NumOfMemOps * MemOpCost + Entry->Cost;
6317 ShuffleKind, SingleMemOpTy, std::nullopt,
CostKind, 0,
nullptr);
6319 unsigned NumOfLoadsInInterleaveGrp =
6320 Indices.
size() ? Indices.
size() : Factor;
6329 unsigned NumOfUnfoldedLoads =
6330 UseMaskedMemOp || NumOfResults > 1 ? NumOfMemOps : NumOfMemOps / 2;
6333 unsigned NumOfShufflesPerResult =
6334 std::max((
unsigned)1, (
unsigned)(NumOfMemOps - 1));
6341 NumOfMoves = NumOfResults * NumOfShufflesPerResult / 2;
6344 MaskCost + NumOfUnfoldedLoads * MemOpCost +
6351 assert(Opcode == Instruction::Store &&
6352 "Expected Store Instruction at this point");
6354 static const CostTblEntry AVX512InterleavedStoreTbl[] = {
6355 {3, MVT::v16i8, 12},
6356 {3, MVT::v32i8, 14},
6357 {3, MVT::v64i8, 26},
6360 {4, MVT::v16i8, 11},
6361 {4, MVT::v32i8, 14},
6365 if (
const auto *Entry =
6367 return MaskCost + NumOfMemOps * MemOpCost + Entry->Cost;
6372 unsigned NumOfSources = Factor;
6375 unsigned NumOfShufflesPerStore = NumOfSources - 1;
6379 unsigned NumOfMoves = NumOfMemOps * NumOfShufflesPerStore / 2;
6382 NumOfMemOps * (MemOpCost + NumOfShufflesPerStore * ShuffleCost) +
6390 bool UseMaskForCond,
bool UseMaskForGaps) {
6391 auto *VecTy = cast<FixedVectorType>(
BaseTy);
6393 auto isSupportedOnAVX512 = [&](
Type *VecTy) {
6394 Type *EltTy = cast<VectorType>(VecTy)->getElementType();
6399 return ST->hasBWI();
6401 return ST->hasBF16();
6404 if (ST->
hasAVX512() && isSupportedOnAVX512(VecTy))
6406 Opcode, VecTy, Factor, Indices, Alignment,
6409 if (UseMaskForCond || UseMaskForGaps)
6412 UseMaskForCond, UseMaskForGaps);
6432 unsigned VF = VecTy->getNumElements() / Factor;
6433 Type *ScalarTy = VecTy->getElementType();
6465 {2, MVT::v16i16, 9},
6466 {2, MVT::v32i16, 18},
6469 {2, MVT::v16i32, 8},
6470 {2, MVT::v32i32, 16},
6474 {2, MVT::v16i64, 16},
6475 {2, MVT::v32i64, 32},
6480 {3, MVT::v16i8, 11},
6481 {3, MVT::v32i8, 14},
6486 {3, MVT::v16i16, 28},
6487 {3, MVT::v32i16, 56},
6492 {3, MVT::v16i32, 14},
6493 {3, MVT::v32i32, 32},
6497 {3, MVT::v8i64, 10},
6498 {3, MVT::v16i64, 20},
6503 {4, MVT::v16i8, 24},
6504 {4, MVT::v32i8, 56},
6507 {4, MVT::v4i16, 17},
6508 {4, MVT::v8i16, 33},
6509 {4, MVT::v16i16, 75},
6510 {4, MVT::v32i16, 150},
6514 {4, MVT::v8i32, 16},
6515 {4, MVT::v16i32, 32},
6516 {4, MVT::v32i32, 68},
6520 {4, MVT::v8i64, 20},
6521 {4, MVT::v16i64, 40},
6526 {6, MVT::v16i8, 43},
6527 {6, MVT::v32i8, 82},
6529 {6, MVT::v2i16, 13},
6531 {6, MVT::v8i16, 39},
6532 {6, MVT::v16i16, 106},
6533 {6, MVT::v32i16, 212},
6536 {6, MVT::v4i32, 15},
6537 {6, MVT::v8i32, 31},
6538 {6, MVT::v16i32, 64},
6541 {6, MVT::v4i64, 18},
6542 {6, MVT::v8i64, 36},
6547 static const CostTblEntry SSSE3InterleavedLoadTbl[] = {
6561 static const CostTblEntry AVX2InterleavedStoreTbl[] = {
6566 {2, MVT::v16i16, 4},
6567 {2, MVT::v32i16, 8},
6571 {2, MVT::v16i32, 8},
6572 {2, MVT::v32i32, 16},
6577 {2, MVT::v16i64, 16},
6578 {2, MVT::v32i64, 32},
6583 {3, MVT::v16i8, 11},
6584 {3, MVT::v32i8, 13},
6588 {3, MVT::v8i16, 12},
6589 {3, MVT::v16i16, 27},
6590 {3, MVT::v32i16, 54},
6594 {3, MVT::v8i32, 11},
6595 {3, MVT::v16i32, 22},
6596 {3, MVT::v32i32, 48},
6600 {3, MVT::v8i64, 12},
6601 {3, MVT::v16i64, 24},
6607 {4, MVT::v32i8, 12},
6611 {4, MVT::v8i16, 10},
6612 {4, MVT::v16i16, 32},
6613 {4, MVT::v32i16, 64},
6617 {4, MVT::v8i32, 16},
6618 {4, MVT::v16i32, 32},
6619 {4, MVT::v32i32, 64},
6623 {4, MVT::v8i64, 20},
6624 {4, MVT::v16i64, 40},
6629 {6, MVT::v16i8, 27},
6630 {6, MVT::v32i8, 90},
6632 {6, MVT::v2i16, 10},
6633 {6, MVT::v4i16, 15},
6634 {6, MVT::v8i16, 21},
6635 {6, MVT::v16i16, 58},
6636 {6, MVT::v32i16, 90},
6639 {6, MVT::v4i32, 12},
6640 {6, MVT::v8i32, 33},
6641 {6, MVT::v16i32, 66},
6644 {6, MVT::v4i64, 15},
6645 {6, MVT::v8i64, 30},
6648 static const CostTblEntry SSE2InterleavedStoreTbl[] = {
6659 if (Opcode == Instruction::Load) {
6660 auto GetDiscountedCost = [Factor, NumMembers = Indices.
size(),
6664 return MemOpCosts +
divideCeil(NumMembers * Entry->Cost, Factor);
6668 if (
const auto *Entry =
CostTableLookup(AVX2InterleavedLoadTbl, Factor,
6670 return GetDiscountedCost(Entry);
6673 if (
const auto *Entry =
CostTableLookup(SSSE3InterleavedLoadTbl, Factor,
6675 return GetDiscountedCost(Entry);
6678 if (
const auto *Entry =
CostTableLookup(SSE2InterleavedLoadTbl, Factor,
6680 return GetDiscountedCost(Entry);
6682 assert(Opcode == Instruction::Store &&
6683 "Expected Store Instruction at this point");
6685 "Interleaved store only supports fully-interleaved groups.");
6687 if (
const auto *Entry =
CostTableLookup(AVX2InterleavedStoreTbl, Factor,
6689 return MemOpCosts + Entry->Cost;
6692 if (
const auto *Entry =
CostTableLookup(SSE2InterleavedStoreTbl, Factor,
6694 return MemOpCosts + Entry->Cost;
6699 UseMaskForCond, UseMaskForGaps);
6704 bool HasBaseReg, int64_t Scale,
6705 unsigned AddrSpace)
const {
6732 return AM.
Scale != 0;
Expand Atomic instructions
This file provides a helper that implements much of the TTI interface in terms of the target-independ...
Analysis containing CSE Info
static cl::opt< TargetTransformInfo::TargetCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(TargetTransformInfo::TCK_RecipThroughput), cl::values(clEnumValN(TargetTransformInfo::TCK_RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(TargetTransformInfo::TCK_Latency, "latency", "Instruction latency"), clEnumValN(TargetTransformInfo::TCK_CodeSize, "code-size", "Code size"), clEnumValN(TargetTransformInfo::TCK_SizeAndLatency, "size-latency", "Code size and latency")))
Cost tables and simple lookup functions.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
const char LLVMTargetMachineRef TM
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file describes how to lower LLVM code to machine code.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
APInt zext(unsigned width) const
Zero extend to a new width.
unsigned popcount() const
Count the number of bits set.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
unsigned getBitWidth() const
Return the number of bits in the APInt.
APInt sextOrTrunc(unsigned width) const
Sign extend or truncate to width.
APInt ashr(unsigned ShiftAmt) const
Arithmetic right-shift function.
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
APInt extractBits(unsigned numBits, unsigned bitPosition) const
Return an APInt with the extracted bits [bitPosition,bitPosition+numBits).
int64_t getSExtValue() const
Get sign extended value.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
Get intrinsic cost based on arguments.
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Opd1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Opd2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args=ArrayRef< const Value * >(), const Instruction *CxtI=nullptr)
TTI::ShuffleKind improveShuffleKindFromMask(TTI::ShuffleKind Kind, ArrayRef< int > Mask, VectorType *Ty, int &Index, VectorType *&SubTy) const
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
Try to calculate op costs for min/max reduction operations.
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args=std::nullopt, const Instruction *CxtI=nullptr)
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *, const SCEV *)
InstructionCost getScalarizationOverhead(VectorType *InTy, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind)
Estimate the overhead of scalarizing an instruction.
InstructionCost getGEPCost(Type *PointeeType, const Value *Ptr, ArrayRef< const Value * > Operands, Type *AccessType, TTI::TargetCostKind CostKind)
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
std::pair< InstructionCost, MVT > getTypeLegalizationCost(Type *Ty) const
Estimate the cost of type-legalization and the legalized type.
InstructionCost getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF, const APInt &DemandedDstElts, TTI::TargetCostKind CostKind)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool isLegalAddressingMode(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace, Instruction *I=nullptr, int64_t ScalableOffset=0)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ ICMP_SLE
signed less or equal
@ ICMP_UGE
unsigned greater or equal
@ ICMP_UGT
unsigned greater than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ ICMP_SGE
signed greater or equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
A parsed version of the target data layout string in and methods for querying it.
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Align getABITypeAlign(Type *Ty) const
Returns the minimum ABI-required alignment for the specified type.
TypeSize getTypeSizeInBits(Type *Ty) const
Size examples:
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
Align getPrefTypeAlign(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
constexpr bool isScalar() const
Exactly one element.
Convenience struct for specifying and reasoning about fast-math flags.
Container class for subtarget features.
Class to represent fixed width SIMD vectors.
unsigned getNumElements() const
static FixedVectorType * get(Type *ElementType, unsigned NumElts)
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static InstructionCost getInvalid(CostType Val=0)
std::optional< CostType > getValue() const
This function is intended to be used as sparingly as possible, since the class provides the full rang...
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
FastMathFlags getFlags() const
Type * getReturnType() const
const SmallVectorImpl< const Value * > & getArgs() const
const IntrinsicInst * getInst() const
Intrinsic::ID getID() const
bool isTypeBasedOnly() const
bool is128BitVector() const
Return true if this is a 128-bit vector type.
uint64_t getScalarSizeInBits() const
unsigned getVectorNumElements() const
bool isVector() const
Return true if this is a vector value type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
MVT getVectorElementType() const
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
Class to represent pointers.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
unsigned getAddressSpace() const
Return the address space of the Pointer type.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
static bool isIdentityMask(ArrayRef< int > Mask, int NumSrcElts)
Return true if this shuffle mask chooses elements from exactly one source vector without lane crossin...
This is a 'bitvector' (really, a variable-sized bit array), optimized for the case when the array is ...
bool test(unsigned Idx) const
size_type size() const
Returns the number of bits in this bitvector.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
int InstructionOpcodeToISD(unsigned Opcode) const
Get the ISD node that corresponds to the Instruction class opcode.
EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown=false) const
Return the EVT corresponding to this LLVM type.
const TargetMachine & getTargetMachine() const
unsigned getMaxExpandSizeMemcmp(bool OptSize) const
Get maximum # of load operations permitted for memcmp.
bool isOperationLegal(unsigned Op, EVT VT) const
Return true if the specified operation is legal on this target.
Primary interface to the complete machine description for the target machine.
static constexpr TypeSize getFixed(ScalarTy ExactSize)
static constexpr TypeSize getScalable(ScalarTy MinimumSize)
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getIntegerBitWidth() const
static Type * getDoubleTy(LLVMContext &C)
bool isVectorTy() const
True if this is an instance of VectorType.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isPointerTy() const
True if this is an instance of PointerType.
static IntegerType * getInt1Ty(LLVMContext &C)
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
static IntegerType * getIntNTy(LLVMContext &C, unsigned N)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static IntegerType * getInt8Ty(LLVMContext &C)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
static IntegerType * getInt32Ty(LLVMContext &C)
static IntegerType * getInt64Ty(LLVMContext &C)
static Type * getFloatTy(LLVMContext &C)
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
Base class of all SIMD vector types.
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
Type * getElementType() const
bool useAVX512Regs() const
unsigned getPreferVectorWidth() const
InstructionCost getInterleavedMemoryOpCostAVX512(unsigned Opcode, FixedVectorType *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
bool isLegalMaskedGather(Type *DataType, Align Alignment)
InstructionCost getAltInstrCost(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask, TTI::TargetCostKind CostKind) const
std::optional< unsigned > getCacheAssociativity(TargetTransformInfo::CacheLevel Level) const override
TTI::PopcntSupportKind getPopcntSupport(unsigned TyWidth)
bool isLegalNTStore(Type *DataType, Align Alignment)
bool enableInterleavedAccessVectorization()
InstructionCost getIntImmCostIntrin(Intrinsic::ID IID, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind)
bool isLegalNTLoad(Type *DataType, Align Alignment)
InstructionCost getIntImmCostInst(unsigned Opcode, unsigned Idx, const APInt &Imm, Type *Ty, TTI::TargetCostKind CostKind, Instruction *Inst=nullptr)
bool forceScalarizeMaskedScatter(VectorType *VTy, Align Alignment)
bool isLegalMaskedGatherScatter(Type *DataType, Align Alignment)
bool isLegalMaskedLoad(Type *DataType, Align Alignment)
bool supportsEfficientVectorElementLoadStore() const
TTI::MemCmpExpansionOptions enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const
bool prefersVectorizedAddressing() const
unsigned getLoadStoreVecRegBitWidth(unsigned AS) const
bool isLegalBroadcastLoad(Type *ElementTy, ElementCount NumElements) const
InstructionCost getMinMaxReductionCost(Intrinsic::ID IID, VectorType *Ty, FastMathFlags FMF, TTI::TargetCostKind CostKind)
bool forceScalarizeMaskedGather(VectorType *VTy, Align Alignment)
std::optional< unsigned > getCacheSize(TargetTransformInfo::CacheLevel Level) const override
bool isLegalMaskedStore(Type *DataType, Align Alignment)
InstructionCost getReplicationShuffleCost(Type *EltTy, int ReplicationFactor, int VF, const APInt &DemandedDstElts, TTI::TargetCostKind CostKind)
InstructionCost getGatherScatterOpCost(unsigned Opcode, Type *DataTy, const Value *Ptr, bool VariableMask, Align Alignment, TTI::TargetCostKind CostKind, const Instruction *I)
Calculate the cost of Gather / Scatter operation.
InstructionCost getInterleavedMemoryOpCost(unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef< unsigned > Indices, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, bool UseMaskForCond=false, bool UseMaskForGaps=false)
unsigned getMaxInterleaveFactor(ElementCount VF)
TypeSize getRegisterBitWidth(TargetTransformInfo::RegisterKind K) const
bool isLegalMaskedCompressStore(Type *DataType, Align Alignment)
InstructionCost getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, TTI::CastContextHint CCH, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
InstructionCost getPointersChainCost(ArrayRef< const Value * > Ptrs, const Value *Base, const TTI::PointersChainInfo &Info, Type *AccessTy, TTI::TargetCostKind CostKind)
InstructionCost getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA, TTI::TargetCostKind CostKind)
unsigned getNumberOfRegisters(unsigned ClassID) const
InstructionCost getMemoryOpCost(unsigned Opcode, Type *Src, MaybeAlign Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind, TTI::OperandValueInfo OpInfo={TTI::OK_AnyValue, TTI::OP_None}, const Instruction *I=nullptr)
bool isLSRCostLess(const TargetTransformInfo::LSRCost &C1, const TargetTransformInfo::LSRCost &C2)
bool isLegalMaskedExpandLoad(Type *DataType, Align Alignment)
InstructionCost getArithmeticReductionCost(unsigned Opcode, VectorType *Ty, std::optional< FastMathFlags > FMF, TTI::TargetCostKind CostKind)
unsigned getAtomicMemIntrinsicMaxElementSize() const
bool isLegalMaskedScatter(Type *DataType, Align Alignment)
InstructionCost getArithmeticInstrCost(unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info={TTI::OK_AnyValue, TTI::OP_None}, TTI::OperandValueInfo Op2Info={TTI::OK_AnyValue, TTI::OP_None}, ArrayRef< const Value * > Args=ArrayRef< const Value * >(), const Instruction *CxtI=nullptr)
InstructionCost getIntImmCost(int64_t)
Calculate the cost of materializing a 64-bit value.
InstructionCost getMaskedMemoryOpCost(unsigned Opcode, Type *Src, Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind)
InstructionCost getVectorInstrCost(unsigned Opcode, Type *Val, TTI::TargetCostKind CostKind, unsigned Index, Value *Op0, Value *Op1)
InstructionCost getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset, bool HasBaseReg, int64_t Scale, unsigned AddrSpace) const
Return the cost of the scaling factor used in the addressing mode represented by AM for this target,...
InstructionCost getScalarizationOverhead(VectorType *Ty, const APInt &DemandedElts, bool Insert, bool Extract, TTI::TargetCostKind CostKind)
bool areInlineCompatible(const Function *Caller, const Function *Callee) const
InstructionCost getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool isExpensiveToSpeculativelyExecute(const Instruction *I)
InstructionCost getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE, const SCEV *Ptr)
InstructionCost getShuffleCost(TTI::ShuffleKind Kind, VectorType *Tp, ArrayRef< int > Mask, TTI::TargetCostKind CostKind, int Index, VectorType *SubTp, ArrayRef< const Value * > Args=std::nullopt, const Instruction *CxtI=nullptr)
bool isLegalAltInstr(VectorType *VecTy, unsigned Opcode0, unsigned Opcode1, const SmallBitVector &OpcodeMask) const
InstructionCost getMinMaxCost(Intrinsic::ID IID, Type *Ty, TTI::TargetCostKind CostKind, FastMathFlags FMF)
bool isFCmpOrdCheaperThanFCmpZero(Type *Ty)
InstructionCost getCFInstrCost(unsigned Opcode, TTI::TargetCostKind CostKind, const Instruction *I=nullptr)
bool areTypesABICompatible(const Function *Caller, const Function *Callee, const ArrayRef< Type * > &Type) const
bool hasDivRemOp(Type *DataType, bool IsSigned)
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
APInt ScaleBitMask(const APInt &A, unsigned NewBitWidth, bool MatchAllBits=false)
Splat/Merge neighboring bits to widen/narrow the bitmask represented by.
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
@ DELETED_NODE
DELETED_NODE - This is an illegal value that is used to catch errors.
@ BSWAP
Byte Swap and Counting operators.
@ ADD
Simple integer binary arithmetic operators.
@ SINT_TO_FP
[SU]INT_TO_FP - These operators convert integers (whose interpreted sign depends on the first letter)...
@ FADD
Simple binary floating point operators.
@ ABS
ABS - Determine the unsigned absolute value of a signed integer value of the same bitwidth.
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
@ SIGN_EXTEND
Conversion operators.
@ CTTZ_ZERO_UNDEF
Bit counting operators with an undefined result for zero inputs.
@ FNEG
Perform various unary floating-point operations inspired by libm.
@ SSUBSAT
RESULT = [US]SUBSAT(LHS, RHS) - Perform saturation subtraction on 2 integers with the same bit width ...
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
@ SHL
Shift and rotation operations.
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
@ FMINNUM
FMINNUM/FMAXNUM - Perform floating-point minimum or maximum on two values.
@ SMIN
[US]{MIN/MAX} - Binary minimum or maximum of signed or unsigned integers.
@ FP_EXTEND
X = FP_EXTEND(Y) - Extend a smaller FP type into a larger FP type.
@ FMINIMUM
FMINIMUM/FMAXIMUM - NaN-propagating minimum/maximum that also treat -0.0 as less than 0....
@ FP_TO_SINT
FP_TO_[US]INT - Convert a floating point value to a signed or unsigned integer.
@ AND
Bitwise operators - logical and, logical or, logical xor.
@ FP_ROUND
X = FP_ROUND(Y, TRUNC) - Rounding 'Y' from a larger floating point type down to the precision of the ...
@ TRUNCATE
TRUNCATE - Completely drop the high bits.
@ SADDSAT
RESULT = [US]ADDSAT(LHS, RHS) - Perform saturation addition on 2 integers with the same bit width (W)...
bool match(Val *V, const Pattern &P)
apint_match m_APIntAllowPoison(const APInt *&Res)
Match APInt while allowing poison in splat vector constants.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
const CostTblEntryT< CostType > * CostTableLookup(ArrayRef< CostTblEntryT< CostType > > Tbl, int ISD, MVT Ty)
Find in cost table.
uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator)
Returns the integer ceil(Numerator / Denominator).
Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
uint64_t PowerOf2Ceil(uint64_t A)
Returns the power of two which is greater than or equal to the given value.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
constexpr int PoisonMaskElem
void processShuffleMasks(ArrayRef< int > Mask, unsigned NumOfSrcRegs, unsigned NumOfDestRegs, unsigned NumOfUsedRegs, function_ref< void()> NoInputAction, function_ref< void(ArrayRef< int >, unsigned, unsigned)> SingleInputAction, function_ref< void(ArrayRef< int >, unsigned, unsigned)> ManyInputsAction)
Splits and processes shuffle mask depending on the number of input and output registers.
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
OutputIt copy(R &&Range, OutputIt Out)
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
uint64_t alignDown(uint64_t Value, uint64_t Align, uint64_t Skew=0)
Returns the largest uint64_t less than or equal to Value and is Skew mod Align.
const TypeConversionCostTblEntryT< CostType > * ConvertCostTableLookup(ArrayRef< TypeConversionCostTblEntryT< CostType > > Tbl, int ISD, MVT Dst, MVT Src)
Find in type conversion cost table.
unsigned RecipThroughputCost
std::optional< unsigned > operator[](TargetTransformInfo::TargetCostKind Kind) const
unsigned SizeAndLatencyCost
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isSimple() const
Test if the given EVT is simple (as opposed to being extended).
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
bool isVector() const
Return true if this is a vector value type.
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg + ScalableOffset*...
Type Conversion Cost Table.