[llvm] [TTI] Include scalarization overhead for icmp/fcmp result (PR #206697)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 03:38:41 PDT 2026
================
@@ -1464,9 +1464,14 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
// Return the cost of multiple scalar invocation plus the cost of
// inserting and extracting the values.
- return getScalarizationOverhead(ValVTy, /*Insert*/ true,
- /*Extract*/ false, CostKind) +
- Num * Cost;
+ InstructionCost Overhead =
+ getScalarizationOverhead(ValVTy, /*Insert*/ false,
+ /*Extract*/ true, CostKind);
+ if (Opcode == Instruction::ICmp || Opcode == Instruction::FCmp)
+ Overhead +=
+ getScalarizationOverhead(cast<VectorType>(CondTy), /*Insert*/ true,
+ /*Extract*/ false, CostKind);
+ return Overhead + Num * Cost;
----------------
RKSimon wrote:
Still not sure this is correct, for the scalarization overheads shouldn't it be:
icmp/fcmp: overhead = 2 * extract of the ValVTy + 1 * insert of CondTy
select: overhead = 2 * extract of the ValVTy + 1 * extract of CondTy + 1 * insert of ValVTy
Ideally we could be using the getOperandsScalarizationOverhead helpers?
https://github.com/llvm/llvm-project/pull/206697
More information about the llvm-commits
mailing list