[llvm-branch-commits] [llvm] [DAGCombiner] Mark uint_to_fp widened through trunc nuw as nneg (PR #242916)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 15 19:55:18 PST 2026


================
@@ -21009,10 +21009,13 @@ SDValue DAGCombiner::visitUINT_TO_FP(SDNode *N) {
     return DAG.getNode(ISD::UINT_TO_FP, DL, VT, Trunc);
   }
 
-  // fold (uint_to_fp (trunc nuw x)) -> (uint_to_fp x)
+  // fold (uint_to_fp (trunc nuw x)) -> (uint_to_fp nneg x)
   if (N0.getOpcode() == ISD::TRUNCATE && N0->getFlags().hasNoUnsignedWrap() &&
-      TLI.isTypeDesirableForOp(N, N0.getOperand(0).getValueType()))
-    return DAG.getNode(ISD::UINT_TO_FP, DL, VT, N0.getOperand(0));
+      TLI.isTypeDesirableForOp(N, N0.getOperand(0).getValueType())) {
+    SDNodeFlags Flags = N->getFlags();
+    Flags.setNonNeg(true);
+    return DAG.getNode(ISD::UINT_TO_FP, DL, VT, N0.getOperand(0), Flags);
----------------
arsenm wrote:

These days you should be able to write the flag value inline without the SDNodeFlags + set 

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


More information about the llvm-branch-commits mailing list