[llvm] [VPlan] Try to hoist Previous (and operands), if sinking fails for FORs. (PR #108945)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 12 14:58:51 PDT 2024
================
@@ -771,6 +771,92 @@ sinkRecurrenceUsersAfterPrevious(VPFirstOrderRecurrencePHIRecipe *FOR,
return true;
}
+/// Try to hoist \p Previous and its operands before all users of \p FOR.
+static bool hoistPreviousBeforeFORUsers(VPFirstOrderRecurrencePHIRecipe *FOR,
+ VPRecipeBase *Previous,
+ VPDominatorTree &VPDT) {
+ using namespace llvm::VPlanPatternMatch;
+ if (Previous->mayHaveSideEffects() || Previous->mayReadFromMemory())
+ return false;
+
+ // Collect recipes that need hoisting.
+ SmallVector<VPRecipeBase *> WorkList;
+ SmallPtrSet<VPRecipeBase *, 8> Seen;
+ VPBasicBlock *HoistBlock = FOR->getParent();
+ auto HoistPoint = HoistBlock->getFirstNonPhi();
----------------
ayalz wrote:
Simpler to set HoistPoint to FOR, given the flat loop? See more below.
https://github.com/llvm/llvm-project/pull/108945
More information about the llvm-commits
mailing list