[llvm] [LV] Vectorize uncountable early exit store loops with combined conditions (PR #205109)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 22 07:54:06 PDT 2026
================
@@ -1780,26 +1804,52 @@ bool LoopVectorizationLegality::canUncountableExitConditionLoadBeMoved(
auto *Br = cast<CondBrInst>(ExitingBlock->getTerminator());
using namespace llvm::PatternMatch;
- Instruction *L = nullptr;
- Value *Ptr = nullptr;
- Value *R = nullptr;
- // The exit-condition load can appear on either side of the icmp.
+ using namespace llvm::SCEVPatternMatch;
+ Value *Ptr, *L, *R, *IVInc = nullptr;
+ // We want to match either an uncounted condition (loaded value compared
+ // against a loop invariant value) or the combination (via logical or) of
+ // an uncounted condition with a counted condition (integer comparison of
+ // an induction variable for which we can identify an add recurrence within
+ // this loop).
+ auto m_Uncounted = [](auto &&Ptr, auto &&L, auto &&R) {
+ return m_OneUse(
+ m_c_ICmp(m_OneUse(m_Value(L, m_Load(m_Value(Ptr)))), m_Value(R)));
+ };
+ auto m_Counted = [](auto &&IVInc) {
+ return m_c_ICmp(m_Value(IVInc, m_Add(m_Value(), m_Value())), m_Value());
+ };
----------------
fhahn wrote:
this is duplicated in multiple places, could we share the logic somehow so we have a single place to update?
Also, around line 1684 we allow any value as other condition, while here and below i t must a compare of a load
https://github.com/llvm/llvm-project/pull/205109
More information about the llvm-commits
mailing list