[llvm] [LV] Transform to handle exits in the scalar loop (PR #148626)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 08:26:47 PST 2025
================
@@ -262,6 +262,16 @@ struct VPlanTransforms {
VPlan &Plan, VPBasicBlock *HeaderVPBB,
VPBasicBlock *LatchVPBB);
+ /// Update \p Plan to check whether the next iteration of the vector loop
+ /// would exit (using any exit type) and if so branch to the scalar loop
+ /// instead. This requires identifying the recipes that form the conditions
+ /// for exiting, cloning them to the preheader, then adjusting both the
+ /// preheader recipes (to check the first vector iteration) and those in
+ /// the vector loop (to check the next vector iteration instead of the
+ /// current one). This can be used to avoid complex masking for state-changing
+ /// recipes (like stores).
----------------
david-arm wrote:
Also, when I was at a similar stage doing the initial early exit work (under a flag) @fhahn asked me to put some documentation in llvm/docs/Vectorizers.rst too, along with a diagram (vplan-early-exit.png) showing the new vplan structure. I think it would be good to add something similar to be consistent. At the very least, the section called "Early Exit Vectorization" in llvm/docs/Vectorizers.rst needs updating I think.
https://github.com/llvm/llvm-project/pull/148626
More information about the llvm-commits
mailing list