[llvm] [LV] Follow up to uncountable exit with side effects vectorization (PR #201589)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 14 11:10:36 PDT 2026
================
@@ -4232,24 +4377,29 @@ static bool handleUncountableExitsWithSideEffects(
// We can abandon a VPlan entirely if we return false here, so we shouldn't
// crash if some earlier assumptions on scalar IR don't hold for the vplan
// version of the loop.
- SmallVector<VPInstruction *, 2> GEPs;
SmallVector<VPInstruction *, 8> ConditionRecipes;
std::optional<VPValue *> Cond =
- vputils::getRecipesForUncountableExit(ConditionRecipes, GEPs, LatchVPBB);
+ getRecipesForUncountableExit(ConditionRecipes, LatchVPBB);
if (!Cond)
return false;
// Find load contributing to condition.
- VPRecipeBase *CondLoad = nullptr;
- for (auto *Recipe : ConditionRecipes) {
- if (match(Recipe, m_VPInstruction<Instruction::Load>(m_VPValue()))) {
- // TODO: Support more than one load. Needs legality updates too.
- assert(CondLoad == nullptr && "Too many condition loads");
- CondLoad = Recipe;
- }
- }
- assert(CondLoad && "Couldn't find load");
+ // At the moment LoopVectorizationLegality only supports a single
+ // early-exit expression with a compare and a single load that must
+ // be unconditional.
+ // TODO: Support more than one load.
+ auto *Load =
+ find_singleton<VPInstruction>(ConditionRecipes, [](auto *I, bool _) {
+ return match(I, m_VPInstruction<Instruction::Load>(m_VPValue()))
+ ? I
+ : nullptr;
+ });
+ assert(Load && "Couldn't find load");
----------------
fhahn wrote:
```suggestion
assert(Load && "Couldn't find exactly one load");
```
https://github.com/llvm/llvm-project/pull/201589
More information about the llvm-commits
mailing list