Skip to content

Commit 332ce17

Browse files
committed
[CostModel] Make sure getCmpSelInstrCost is passed a CondTy
It is already required along certain code paths that the CondTy is valid. Fix some of the uses to make sure it is passed.
1 parent 734660b commit 332ce17

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,11 +1384,9 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
13841384
return InstructionCost::getInvalid();
13851385

13861386
unsigned Num = cast<FixedVectorType>(ValVTy)->getNumElements();
1387-
if (CondTy)
1388-
CondTy = CondTy->getScalarType();
1389-
InstructionCost Cost =
1390-
thisT()->getCmpSelInstrCost(Opcode, ValVTy->getScalarType(), CondTy,
1391-
VecPred, CostKind, Op1Info, Op2Info, I);
1387+
InstructionCost Cost = thisT()->getCmpSelInstrCost(
1388+
Opcode, ValVTy->getScalarType(), CondTy->getScalarType(), VecPred,
1389+
CostKind, Op1Info, Op2Info, I);
13921390

13931391
// Return the cost of multiple scalar invocation plus the cost of
13941392
// inserting and extracting the values.

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,8 @@ static bool validateAndCostRequiredSelects(BasicBlock *BB, BasicBlock *ThenBB,
30943094
if (ThenV == OrigV)
30953095
continue;
30963096

3097-
Cost += TTI.getCmpSelInstrCost(Instruction::Select, PN.getType(), nullptr,
3097+
Cost += TTI.getCmpSelInstrCost(Instruction::Select, PN.getType(),
3098+
CmpInst::makeCmpResultType(PN.getType()),
30983099
CmpInst::BAD_ICMP_PREDICATE, CostKind);
30993100

31003101
// Don't convert to selects if we could remove undefined behavior instead.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6974,10 +6974,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
69746974
}
69756975

69766976
VectorTy = toVectorTy(ValTy, VF);
6977-
return TTI.getCmpSelInstrCost(I->getOpcode(), VectorTy, nullptr,
6978-
cast<CmpInst>(I)->getPredicate(), CostKind,
6979-
{TTI::OK_AnyValue, TTI::OP_None},
6980-
{TTI::OK_AnyValue, TTI::OP_None}, I);
6977+
return TTI.getCmpSelInstrCost(
6978+
I->getOpcode(), VectorTy, CmpInst::makeCmpResultType(VectorTy),
6979+
cast<CmpInst>(I)->getPredicate(), CostKind,
6980+
{TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None}, I);
69816981
}
69826982
case Instruction::Store:
69836983
case Instruction::Load: {

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,10 +1753,10 @@ InstructionCost VPWidenRecipe::computeCost(ElementCount VF,
17531753
case Instruction::FCmp: {
17541754
Instruction *CtxI = dyn_cast_or_null<Instruction>(getUnderlyingValue());
17551755
Type *VectorTy = toVectorTy(Ctx.Types.inferScalarType(getOperand(0)), VF);
1756-
return Ctx.TTI.getCmpSelInstrCost(Opcode, VectorTy, nullptr, getPredicate(),
1757-
Ctx.CostKind,
1758-
{TTI::OK_AnyValue, TTI::OP_None},
1759-
{TTI::OK_AnyValue, TTI::OP_None}, CtxI);
1756+
return Ctx.TTI.getCmpSelInstrCost(
1757+
Opcode, VectorTy, CmpInst::makeCmpResultType(VectorTy), getPredicate(),
1758+
Ctx.CostKind, {TTI::OK_AnyValue, TTI::OP_None},
1759+
{TTI::OK_AnyValue, TTI::OP_None}, CtxI);
17601760
}
17611761
default:
17621762
llvm_unreachable("Unsupported opcode for instruction");

0 commit comments

Comments
 (0)