Skip to content

Commit 0a77f3a

Browse files
Addressing reviewers
1 parent b4a7eed commit 0a77f3a

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,13 +1255,6 @@ class TargetTransformInfo {
12551255
ArrayRef<const Value *> Args = ArrayRef<const Value *>(),
12561256
const Instruction *CxtI = nullptr) const;
12571257

1258-
/// Returns the cost of a call when a target has a vector library function for
1259-
/// the given \p VecTy, otherwise an invalid cost.
1260-
InstructionCost getVecLibCallCost(const int OpCode,
1261-
const TargetLibraryInfo *TLI,
1262-
VectorType *VecTy,
1263-
TTI::TargetCostKind CostKind);
1264-
12651258
/// Returns the cost estimation for alternating opcode pattern that can be
12661259
/// lowered to a single instruction on the target. In X86 this is for the
12671260
/// addsub instruction which corrsponds to a Shuffle + Fadd + FSub pattern in

llvm/include/llvm/Analysis/VectorUtils.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/ADT/MapVector.h"
1717
#include "llvm/ADT/SmallVector.h"
1818
#include "llvm/Analysis/LoopAccessAnalysis.h"
19+
#include "llvm/Analysis/TargetTransformInfo.h"
1920
#include "llvm/IR/VFABIDemangler.h"
2021
#include "llvm/Support/CheckedArithmetic.h"
2122

@@ -119,7 +120,6 @@ template <typename InstTy> class InterleaveGroup;
119120
class IRBuilderBase;
120121
class Loop;
121122
class ScalarEvolution;
122-
class TargetTransformInfo;
123123
class Type;
124124
class Value;
125125

@@ -410,6 +410,14 @@ bool maskIsAllOneOrUndef(Value *Mask);
410410
/// for each lane which may be active.
411411
APInt possiblyDemandedEltsInMask(Value *Mask);
412412

413+
/// Returns the cost of a call when a target has a vector library function for
414+
/// the given \p VecTy, otherwise an invalid cost.
415+
InstructionCost getVecLibCallCost(const Instruction *I,
416+
const TargetTransformInfo *TTI,
417+
const TargetLibraryInfo *TLI,
418+
VectorType *VecTy,
419+
TargetTransformInfo::TargetCostKind CostKind);
420+
413421
/// The group of interleaved loads/stores sharing the same stride and
414422
/// close to each other.
415423
///

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "llvm/Analysis/TargetTransformInfo.h"
1010
#include "llvm/Analysis/CFG.h"
1111
#include "llvm/Analysis/LoopIterator.h"
12-
#include "llvm/Analysis/TargetLibraryInfo.h"
1312
#include "llvm/Analysis/TargetTransformInfoImpl.h"
1413
#include "llvm/IR/CFG.h"
1514
#include "llvm/IR/Dominators.h"
@@ -870,18 +869,6 @@ TargetTransformInfo::getOperandInfo(const Value *V) {
870869
return {OpInfo, OpProps};
871870
}
872871

873-
InstructionCost TargetTransformInfo::getVecLibCallCost(
874-
const int OpCode, const TargetLibraryInfo *TLI, VectorType *VecTy,
875-
TTI::TargetCostKind CostKind) {
876-
Type *ScalarTy = VecTy->getScalarType();
877-
LibFunc Func;
878-
if (TLI->getLibFunc(OpCode, ScalarTy, Func) &&
879-
TLI->isFunctionVectorizable(TLI->getName(Func), VecTy->getElementCount()))
880-
return getCallInstrCost(nullptr, VecTy, {ScalarTy, ScalarTy}, CostKind);
881-
882-
return InstructionCost::getInvalid();
883-
}
884-
885872
InstructionCost TargetTransformInfo::getArithmeticInstrCost(
886873
unsigned Opcode, Type *Ty, TTI::TargetCostKind CostKind,
887874
OperandValueInfo Op1Info, OperandValueInfo Op2Info,

llvm/lib/Analysis/VectorUtils.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/Analysis/LoopIterator.h"
1919
#include "llvm/Analysis/ScalarEvolution.h"
2020
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
21+
#include "llvm/Analysis/TargetLibraryInfo.h"
2122
#include "llvm/Analysis/TargetTransformInfo.h"
2223
#include "llvm/Analysis/ValueTracking.h"
2324
#include "llvm/IR/Constants.h"
@@ -1031,6 +1032,22 @@ APInt llvm::possiblyDemandedEltsInMask(Value *Mask) {
10311032
return DemandedElts;
10321033
}
10331034

1035+
InstructionCost
1036+
llvm::getVecLibCallCost(const Instruction *I, const TargetTransformInfo *TTI,
1037+
const TargetLibraryInfo *TLI, VectorType *VecTy,
1038+
TargetTransformInfo::TargetCostKind CostKind) {
1039+
SmallVector<Type *, 4> OpTypes;
1040+
for (auto &Op : I->operands())
1041+
OpTypes.push_back(Op->getType());
1042+
1043+
LibFunc Func;
1044+
if (TLI->getLibFunc(I->getOpcode(), I->getType(), Func) &&
1045+
TLI->isFunctionVectorizable(TLI->getName(Func), VecTy->getElementCount()))
1046+
return TTI->getCallInstrCost(nullptr, VecTy, OpTypes, CostKind);
1047+
1048+
return InstructionCost::getInvalid();
1049+
}
1050+
10341051
bool InterleavedAccessInfo::isStrided(int Stride) {
10351052
unsigned Factor = std::abs(Stride);
10361053
return Factor >= 2 && Factor <= MaxInterleaveGroupFactor;

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8366,7 +8366,7 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
83668366
ShuffleOrOp, VecTy, CostKind, Op1Info, Op2Info);
83678367
// Some targets can replace frem with vector library calls.
83688368
InstructionCost VecCallCost =
8369-
TTI->getVecLibCallCost(ShuffleOrOp, TLI, VecTy, CostKind);
8369+
getVecLibCallCost(VL0, TTI, TLI, VecTy, CostKind);
83708370
return std::min(VecInstrCost, VecCallCost) + CommonCost;
83718371
};
83728372
return GetCostDiff(GetScalarCost, GetVectorCost);

0 commit comments

Comments
 (0)