[llvm] [ValueTracking] Handle recursive select/PHI in ComputeKnownBits (PR #114689)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 3 02:08:36 PST 2024
================
@@ -580,6 +580,43 @@ static bool cmpExcludesZero(CmpInst::Predicate Pred, const Value *RHS) {
return true;
}
+static void breakSelfRecursivePHI(const Use *U, const PHINode *PHI,
+ Value *&ValOut, Instruction *&CtxIOut,
+ unsigned *DepthInOut = nullptr) {
+ ValOut = U->get();
+ if (ValOut == PHI)
+ return;
+ CtxIOut = PHI->getIncomingBlock(*U)->getTerminator();
+ Value *V;
+ // If the Use is a select of this phi, compute analysis on other arm to be
+ // recusion.
+ // TODO: FMin/FMax
+ if (match(ValOut, m_Select(m_Value(), m_Specific(PHI), m_Value(V))) ||
+ match(ValOut, m_Select(m_Value(), m_Value(V), m_Specific(PHI))) ||
+ match(ValOut, m_c_MaxOrMin(m_Value(V), m_Specific(PHI)))) {
----------------
nikic wrote:
Can you please keep the extension to min/max for a separate PR? It seems unrelated to the core change here.
https://github.com/llvm/llvm-project/pull/114689
More information about the llvm-commits
mailing list