@@ -3509,104 +3509,125 @@ X86TTIImpl::getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
3509
3509
if (ISD == ISD::FSQRT && CostKind == TTI::TCK_CodeSize)
3510
3510
return LT.first ;
3511
3511
3512
- auto adjustTableCost = [](const CostTblEntry &Entry ,
3512
+ auto adjustTableCost = [](int ISD, unsigned Cost ,
3513
3513
InstructionCost LegalizationCost,
3514
3514
FastMathFlags FMF) {
3515
3515
// If there are no NANs to deal with, then these are reduced to a
3516
3516
// single MIN** or MAX** instruction instead of the MIN/CMP/SELECT that we
3517
3517
// assume is used in the non-fast case.
3518
- if (Entry. ISD == ISD::FMAXNUM || Entry. ISD == ISD::FMINNUM) {
3518
+ if (ISD == ISD::FMAXNUM || ISD == ISD::FMINNUM) {
3519
3519
if (FMF.noNaNs ())
3520
3520
return LegalizationCost * 1 ;
3521
3521
}
3522
- return LegalizationCost * (int )Entry. Cost ;
3522
+ return LegalizationCost * (int )Cost;
3523
3523
};
3524
3524
3525
3525
if (ST->useGLMDivSqrtCosts ())
3526
3526
if (const auto *Entry = CostTableLookup (GLMCostTbl, ISD, MTy))
3527
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3527
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3528
+ ICA.getFlags ());
3528
3529
3529
3530
if (ST->useSLMArithCosts ())
3530
3531
if (const auto *Entry = CostTableLookup (SLMCostTbl, ISD, MTy))
3531
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3532
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3533
+ ICA.getFlags ());
3532
3534
3533
3535
if (ST->hasBITALG ())
3534
3536
if (const auto *Entry = CostTableLookup (AVX512BITALGCostTbl, ISD, MTy))
3535
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3537
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3538
+ ICA.getFlags ());
3536
3539
3537
3540
if (ST->hasVPOPCNTDQ ())
3538
3541
if (const auto *Entry = CostTableLookup (AVX512VPOPCNTDQCostTbl, ISD, MTy))
3539
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3542
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3543
+ ICA.getFlags ());
3540
3544
3541
3545
if (ST->hasCDI ())
3542
3546
if (const auto *Entry = CostTableLookup (AVX512CDCostTbl, ISD, MTy))
3543
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3547
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3548
+ ICA.getFlags ());
3544
3549
3545
3550
if (ST->hasBWI ())
3546
3551
if (const auto *Entry = CostTableLookup (AVX512BWCostTbl, ISD, MTy))
3547
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3552
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3553
+ ICA.getFlags ());
3548
3554
3549
3555
if (ST->hasAVX512 ())
3550
3556
if (const auto *Entry = CostTableLookup (AVX512CostTbl, ISD, MTy))
3551
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3557
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3558
+ ICA.getFlags ());
3552
3559
3553
3560
if (ST->hasXOP ())
3554
3561
if (const auto *Entry = CostTableLookup (XOPCostTbl, ISD, MTy))
3555
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3562
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3563
+ ICA.getFlags ());
3556
3564
3557
3565
if (ST->hasAVX2 ())
3558
3566
if (const auto *Entry = CostTableLookup (AVX2CostTbl, ISD, MTy))
3559
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3567
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3568
+ ICA.getFlags ());
3560
3569
3561
3570
if (ST->hasAVX ())
3562
3571
if (const auto *Entry = CostTableLookup (AVX1CostTbl, ISD, MTy))
3563
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3572
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3573
+ ICA.getFlags ());
3564
3574
3565
3575
if (ST->hasSSE42 ())
3566
3576
if (const auto *Entry = CostTableLookup (SSE42CostTbl, ISD, MTy))
3567
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3577
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3578
+ ICA.getFlags ());
3568
3579
3569
3580
if (ST->hasSSE41 ())
3570
3581
if (const auto *Entry = CostTableLookup (SSE41CostTbl, ISD, MTy))
3571
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3582
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3583
+ ICA.getFlags ());
3572
3584
3573
3585
if (ST->hasSSSE3 ())
3574
3586
if (const auto *Entry = CostTableLookup (SSSE3CostTbl, ISD, MTy))
3575
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3587
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3588
+ ICA.getFlags ());
3576
3589
3577
3590
if (ST->hasSSE2 ())
3578
3591
if (const auto *Entry = CostTableLookup (SSE2CostTbl, ISD, MTy))
3579
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3592
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3593
+ ICA.getFlags ());
3580
3594
3581
3595
if (ST->hasSSE1 ())
3582
3596
if (const auto *Entry = CostTableLookup (SSE1CostTbl, ISD, MTy))
3583
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3597
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3598
+ ICA.getFlags ());
3584
3599
3585
3600
if (ST->hasBMI ()) {
3586
3601
if (ST->is64Bit ())
3587
3602
if (const auto *Entry = CostTableLookup (BMI64CostTbl, ISD, MTy))
3588
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3603
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3604
+ ICA.getFlags ());
3589
3605
3590
3606
if (const auto *Entry = CostTableLookup (BMI32CostTbl, ISD, MTy))
3591
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3607
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3608
+ ICA.getFlags ());
3592
3609
}
3593
3610
3594
3611
if (ST->hasLZCNT ()) {
3595
3612
if (ST->is64Bit ())
3596
3613
if (const auto *Entry = CostTableLookup (LZCNT64CostTbl, ISD, MTy))
3597
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3614
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3615
+ ICA.getFlags ());
3598
3616
3599
3617
if (const auto *Entry = CostTableLookup (LZCNT32CostTbl, ISD, MTy))
3600
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3618
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3619
+ ICA.getFlags ());
3601
3620
}
3602
3621
3603
3622
if (ST->hasPOPCNT ()) {
3604
3623
if (ST->is64Bit ())
3605
3624
if (const auto *Entry = CostTableLookup (POPCNT64CostTbl, ISD, MTy))
3606
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3625
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3626
+ ICA.getFlags ());
3607
3627
3608
3628
if (const auto *Entry = CostTableLookup (POPCNT32CostTbl, ISD, MTy))
3609
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3629
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3630
+ ICA.getFlags ());
3610
3631
}
3611
3632
3612
3633
if (ISD == ISD::BSWAP && ST->hasMOVBE () && ST->hasFastMOVBE ()) {
@@ -3622,10 +3643,11 @@ X86TTIImpl::getTypeBasedIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
3622
3643
3623
3644
if (ST->is64Bit ())
3624
3645
if (const auto *Entry = CostTableLookup (X64CostTbl, ISD, MTy))
3625
- return adjustTableCost (*Entry, LT.first , ICA.getFlags ());
3646
+ return adjustTableCost (Entry->ISD , Entry->Cost , LT.first ,
3647
+ ICA.getFlags ());
3626
3648
3627
3649
if (const auto *Entry = CostTableLookup (X86CostTbl, ISD, MTy))
3628
- return adjustTableCost (* Entry, LT.first , ICA.getFlags ());
3650
+ return adjustTableCost (Entry-> ISD , Entry-> Cost , LT.first , ICA.getFlags ());
3629
3651
}
3630
3652
3631
3653
return BaseT::getIntrinsicInstrCost (ICA, CostKind);
0 commit comments