[llvm] [VectorCombine] Scalarize bin ops and cmps with two splatted operands (PR #137786)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 11:28:03 PDT 2025
================
@@ -1099,29 +1110,33 @@ bool VectorCombine::scalarizeBinopOrCmp(Instruction &I) {
// Get cost estimate for the insert element. This cost will factor into
// both sequences.
InstructionCost InsertCost = TTI.getVectorInstrCost(
- Instruction::InsertElement, VecTy, CostKind, Index);
- InstructionCost OldCost =
- (IsConst0 ? 0 : InsertCost) + (IsConst1 ? 0 : InsertCost) + VectorOpCost;
- InstructionCost NewCost = ScalarOpCost + InsertCost +
- (IsConst0 ? 0 : !Ins0->hasOneUse() * InsertCost) +
- (IsConst1 ? 0 : !Ins1->hasOneUse() * InsertCost);
+ Instruction::InsertElement, VecTy, CostKind, Index.value_or(0));
+ InstructionCost OldCost = (isa<Constant>(Ins0) ? 0 : InsertCost) +
----------------
preames wrote:
The costing here looks suspect. In particular, I would assume that (splat x) + (splat y) needs to be costed differently that (insertelt undef, x, 0) + (insertelt undef, y, 0). Consider the case where this is a m8 vector type.
https://github.com/llvm/llvm-project/pull/137786
More information about the llvm-commits
mailing list