[llvm] [InstCombine] Treat `uitofp nneg` as non-negative signed range for fcmp clamp folds (PR #208234)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 13 13:23:57 PDT 2026


================
@@ -8535,10 +8535,15 @@ Instruction *InstCombinerImpl::foldFCmpIntToFPConst(FCmpInst &I,
     }
   }
 
+  Value *X = LHSI->getOperand(0);
+
   // Lower this FP comparison into an appropriate integer version of the
   // comparison.
-  return new ICmpInst(Pred, LHSI->getOperand(0),
-                      ConstantInt::get(LHSI->getOperand(0)->getType(), RHSInt));
+  auto *NewCmp = new ICmpInst(Pred, X, ConstantInt::get(X->getType(), RHSInt));
+  if (LHSUnsigned && cast<PossiblyNonNegInst>(LHSI)->hasNonNeg() &&
+      RHSInt.isSignBitClear())
+    NewCmp->setSameSign();
----------------
arsenm wrote:

Is this supposed to be part of this patch? The direct effect is adding a flag, but none of the test outputs have an icmp 

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


More information about the llvm-commits mailing list