[llvm] [VPlan] Compute cost of more replicating loads/stores in ::computeCost. (PR #160053)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 01:46:08 PDT 2025


================
@@ -3068,6 +3068,63 @@ bool VPReplicateRecipe::shouldPack() const {
   });
 }
 
+/// Returns true if \p Ptr is a pointer computation for which the legacy cost
+/// model computes a SCEV expression when computing the address cost.
+static bool shouldUseAddressAccessSCEV(VPValue *Ptr) {
+  auto *PtrR = Ptr->getDefiningRecipe();
+  if (!PtrR || !((isa<VPReplicateRecipe>(PtrR) &&
+                  cast<VPReplicateRecipe>(PtrR)->getOpcode() ==
+                      Instruction::GetElementPtr) ||
+                 isa<VPWidenGEPRecipe>(PtrR)))
+    return false;
+
+  // We are looking for a GEP with all loop invariant indices except for one
+  // which should be an induction variable.
----------------
david-arm wrote:

nit: Does the comment need updating here as it doesn't seem to match the code? What the code really seems to do is "make sure all operands are either loop invariants or induction variables", i.e. there can be more than one induction variable.

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


More information about the llvm-commits mailing list