[llvm] [VPlan] Implement VPWidenCastRecipe::computeCost(). (NFCI) (PR #111339)

Elvis Wang via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 20 22:47:20 PDT 2024


================
@@ -7258,12 +7258,29 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,
     const auto &ChainOps = RdxDesc.getReductionOpChain(RedPhi, OrigLoop);
     SetVector<Instruction *> ChainOpsAndOperands(ChainOps.begin(),
                                                  ChainOps.end());
+    auto isZExtOrSExt = [](const unsigned Opcode) -> bool {
+      return Opcode == Instruction::ZExt || Opcode == Instruction::SExt;
+    };
     // Also include the operands of instructions in the chain, as the cost-model
     // may mark extends as free.
+    //
+    // For ARM, some of the instruction can folded into the reducion
+    // instruction. So we need to mark all folded instructions free.
+    // For example: We can fold reduce(mul(ext(A), ext(B))) into one
+    // instruction.
----------------
ElvisWang123 wrote:

I am working on the VPlan-based pattern match for ARM MVE reduction instructions.
After that we would be able to remove this hard-coded check in `precomputeCost()`.

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


More information about the llvm-commits mailing list