[llvm] [ValueTracking] Propogate sign information out of loop (PR #175590)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 14 08:59:58 PST 2026


================
@@ -5956,7 +5953,25 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
     // Unreachable blocks may have zero-operand PHI nodes.
     if (P->getNumIncomingValues() == 0)
       break;
-
+    // Look for the case of a for loop which has a positive
+    // initial value and is incremented by a squared value.
+    // This will propogate sign information out of such loops.
+    if (P->getNumIncomingValues() == 2) {
+      Value *Start = P->getIncomingValue(0);
+      Value *RecurValue = P->getIncomingValue(1);
+      Value *X;
+      if (match(RecurValue, m_Intrinsic<Intrinsic::fmuladd>(
+                                m_Value(X), m_Value(X), m_Specific(P)))) {
----------------
dtcxzyw wrote:

We have a variant called `matchSimpleBinaryIntrinsicRecurrence`

https://github.com/llvm/llvm-project/pull/175590


More information about the llvm-commits mailing list