Skip to content

Commit 5f1335a

Browse files
Addressing reviewers (2)
1 parent 71d6952 commit 5f1335a

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,9 +1258,10 @@ class TargetTransformInfo {
12581258
/// Returns the cost of a vector instruction based on the assumption that frem
12591259
/// will be later transformed (by ReplaceWithVecLib) into a call to a
12601260
/// platform specific frem vector math function.
1261-
/// If unsupported, it will return cost using getArithmeticInstrCost.
1261+
/// Returns the same cost as getArithmeticInstrCost when no math function is
1262+
/// available.
12621263
InstructionCost getFRemInstrCost(
1263-
const TargetLibraryInfo *TLI, unsigned Opcode, Type *Ty,
1264+
const TargetLibraryInfo *TLI, Type *Ty,
12641265
TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput,
12651266
TTI::OperandValueInfo Opd1Info = {TTI::OK_AnyValue, TTI::OP_None},
12661267
TTI::OperandValueInfo Opd2Info = {TTI::OK_AnyValue, TTI::OP_None},

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -883,21 +883,17 @@ InstructionCost TargetTransformInfo::getArithmeticInstrCost(
883883
}
884884

885885
InstructionCost TargetTransformInfo::getFRemInstrCost(
886-
const TargetLibraryInfo *TLI, unsigned Opcode, Type *Ty,
887-
TTI::TargetCostKind CostKind, OperandValueInfo Op1Info,
888-
OperandValueInfo Op2Info, ArrayRef<const Value *> Args,
889-
const Instruction *CxtI) const {
890-
assert(Opcode == Instruction::FRem && "Instruction must be frem");
891-
886+
const TargetLibraryInfo *TLI, Type *Ty, TTI::TargetCostKind CostKind,
887+
OperandValueInfo Op1Info, OperandValueInfo Op2Info,
888+
ArrayRef<const Value *> Args, const Instruction *CxtI) const {
892889
VectorType *VecTy = dyn_cast<VectorType>(Ty);
893-
Type *ScalarTy = VecTy ? VecTy->getScalarType() : Ty;
894890
LibFunc Func;
895-
if (VecTy && TLI->getLibFunc(Opcode, ScalarTy, Func) &&
891+
if (VecTy && TLI->getLibFunc(Instruction::FRem, Ty->getScalarType(), Func) &&
896892
TLI->isFunctionVectorizable(TLI->getName(Func), VecTy->getElementCount()))
897893
return getCallInstrCost(nullptr, VecTy, {VecTy, VecTy}, CostKind);
898894

899-
return getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info, Op2Info, Args,
900-
CxtI);
895+
return getArithmeticInstrCost(Instruction::FRem, Ty, CostKind, Op1Info,
896+
Op2Info, Args, CxtI);
901897
}
902898

903899
InstructionCost TargetTransformInfo::getAltInstrCost(

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6901,10 +6901,9 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
69016901
SmallVector<const Value *, 4> Operands(I->operand_values());
69026902
TTI::OperandValueInfo Op1Info{TargetTransformInfo::OK_AnyValue,
69036903
TargetTransformInfo::OP_None};
6904-
// Some targets replace frem with vector library calls.
69056904
if (I->getOpcode() == Instruction::FRem)
6906-
return TTI.getFRemInstrCost(TLI, I->getOpcode(), VectorTy, CostKind,
6907-
Op1Info, Op2Info, Operands, I);
6905+
return TTI.getFRemInstrCost(TLI, VectorTy, CostKind, Op1Info, Op2Info,
6906+
Operands, I);
69086907

69096908
return TTI.getArithmeticInstrCost(I->getOpcode(), VectorTy, CostKind,
69106909
Op1Info, Op2Info, Operands, I);

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8616,11 +8616,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
86168616
unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
86178617
TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0));
86188618
TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx));
8619-
8620-
// Some targets replace frem with vector library calls.
86218619
if (ShuffleOrOp == Instruction::FRem)
8622-
return TTI->getFRemInstrCost(TLI, ShuffleOrOp, VecTy, CostKind, Op1Info,
8623-
Op2Info) +
8620+
return TTI->getFRemInstrCost(TLI, VecTy, CostKind, Op1Info, Op2Info) +
86248621
CommonCost;
86258622

86268623
return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,

0 commit comments

Comments
 (0)