From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 6/6] Use element_precision for match.pd arith conversion optimization
Date: Fri, 23 Jun 2023 10:27:58 +0200 (CEST) [thread overview]
Message-ID: <20230623082759.0DD281331F@imap2.suse-dmz.suse.de> (raw)
The simplification (outertype)((innertype0)a+(innertype1)b) to
((newtype)a+(newtype)b) ends up using TYPE_PRECISION to check
whether it can elide a conversion but in some paths there can
be VECTOR_TYPEs where this instead compares the number of lanes.
The following fixes the missed optimizations and uses
element_precision in those places.
Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will
push after that finished.
* match.pd ((outertype)((innertype0)a+(innertype1)b)
-> ((newtype)a+(newtype)b)): Use element_precision
where appropriate.
---
gcc/match.pd | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gcc/match.pd b/gcc/match.pd
index 85d562a531d..48b76e6a051 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7428,9 +7428,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& newtype == type
&& types_match (newtype, type))
(op (convert:newtype @1) (convert:newtype @2))
- (with { if (TYPE_PRECISION (ty1) > TYPE_PRECISION (newtype))
+ (with { if (element_precision (ty1) > element_precision (newtype))
newtype = ty1;
- if (TYPE_PRECISION (ty2) > TYPE_PRECISION (newtype))
+ if (element_precision (ty2) > element_precision (newtype))
newtype = ty2; }
/* Sometimes this transformation is safe (cannot
change results through affecting double rounding
@@ -7453,9 +7453,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
exponent range for the product or ratio of two
values representable in the TYPE to be within the
range of normal values of ITYPE. */
- (if (TYPE_PRECISION (newtype) < TYPE_PRECISION (itype)
+ (if (element_precision (newtype) < element_precision (itype)
&& (flag_unsafe_math_optimizations
- || (TYPE_PRECISION (newtype) == TYPE_PRECISION (type)
+ || (element_precision (newtype) == element_precision (type)
&& real_can_shorten_arithmetic (TYPE_MODE (itype),
TYPE_MODE (type))
&& !excess_precision_type (newtype)))
--
2.35.3
reply other threads:[~2023-06-23 8:27 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230623082759.0DD281331F@imap2.suse-dmz.suse.de \
--to=rguenther@suse.de \
--cc=gcc-patches@gcc.gnu.org \
/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).