[llvm] [VPlan] Extend licm to hoist replicate loads (PR #179506)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 13:53:36 PDT 2026
================
@@ -307,6 +307,30 @@ static bool cannotHoistOrSinkRecipe(const VPRecipeBase &R) {
return RepR && RepR->getOpcode() == Instruction::Alloca;
}
+/// Return true if we do not know how to (mechanically) hoist or sink a
+/// non-memory or memory recipe \p R out of a loop region.
+static bool
+cannotHoistOrSinkRecipe(VPRecipeBase &R,
+ ArrayRef<SmallVector<VPReplicateRecipe *, 4>> MemGroups,
+ VPBasicBlock *FirstBB, VPBasicBlock *LastBB) {
+ if (!isa<VPReplicateRecipe>(R) || !R.mayReadFromMemory())
+ return cannotHoistOrSinkRecipe(R);
+
+ auto FilteredMemGroup =
+ make_filter_range(MemGroups, [&R](ArrayRef<VPReplicateRecipe *> Group) {
+ return is_contained(Group, &R);
+ });
+ if (FilteredMemGroup.empty())
+ return true;
+ assert(std::distance(FilteredMemGroup.begin(), FilteredMemGroup.end()) == 1 &&
+ "Recipe expected to be found in exactly one MemGroup");
+ auto MemGroup = *FilteredMemGroup.begin();
----------------
artagnon wrote:
Hm, isn't the original version clearer? The new version isn't even more compact?
https://github.com/llvm/llvm-project/pull/179506
More information about the llvm-commits
mailing list