[llvm] PowerPC/VSX: Select FMINNUM_IEEE and FMAXNUM_IEEE (PR #112195)

YunQiang Su via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 22 18:43:09 PDT 2024


================
@@ -2735,39 +2744,23 @@ def : Pat<(f32 (fneg (fabs f32:$S))),
 // f32 Min.
 def : Pat<(f32 (fminnum_ieee f32:$A, f32:$B)),
           (f32 FpMinMax.F32Min)>;
-def : Pat<(f32 (fminnum_ieee (fcanonicalize f32:$A), f32:$B)),
-          (f32 FpMinMax.F32Min)>;
-def : Pat<(f32 (fminnum_ieee f32:$A, (fcanonicalize f32:$B))),
-          (f32 FpMinMax.F32Min)>;
-def : Pat<(f32 (fminnum_ieee (fcanonicalize f32:$A), (fcanonicalize f32:$B))),
+def : Pat<(f32 (fminnum f32:$A, f32:$B)),
           (f32 FpMinMax.F32Min)>;
 // F32 Max.
 def : Pat<(f32 (fmaxnum_ieee f32:$A, f32:$B)),
           (f32 FpMinMax.F32Max)>;
-def : Pat<(f32 (fmaxnum_ieee (fcanonicalize f32:$A), f32:$B)),
-          (f32 FpMinMax.F32Max)>;
-def : Pat<(f32 (fmaxnum_ieee f32:$A, (fcanonicalize f32:$B))),
-          (f32 FpMinMax.F32Max)>;
-def : Pat<(f32 (fmaxnum_ieee (fcanonicalize f32:$A), (fcanonicalize f32:$B))),
+def : Pat<(f32 (fmaxnum f32:$A, f32:$B)),
           (f32 FpMinMax.F32Max)>;
----------------
wzssyqa wrote:

Since `xsmaxdp|xsmindp` treat +0.0>-0.0, we should always prefer them if possible.
Here, if we have `nnan` tag or `--enable-no-nans-fp-math` argument, we can use either one of `xsmaxcdp|xsmincdp` or `xsmaxdp|xsmindp`.

And we still have a problem here:
```
define dso_local float @testfmax_fast(float %a, float %b) local_unnamed_addr {
; NO-FAST-P9-LABEL: testfmax_fast:
; NO-FAST-P9:       # %bb.0: # %entry
; NO-FAST-P9-NEXT:    xsmaxcdp f1, f1, f2
; NO-FAST-P9-NEXT:    blr
entry:
  %cmp = fcmp nnan ninf ogt float %a, %b
  %cond = select i1 %cmp, float %a, float %b
  ret float %cond
}
```

In fact we can use `xsmaxdp`.

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


More information about the llvm-commits mailing list