[SLP] use reduction kind's opcode for cost model queries; NFC

This should be no-functional-change because the reduction kind
opcodes are 1-for-1 mappings to the instructions we are matching
as reductions. But we want to remove the need for the
`OperationData` opcode field because that does not work when
we start matching intrinsics (eg, maxnum) as reduction candidates.
This commit is contained in:
Sanjay Patel 2021-01-05 15:08:51 -05:00
parent d4a999b453
commit 5a1d31a284
1 changed files with 5 additions and 6 deletions

View File

@ -7138,6 +7138,7 @@ private:
auto *VecTy = FixedVectorType::get(ScalarTy, ReduxWidth); auto *VecTy = FixedVectorType::get(ScalarTy, ReduxWidth);
RecurKind Kind = RdxTreeInst.getKind(); RecurKind Kind = RdxTreeInst.getKind();
unsigned RdxOpcode = RecurrenceDescriptor::getOpcode(Kind);
int SplittingRdxCost; int SplittingRdxCost;
switch (Kind) { switch (Kind) {
case RecurKind::Add: case RecurKind::Add:
@ -7147,9 +7148,8 @@ private:
case RecurKind::Xor: case RecurKind::Xor:
case RecurKind::FAdd: case RecurKind::FAdd:
case RecurKind::FMul: case RecurKind::FMul:
SplittingRdxCost = SplittingRdxCost = TTI->getArithmeticReductionCost(
TTI->getArithmeticReductionCost(RdxTreeInst.getOpcode(), VecTy, RdxOpcode, VecTy, /*IsPairwiseForm=*/false);
/*IsPairwiseForm=*/false);
break; break;
case RecurKind::SMax: case RecurKind::SMax:
case RecurKind::SMin: case RecurKind::SMin:
@ -7175,15 +7175,14 @@ private:
case RecurKind::Xor: case RecurKind::Xor:
case RecurKind::FAdd: case RecurKind::FAdd:
case RecurKind::FMul: case RecurKind::FMul:
ScalarReduxCost = ScalarReduxCost = TTI->getArithmeticInstrCost(RdxOpcode, ScalarTy);
TTI->getArithmeticInstrCost(RdxTreeInst.getOpcode(), ScalarTy);
break; break;
case RecurKind::SMax: case RecurKind::SMax:
case RecurKind::SMin: case RecurKind::SMin:
case RecurKind::UMax: case RecurKind::UMax:
case RecurKind::UMin: case RecurKind::UMin:
ScalarReduxCost = ScalarReduxCost =
TTI->getCmpSelInstrCost(RdxTreeInst.getOpcode(), ScalarTy) + TTI->getCmpSelInstrCost(RdxOpcode, ScalarTy) +
TTI->getCmpSelInstrCost(Instruction::Select, ScalarTy, TTI->getCmpSelInstrCost(Instruction::Select, ScalarTy,
CmpInst::makeCmpResultType(ScalarTy)); CmpInst::makeCmpResultType(ScalarTy));
break; break;