[llvm] [DAGCombiner] Improve FMin/FMax DAGCombines (PR #161352)

Lewis Crawford via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 6 09:45:36 PDT 2025


================
@@ -653,5 +653,29 @@ define float @test_maxnum_const_nan(float %x) {
   ret float %r
 }
 
+; nnan maxnum(X, -inf) -> X
+define float @test_maxnum_neg_inf_nnan(float %x) nounwind {
+; CHECK-LABEL: test_maxnum_neg_inf_nnan:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    retq
+  %r = call nnan float @llvm.maxnum.f32(float %x, float 0xfff0000000000000)
+  ret float %r
----------------
LewisCrawford wrote:

Making %x an immediate would trigger constant-folding, so would use a different path. Swapping the args would also not work, as it still returns the same value.

I've added a 2nd argument %y to the outer function, and am calling min/max on %y instead now, so that the compiler needs to move arg1 into the return register, rather than just relying on arg0 already being in the right place. Hopefully this makes things easier to read and less implicit.

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


More information about the llvm-commits mailing list