[llvm] [AArch64][CostModel] Improve cost estimate of scalarizing a vector di… (PR #118055)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 07:33:36 PST 2025


================
@@ -3572,6 +3573,40 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
           Cost *= 4;
         return Cost;
       } else {
+        // If the information about individual scalars being vectorized is
+        // available, this yeilds better cost estimation.
+        if (auto *VTy = dyn_cast<FixedVectorType>(Ty); VTy && !Args.empty()) {
+          assert(Args.size() % 2 == 0 && "Args size should be even");
+          InstructionCost InsertExtractCost =
+              ST->getVectorInsertExtractBaseCost();
+          // If the cost of single sdiv is inquired through the cost-model.
+          // FIXME: remove the isa checks once the PR 122236 lands.
+          if (Args.size() == 2 &&
+              !(isa<ConstantVector>(Args[1]) ||
+                isa<ConstantDataVector>(Args[1]) ||
+                isa<ConstantExpr>(Args[1])) &&
----------------
alexey-bataev wrote:

Also, I told this before already, if the node is scalarized, it must be represented as a buildvector node.

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


More information about the llvm-commits mailing list