@@ -4409,6 +4409,32 @@ AArch64TTIImpl::getAddressComputationCost(Type *PtrTy, ScalarEvolution *SE,
44094409 return 1 ;
44104410}
44114411
4412+ // / Check whether Opcode1 has less throughput according to the scheduling
4413+ // / model than Opcode2.
4414+ bool AArch64TTIImpl::hasKnownLowerThroughputFromSchedulingModel (
4415+ unsigned Opcode1, unsigned Opcode2) const {
4416+ const MCSchedModel &Sched = ST->getSchedModel ();
4417+ const TargetInstrInfo *TII = ST->getInstrInfo ();
4418+ if (!Sched.hasInstrSchedModel ())
4419+ return false ;
4420+
4421+ const MCSchedClassDesc *SCD1 =
4422+ Sched.getSchedClassDesc (TII->get (Opcode1).getSchedClass ());
4423+ const MCSchedClassDesc *SCD2 =
4424+ Sched.getSchedClassDesc (TII->get (Opcode2).getSchedClass ());
4425+ // We cannot handle variant scheduling classes without an MI. If we need to
4426+ // support them for any of the instructions we query the information of we
4427+ // might need to add a way to resolve them without a MI or not use the
4428+ // scheduling info.
4429+ assert (!SCD1->isVariant () && !SCD2->isVariant () &&
4430+ " Cannot handle variant scheduling classes without an MI" );
4431+ if (!SCD1->isValid () || !SCD2->isValid ())
4432+ return false ;
4433+
4434+ return MCSchedModel::getReciprocalThroughput (*ST, *SCD1) >
4435+ MCSchedModel::getReciprocalThroughput (*ST, *SCD2);
4436+ }
4437+
44124438InstructionCost AArch64TTIImpl::getCmpSelInstrCost (
44134439 unsigned Opcode, Type *ValTy, Type *CondTy, CmpInst::Predicate VecPred,
44144440 TTI::TargetCostKind CostKind, TTI::OperandValueInfo Op1Info,
@@ -4506,6 +4532,12 @@ InstructionCost AArch64TTIImpl::getCmpSelInstrCost(
45064532 (VecPred == FCmpInst::FCMP_ONE || VecPred == FCmpInst::FCMP_UEQ))
45074533 Factor = 3 ; // fcmxx+fcmyy+or
45084534
4535+ if (isa<ScalableVectorType>(ValTy) &&
4536+ CostKind == TTI::TCK_RecipThroughput &&
4537+ hasKnownLowerThroughputFromSchedulingModel (AArch64::FCMEQ_PPzZZ_S,
4538+ AArch64::FCMEQv4f32))
4539+ Factor *= 2 ;
4540+
45094541 return Factor * (CostKind == TTI::TCK_Latency ? 2 : LT.first );
45104542 }
45114543
0 commit comments