[llvm] [VPlan] Support early-exit loops in optimizeForVFAndUF. (PR #131539)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 17 01:47:37 PDT 2025
================
@@ -1019,9 +1046,12 @@ void VPlanTransforms::optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF,
// 1. BranchOnCount, or
// 2. BranchOnCond where the input is Not(ActiveLaneMask).
using namespace llvm::VPlanPatternMatch;
+ VPValue *Cond;
if (!match(Term, m_BranchOnCount(m_VPValue(), m_VPValue())) &&
- !match(Term,
- m_BranchOnCond(m_Not(m_ActiveLaneMask(m_VPValue(), m_VPValue())))))
+ !match(Term, m_BranchOnCond(
+ m_Not(m_ActiveLaneMask(m_VPValue(), m_VPValue())))) &&
+ (!match(Term, m_BranchOnCond(m_VPValue(Cond))) ||
+ isConditionKnown(Cond, Plan, BestVF, BestUF, *PSE.getSE())))
----------------
david-arm wrote:
To be honest I don't know how this even works. If the terminator is a branch-on-cond recipe and the condition is known to be true then bail out and don't do any optimisations. Yet surely the case you're optimising (as shown by the tests) is precisely when you know the condition is true?!
Unless I'm missing something, it suggests that `isConditionKnown` is actually returning false for your tests, doesn't it?
https://github.com/llvm/llvm-project/pull/131539
More information about the llvm-commits
mailing list