[llvm] [VPlan] Extend licm to sink replicate stores (PR #191026)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 11:59:44 PDT 2026
================
@@ -2557,14 +2564,29 @@ static void licm(VPlan &Plan) {
#ifndef NDEBUG
VPDominatorTree VPDT(Plan);
#endif
+ auto StoreGroups =
+ collectGroupedReplicateMemOps<Instruction::Store>(Plan, PSE, L);
+ VPTypeAnalysis TypeInfo(Plan);
+
// Sink recipes with no users inside the vector loop region if all users are
// in the same exit block of the region.
// TODO: Extend to sink recipes from inner loops.
PostOrderTraversal<VPBlockShallowTraversalWrapper<VPBlockBase *>> POT(
LoopRegion->getEntry());
for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(POT)) {
for (VPRecipeBase &R : make_early_inc_range(reverse(*VPBB))) {
- if (vputils::cannotHoistOrSinkRecipe(R, /*Sinking=*/true))
+ auto *GroupIt =
+ find_if(StoreGroups, [&R](ArrayRef<VPReplicateRecipe *> Group) {
+ return is_contained(Group, &R);
+ });
+ std::optional<SinkStoreInfo> SinkInfo =
+ GroupIt == StoreGroups.end()
+ ? std::nullopt
+ : std::make_optional<SinkStoreInfo>(*GroupIt, *GroupIt->front(),
+ PSE, *L, TypeInfo);
+ if (cannotHoistOrSinkRecipe(R, LoopRegion->getEntryBasicBlock(),
----------------
fhahn wrote:
I think we need a check that the pointer operand is loop-invariant; as-is I think we currently sink any single-scalar stores, moving stores to a different address in each vector loop iteration outside.
https://github.com/llvm/llvm-project/pull/191026
More information about the llvm-commits
mailing list