[llvm] SelectionDAG: Support FMINIMUMNUM and FMINIMUM in combineMinNumMaxNumImpl (PR #137449)
YunQiang Su via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 11 21:09:04 PST 2025
================
@@ -229,13 +229,10 @@ define float @fminnum32_intrinsic(float %x, float %y) {
; CHECK-LABEL: fminnum32_intrinsic:
; CHECK: .functype fminnum32_intrinsic (f32, f32) -> (f32)
; CHECK-NEXT: # %bb.0:
-; CHECK-NEXT: local.get $push5=, 0
-; CHECK-NEXT: local.get $push4=, 1
-; CHECK-NEXT: local.get $push3=, 0
-; CHECK-NEXT: local.get $push2=, 1
-; CHECK-NEXT: f32.lt $push0=, $pop3, $pop2
-; CHECK-NEXT: f32.select $push1=, $pop5, $pop4, $pop0
-; CHECK-NEXT: return $pop1
+; CHECK-NEXT: local.get $push2=, 0
+; CHECK-NEXT: local.get $push1=, 1
+; CHECK-NEXT: f32.min $push0=, $pop2, $pop1
----------------
wzssyqa wrote:
> but I suspect that `f21.lt` + `select` would compile to fewer machine instructions
In fact it depends: for targets that has max/min opcodes, such as AArch64/RISCV/MIPSr6/LoongArch etc, f32.min can be mapped to hardware instructions directly; for something like x86, which has no such instructions, `f21.lt + select` will be better.
https://github.com/llvm/llvm-project/pull/137449
More information about the llvm-commits
mailing list