[llvm] [ValueTracking] Fix crash in PR175590 (PR #180355)

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 8 08:28:12 PST 2026


================
@@ -5924,6 +5924,43 @@ 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) {
+      for (int i = 0; i < 2; i++) {
+        Value *RecurValue = P->getIncomingValue(1 - i);
+        IntrinsicInst *I = dyn_cast<IntrinsicInst>(RecurValue);
+        if (I) {
----------------
ilovepi wrote:

nit: You can reduce nesting here too.
```suggestion
        if (!I) 
          continue;
```

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


More information about the llvm-commits mailing list