Skip to content

Commit ecd7da7

Browse files
Addressing reviewers (2)
1 parent 34bbbf8 commit ecd7da7

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
@@ -885,21 +885,17 @@ InstructionCost TargetTransformInfo::getArithmeticInstrCost(
885885
}
886886

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

901-
return getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info, Op2Info, Args,
902-
CxtI);
897+
return getArithmeticInstrCost(Instruction::FRem, Ty, CostKind, Op1Info,
898+
Op2Info, Args, CxtI);
903899
}
904900

905901
InstructionCost TargetTransformInfo::getAltInstrCost(

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6913,10 +6913,9 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
69136913
SmallVector<const Value *, 4> Operands(I->operand_values());
69146914
TTI::OperandValueInfo Op1Info{TargetTransformInfo::OK_AnyValue,
69156915
TargetTransformInfo::OP_None};
6916-
// Some targets replace frem with vector library calls.
69176916
if (I->getOpcode() == Instruction::FRem)
6918-
return TTI.getFRemInstrCost(TLI, I->getOpcode(), VectorTy, CostKind,
6919-
Op1Info, Op2Info, Operands, I);
6917+
return TTI.getFRemInstrCost(TLI, VectorTy, CostKind, Op1Info, Op2Info,
6918+
Operands, I);
69206919

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

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8851,11 +8851,8 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value *> VectorizedVals,
88518851
unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
88528852
TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0));
88538853
TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx));
8854-
8855-
// Some targets replace frem with vector library calls.
88568854
if (ShuffleOrOp == Instruction::FRem)
8857-
return TTI->getFRemInstrCost(TLI, ShuffleOrOp, VecTy, CostKind, Op1Info,
8858-
Op2Info) +
8855+
return TTI->getFRemInstrCost(TLI, VecTy, CostKind, Op1Info, Op2Info) +
88598856
CommonCost;
88608857

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

0 commit comments

Comments
 (0)