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

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 23 07:20:53 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])) &&
----------------
sushgokh wrote:

for the test where Op1 only or Op2 only is constant(see the added tests), simply relying on Op1Info and Op2Info does not work. In such cases, we need to pass args

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


More information about the llvm-commits mailing list