Skip to content

Commit e183459

Browse files
authored
[CostModel] Make sure getCmpSelInstrCost is passed a CondTy (#135535)
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 f024aab commit e183459

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
@@ -6966,10 +6966,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,
69666966
}
69676967

69686968
VectorTy = toVectorTy(ValTy, VF);
6969-
return TTI.getCmpSelInstrCost(I->getOpcode(), VectorTy, nullptr,
6970-
cast<CmpInst>(I)->getPredicate(), CostKind,
6971-
{TTI::OK_AnyValue, TTI::OP_None},
6972-
{TTI::OK_AnyValue, TTI::OP_None}, I);
6969+
return TTI.getCmpSelInstrCost(
6970+
I->getOpcode(), VectorTy, CmpInst::makeCmpResultType(VectorTy),
6971+
cast<CmpInst>(I)->getPredicate(), CostKind,
6972+
{TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None}, I);
69736973
}
69746974
case Instruction::Store:
69756975
case Instruction::Load: {

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,10 +1765,10 @@ InstructionCost VPWidenRecipe::computeCost(ElementCount VF,
17651765
case Instruction::FCmp: {
17661766
Instruction *CtxI = dyn_cast_or_null<Instruction>(getUnderlyingValue());
17671767
Type *VectorTy = toVectorTy(Ctx.Types.inferScalarType(getOperand(0)), VF);
1768-
return Ctx.TTI.getCmpSelInstrCost(Opcode, VectorTy, nullptr, getPredicate(),
1769-
Ctx.CostKind,
1770-
{TTI::OK_AnyValue, TTI::OP_None},
1771-
{TTI::OK_AnyValue, TTI::OP_None}, CtxI);
1768+
return Ctx.TTI.getCmpSelInstrCost(
1769+
Opcode, VectorTy, CmpInst::makeCmpResultType(VectorTy), getPredicate(),
1770+
Ctx.CostKind, {TTI::OK_AnyValue, TTI::OP_None},
1771+
{TTI::OK_AnyValue, TTI::OP_None}, CtxI);
17721772
}
17731773
default:
17741774
llvm_unreachable("Unsupported opcode for instruction");

0 commit comments

Comments
 (0)