|
20 | 20 | #include "llvm/IR/DerivedTypes.h"
|
21 | 21 | #include "llvm/IR/Instruction.h"
|
22 | 22 | #include "llvm/IR/Instructions.h"
|
| 23 | +#include "llvm/IR/Intrinsics.h" |
23 | 24 | #include "llvm/IR/IntrinsicInst.h"
|
24 | 25 | #include "llvm/IR/IntrinsicsARM.h"
|
25 | 26 | #include "llvm/IR/PatternMatch.h"
|
@@ -1409,6 +1410,29 @@ unsigned ARMTTIImpl::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
|
1409 | 1410 | return ScalarCost;
|
1410 | 1411 | }
|
1411 | 1412 |
|
| 1413 | +int ARMTTIImpl::getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy, |
| 1414 | + bool IsPairwiseForm, |
| 1415 | + TTI::TargetCostKind CostKind) { |
| 1416 | + EVT ValVT = TLI->getValueType(DL, ValTy); |
| 1417 | + int ISD = TLI->InstructionOpcodeToISD(Opcode); |
| 1418 | + if (!ST->hasMVEIntegerOps() || !ValVT.isSimple() || ISD != ISD::ADD) |
| 1419 | + return BaseT::getArithmeticReductionCost(Opcode, ValTy, IsPairwiseForm, |
| 1420 | + CostKind); |
| 1421 | + |
| 1422 | + std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, ValTy); |
| 1423 | + |
| 1424 | + static const CostTblEntry CostTblAdd[]{ |
| 1425 | + {ISD::ADD, MVT::v16i8, 1}, |
| 1426 | + {ISD::ADD, MVT::v8i16, 1}, |
| 1427 | + {ISD::ADD, MVT::v4i32, 1}, |
| 1428 | + }; |
| 1429 | + if (const auto *Entry = CostTableLookup(CostTblAdd, ISD, LT.second)) |
| 1430 | + return Entry->Cost * ST->getMVEVectorCostFactor() * LT.first; |
| 1431 | + |
| 1432 | + return BaseT::getArithmeticReductionCost(Opcode, ValTy, IsPairwiseForm, |
| 1433 | + CostKind); |
| 1434 | +} |
| 1435 | + |
1412 | 1436 | int ARMTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
|
1413 | 1437 | TTI::TargetCostKind CostKind) {
|
1414 | 1438 | // Currently we make a somewhat optimistic assumption that active_lane_mask's
|
|
0 commit comments