[llvm] a959796 - [VPlan] Assert ComputeReductionResult isn't predicated in middle block. NFC (#191767)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 01:20:34 PDT 2026
Author: Luke Lau
Date: 2026-04-13T08:20:29Z
New Revision: a95979686f532a194d9fb8a8671800f5e75e3405
URL: https://github.com/llvm/llvm-project/commit/a95979686f532a194d9fb8a8671800f5e75e3405
DIFF: https://github.com/llvm/llvm-project/commit/a95979686f532a194d9fb8a8671800f5e75e3405.diff
LOG: [VPlan] Assert ComputeReductionResult isn't predicated in middle block. NFC (#191767)
Added:
Modified:
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index d46f05f9ead57..b2e8b6a85a35a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -3288,6 +3288,17 @@ static void fixupVFUsersForEVL(VPlan &Plan, VPValue &EVL) {
if (!HeaderMask)
return;
+ // Ensure that any reduction that uses a select to mask off tail lanes does so
+ // in the vector loop, not the middle block, since EVL tail folding can have
+ // tail elements in the penultimate iteration.
+ assert(all_of(*Plan.getMiddleBlock(), [&Plan, HeaderMask](VPRecipeBase &R) {
+ if (match(&R, m_ComputeReductionResult(m_Select(m_Specific(HeaderMask),
+ m_VPValue(), m_VPValue()))))
+ return R.getOperand(0)->getDefiningRecipe()->getRegion() ==
+ Plan.getVectorLoopRegion();
+ return true;
+ }));
+
// Replace header masks with a mask equivalent to predicating by EVL:
//
// icmp ule widen-canonical-iv backedge-taken-count
More information about the llvm-commits
mailing list