]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
s390x: Fix fmin/fmax patterns
authorJuergen Christ <jchrist@linux.ibm.com>
Mon, 15 Sep 2025 10:13:22 +0000 (12:13 +0200)
committerJuergen Christ <jchrist@linux.ibm.com>
Fri, 10 Oct 2025 13:16:51 +0000 (15:16 +0200)
s390x floating point minimum and maximum functions unfortunately do
not canonicalize NaNs.  Hence, test pr105414.c fails since
c476f554e3f.  Fix this by only allowing fmin/fmax pattern if signaling
NaNs are disabled.

gcc/ChangeLog:

* config/s390/vector.md (fmax<mode>3): Restrict to no trapping
math.
(fmin<mode>3): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/s390/fminmax-1.c: Disable for signaling NaNs.
* gcc.target/s390/fminmax-2.c: Ditto.
* gcc.target/s390/vector/reduc-minmax-1.c: Ditto.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
gcc/config/s390/vector.md
gcc/testsuite/gcc.target/s390/fminmax-1.c
gcc/testsuite/gcc.target/s390/fminmax-2.c
gcc/testsuite/gcc.target/s390/vector/reduc-minmax-1.c

index 205ead2ca9d8fb81fb143116f708197e48efd16e..375e3e81ae178e5e20de707687a687206470c486 100644 (file)
               (match_operand:VFT_BFP           2 "register_operand")
               (const_int 4)]
              UNSPEC_FMAX))]
-  "TARGET_VXE")
+  "TARGET_VXE && !flag_signaling_nans")
 
 ; fmin
 (define_expand "fmin<mode>3"
               (match_operand:VFT_BFP           2 "register_operand")
               (const_int 4)]
              UNSPEC_FMIN))]
-  "TARGET_VXE")
+  "TARGET_VXE && !flag_signaling_nans")
 
 ; reduc_plus
 (define_expand "reduc_plus_scal_<mode>"
        (unspec:V2DF [(match_dup 1) (match_dup 2) (const_int 4)] REDUC_FMINMAX))
    (set (match_operand:DF 0 "register_operand" "")
        (vec_select:DF (match_dup 3) (parallel [(const_int 0)])))]
-  "TARGET_VX"
+  "TARGET_VX && !flag_trapping_math"
 {
   operands[2] = gen_reg_rtx (V2DFmode);
   operands[3] = gen_reg_rtx (V2DFmode);
        (unspec:V4SF [(match_dup 3) (match_dup 4) (const_int 4)] REDUC_FMINMAX))
    (set (match_operand:SF 0 "register_operand")
        (vec_select:SF (match_dup 5) (parallel [(const_int 0)])))]
-   "TARGET_VXE"
+   "TARGET_VXE && !flag_trapping_math"
 {
   operands[2] = gen_reg_rtx (V4SFmode);
   operands[3] = gen_reg_rtx (V4SFmode);
index df10905f037ae4b653136b5a67ef0cd91c518529..756a19970a5009b38b30dae158c4688090dd3907 100644 (file)
@@ -1,7 +1,7 @@
 /* Check fmin/fmax expanders for scalars on VXE targets.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O2 -march=z14 -mzarch" } */
+/* { dg-options "-O2 -march=z14 -mzarch -fno-trapping-math" } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 /*
index ea37a0a821de0ff16f6b5057a3a515e23c97e25a..ac090c65d1bde9e98c5a5be681552cef90477f83 100644 (file)
@@ -1,7 +1,7 @@
 /* Check fmin/fmax expanders for scalars on non-VXE targets.  */
 
 /* { dg-do compile } */
-/* { dg-options "-O2 -march=z13 -mzarch" } */
+/* { dg-options "-O2 -march=z13 -mzarch -fno-trapping-math" } */
 /* { dg-final { scan-assembler-times "jg" 4 } } */
 
 double
index 5295250dcb74caaf9436d4092c5b32c94f562e5d..7f4d16a03dddd3b697849dee721169adfe1fe5e3 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O3 -mzarch -march=z14 -ftree-vectorize -fdump-tree-optimized" } */
+/* { dg-options "-O3 -mzarch -march=z14 -ftree-vectorize -fdump-tree-optimized -fno-trapping-math" } */
 
 #define MAX(a, b) ((a) > (b) ? (a) : (b))
 #define MIN(a, b) ((a) > (b) ? (b) : (a))