[llvm] [LoopPeel] Peel iterations based on and, or conditions (PR #73413)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 1 00:26:26 PST 2023
================
@@ -351,11 +351,19 @@ static unsigned countToEliminateCompares(Loop &L, unsigned MaxPeelCount,
MaxPeelCount =
std::min((unsigned)SC->getAPInt().getLimitedValue() - 1, MaxPeelCount);
- auto ComputePeelCount = [&](Value *Condition) -> void {
+ std::function<void(Value *)> ComputePeelCount =
+ [&](Value *Condition) -> void {
if (!Condition->getType()->isIntegerTy())
return;
Value *LeftVal, *RightVal;
+ if (match(Condition, m_And(m_Value(LeftVal), m_Value(RightVal))) ||
+ match(Condition, m_Or(m_Value(LeftVal), m_Value(RightVal)))) {
+ ComputePeelCount(LeftVal);
+ ComputePeelCount(RightVal);
----------------
nikic wrote:
What I had in mind here is stack overflow due to deep recursion. But yes, having a visited set is also a good idea, as it ensures there is no exponential blowup for some degenerate IR.
https://github.com/llvm/llvm-project/pull/73413
More information about the llvm-commits
mailing list