public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Robin Dapp <rdapp.gcc@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Cc: rdapp.gcc@gmail.com, Richard Biener <rguenther@suse.de>,
	Tamar.Christina@arm.com
Subject: [PATCH] match.pd: Use element_mode instead of TYPE_MODE.
Date: Mon, 26 Jun 2023 16:26:58 +0200	[thread overview]
Message-ID: <3fc809a1-6667-daca-e95a-b0a58825e16f@gmail.com> (raw)

Hi,

this patch changes TYPE_MODE into element_mode in a match.pd
simplification.  As the simplification can be 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 in the
new mode.  One target that supports e.g. a float addition but not a
_Float16 addition is the RISC-V vector Float16 extension Zvfhmin.

Bootstrap on x86_64 succeeded, testsuite is currently running.  Is this OK
if the testsuite is clean?

Regards
 Robin

gcc/ChangeLog:

	* match.pd: Use element_mode and check if target supports
	operation with new type.
---
 gcc/match.pd | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 33ccda3e7b6..4a200f221f6 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7454,10 +7454,11 @@ 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)
+		   && 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)
-- 
2.41.0

             reply	other threads:[~2023-06-26 14:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-26 14:26 Robin Dapp [this message]
2023-06-26 23:18 ` Jeff Law
2023-06-27  6:30 ` Richard Biener
2023-06-27  6:47   ` Robin Dapp
2023-06-27  7:03     ` Richard Biener
2023-06-27  7:42       ` Robin Dapp
2023-06-27  8:46         ` Richard Biener
2023-06-27  9:42           ` Robin Dapp
2023-06-27  9:50             ` Richard Biener
2023-06-27  9:55               ` Robin Dapp
2023-06-27 10:05                 ` Richard Biener
2023-06-27 15:55                   ` Robin Dapp
2023-06-27 23:05                     ` Andrew Pinski
2023-06-28  7:27                       ` Andrew Pinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3fc809a1-6667-daca-e95a-b0a58825e16f@gmail.com \
    --to=rdapp.gcc@gmail.com \
    --cc=Tamar.Christina@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).