[llvm] [NVPTX][TTI] Update NVPTX TTI to enable f32x2 vectorization (PR #222994)

Daniel Donenfeld via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 5 15:02:38 PDT 2026


================
@@ -527,6 +578,48 @@ InstructionCost NVPTXTTIImpl::getArithmeticInstrCost(
   }
 }
 
+InstructionCost NVPTXTTIImpl::getScalarizationOverhead(
+    VectorType *InTy, const APInt &DemandedElts, bool Insert, bool Extract,
+    TTI::TargetCostKind CostKind, bool ForPoisonSrc, ArrayRef<Value *> VL,
+    TTI::VectorInstrContext VIC) const {
+  if (!InTy->getElementCount().isFixed())
+    return InstructionCost::getInvalid();
+
+  auto VT = getTLI()->getValueType(DL, InTy);
+  auto NumElements = InTy->getElementCount().getFixedValue();
+  InstructionCost Cost = 0;
+  if (Insert && !VL.empty()) {
+    bool AllConstant = all_of(seq(NumElements), [&](int Idx) {
+      return !DemandedElts[Idx] || isa<Constant>(VL[Idx]);
+    });
+    if (AllConstant) {
+      Cost += TTI::TCC_Free;
+      Insert = false;
+    } else if (isV2F32Ty(InTy) && isDemandedSplat(VL, DemandedElts)) {
----------------
daniel-donenfeld wrote:

I fixed this, this could have incorrectly costed the case with just one demanded element

https://github.com/llvm/llvm-project/pull/222994


More information about the llvm-commits mailing list