[llvm] [VPlan] Add transform to fold early-exit branches into loops (PR #148404)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 14 01:09:06 PDT 2025
================
@@ -7242,6 +7246,10 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
// Regions are dissolved after optimizing for VF and UF, which completely
// removes unneeded loop regions first.
VPlanTransforms::dissolveLoopRegions(BestVPlan);
+
+ if (FoldEarlyExitBranchIntoLoop)
----------------
david-arm wrote:
Yeah, I'd like to assess the performance impact of such a change as well before making this the default behaviour as we've previously optimised codegen for the approach favoured by @fhahn. However, in my initial implementation of the early exit work the CFG looked similar to how it does in this PR. Isn't the problem here also about choosing the best canonical form that allows following IR passes to optimise the best they can? The advantage of this new approach is presumably that you can add individual branch weights to match the scalar PGO data.
cc @huntergr-arm since he is intending to add support for having stores in early exit loops, which also requires a different approach.
https://github.com/llvm/llvm-project/pull/148404
More information about the llvm-commits
mailing list