Skip to content

Commit a7c6057

Browse files
author
git apple-llvm automerger
committed
Merge commit 'b93d74ac9c4e' from llvm.org/master into apple/main
2 parents 14f1200 + b93d74a commit a7c6057

File tree

3 files changed

+82
-54
lines changed

3 files changed

+82
-54
lines changed

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/IR/DerivedTypes.h"
2121
#include "llvm/IR/Instruction.h"
2222
#include "llvm/IR/Instructions.h"
23+
#include "llvm/IR/Intrinsics.h"
2324
#include "llvm/IR/IntrinsicInst.h"
2425
#include "llvm/IR/IntrinsicsARM.h"
2526
#include "llvm/IR/PatternMatch.h"
@@ -1409,6 +1410,29 @@ unsigned ARMTTIImpl::getGatherScatterOpCost(unsigned Opcode, Type *DataTy,
14091410
return ScalarCost;
14101411
}
14111412

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+
14121436
int ARMTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
14131437
TTI::TargetCostKind CostKind) {
14141438
// Currently we make a somewhat optimistic assumption that active_lane_mask's

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
247247
Align Alignment, TTI::TargetCostKind CostKind,
248248
const Instruction *I = nullptr);
249249

250+
int getArithmeticReductionCost(unsigned Opcode, VectorType *ValTy,
251+
bool IsPairwiseForm,
252+
TTI::TargetCostKind CostKind);
253+
250254
int getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
251255
TTI::TargetCostKind CostKind);
252256

0 commit comments

Comments
 (0)