]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
match.pd: Use element_mode instead of TYPE_MODE.
authorRobin Dapp <rdapp@ventanamicro.com>
Mon, 26 Jun 2023 11:30:26 +0000 (13:30 +0200)
committerRobin Dapp <rdapp@ventanamicro.com>
Tue, 27 Jun 2023 20:39:26 +0000 (22:39 +0200)
This patch changes TYPE_MODE into element_mode in a match.pd
simplification.  As the simplification can be also called with vector
types real_can_shorten_arithmetic would ICE in REAL_MODE_FORMAT which
expects a scalar mode.  Therefore, use element_mode instead of
TYPE_MODE.

Additionally, check if the target supports the resulting operation.  One
target that supports e.g. a float addition but not a _Float16 addition
is the RISC-V vector extension Zvfhmin.

gcc/ChangeLog:

* match.pd: Use element_mode and check if target supports
operation with new type.

gcc/match.pd

index 33ccda3e7b6bdb863ddc475ff8e133b519501272..83bcefa914bf8a4bbbd91625d57d49700f55fa7f 100644 (file)
@@ -7454,10 +7454,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
                  values representable in the TYPE to be within the
                  range of normal values of ITYPE.  */
              (if (element_precision (newtype) < element_precision (itype)
+                  && (!VECTOR_MODE_P (TYPE_MODE (newtype))
+                      || target_supports_op_p (newtype, op, optab_default))
                   && (flag_unsafe_math_optimizations
                       || (element_precision (newtype) == element_precision (type)
-                          && real_can_shorten_arithmetic (TYPE_MODE (itype),
-                                                          TYPE_MODE (type))
+                          && real_can_shorten_arithmetic (element_mode (itype),
+                                                          element_mode (type))
                           && !excess_precision_type (newtype)))
                   && !types_match (itype, newtype))
                 (convert:type (op (convert:newtype @1)