public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2135] match.pd: Use element_mode instead of TYPE_MODE.
@ 2023-06-27 21:30 Robin Dapp
  0 siblings, 0 replies; only message in thread
From: Robin Dapp @ 2023-06-27 21:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d915762ea9043da858d388b60b2d8093ff77eeab

commit r14-2135-gd915762ea9043da858d388b60b2d8093ff77eeab
Author: Robin Dapp <rdapp@ventanamicro.com>
Date:   Mon Jun 26 13:30:26 2023 +0200

    match.pd: Use element_mode instead of TYPE_MODE.
    
    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.

Diff:
---
 gcc/match.pd | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 33ccda3e7b6..83bcefa914b 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-27 21:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 21:30 [gcc r14-2135] match.pd: Use element_mode instead of TYPE_MODE Robin Dapp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).