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

Kshitij Paranjape via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 29 08:25:33 PST 2026


================
@@ -5954,6 +5954,36 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
       }
     }
 
+    // Look for the case of a for loop which has a positive
+    // initial value and is incremented by a squared value.
+    // This will propagate sign information out of such loops.
+    if (P->getNumIncomingValues() == 2) {
+      Value *RecurValue = P->getIncomingValue(1);
+      IntrinsicInst *I = dyn_cast<IntrinsicInst>(RecurValue);
+      if (!I)
+        break;
+      Value *R, *L;
+      Value *Init;
+      PHINode *PN;
+      if (matchSimpleTernaryIntrinsicRecurrence(I, PN, Init, L, R)) {
+        switch (I->getIntrinsicID()) {
+        case Intrinsic::fma:
+        case Intrinsic::fmuladd: {
+          KnownFPClass KnownStart, KnownL;
+          computeKnownFPClass(Init, DemandedElts,
+                              KnownFPClass::OrderedGreaterThanZeroMask,
----------------
kshitijvp wrote:

Done


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


More information about the llvm-commits mailing list