[llvm] [NFC][VPlan] Split `makeMemOpWideningDecisions` into subpasses (PR #182593)
Andrei Elovikov via llvm-commits
llvm-commits at lists.llvm.org
Sun May 10 21:52:13 PDT 2026
================
@@ -6473,38 +6473,79 @@ void VPlanTransforms::makeMemOpWideningDecisions(
}
}
- VPBasicBlock *MiddleVPBB = Plan.getMiddleBlock();
+ // Few helpers to process different kinds of memory operations.
+
+ // To be used as argument to `VPlanTransforms::runPass` which explicitly
+ // specified pass name, hence `VPlan &` parameter.
+ auto ProcessSubset = [&](VPlan &, auto ProcessVPInst) {
+ SmallVector<VPInstruction *> RemainingMemOps;
+ for (VPInstruction *VPI : MemOps) {
+ if (!ProcessVPInst(VPI))
+ RemainingMemOps.push_back(VPI);
+ }
+
+ MemOps.clear();
+ std::swap(MemOps, RemainingMemOps);
+ };
+
+ auto ReplaceWith = [&](VPInstruction *VPI, VPRecipeBase *New) {
+ New->insertBefore(VPI);
+ if (VPI->getOpcode() == Instruction::Load)
+ VPI->replaceAllUsesWith(New->getVPSingleValue());
+ VPI->eraseFromParent();
+
+ // VPI has been processed.
+ return true;
+ };
+
+ auto Scalarize = [&](VPInstruction *VPI) {
+ return ReplaceWith(VPI, RecipeBuilder.handleReplication(VPI, Range));
+ };
+
+ auto *MiddleVPBB = Plan.getMiddleBlock();
VPBuilder FinalRedStoresBuilder(MiddleVPBB, MiddleVPBB->getFirstNonPhi());
+ VPlanTransforms::runPass(
+ "lowerMemoryIdioms", ProcessSubset, Plan, [&](VPInstruction *VPI) {
----------------
eas wrote:
No, it needs to be at least two. What I want to have is:
1) Some "legacy" decisions that new code must *NOT* override.
2) [Future VPlan-based code] Possibility for new code to make a different decision (e.g. unit-strideness speculation directly on VPlan, on Mel's strided loads/stores could go here.
3) Everything not processed by 1/2 goes to old CM again.
https://github.com/llvm/llvm-project/pull/182593
More information about the llvm-commits
mailing list