From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tree-optimization/112369 - strip_float_extensions and vectors
Date: Mon, 6 Nov 2023 08:55:58 +0000 (UTC) [thread overview]
Message-ID: <20231106085558.okBuJePejpJGyf4M2gN-7F6Rxx8m0ao10eThxrgYmeY@z> (raw)
The following fixes an error in strip_float_extensions when facing
vector conversions.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/112369
* tree.cc (strip_float_extensions): Use element_precision.
* gcc.dg/pr112369.c: New testcase.
---
gcc/testsuite/gcc.dg/pr112369.c | 23 +++++++++++++++++++++++
gcc/tree.cc | 2 +-
2 files changed, 24 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr112369.c
diff --git a/gcc/testsuite/gcc.dg/pr112369.c b/gcc/testsuite/gcc.dg/pr112369.c
new file mode 100644
index 00000000000..677e3543f54
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr112369.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+/* { dg-additional-options "-mavx2" { target avx2 } } */
+
+struct GdkRGBA2 {
+ double a[4];
+};
+struct GdkRGBA3 {
+ float a[4];
+};
+struct GdkRGBA3 f(struct GdkRGBA2 *color) {
+ struct GdkRGBA3 t1;
+ for(int i = 0; i < 4; i++)
+ t1.a[i] = color->a[i];
+ struct GdkRGBA3 t2;
+ for(int i = 0; i < 4; i++)
+ {
+ float tmp = t1.a[i];
+ if (__builtin_isnan(tmp))
+ t2.a[i] = tmp;
+ }
+ return t2;
+}
diff --git a/gcc/tree.cc b/gcc/tree.cc
index cfead156ddf..9c9b057cd88 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -12138,7 +12138,7 @@ strip_float_extensions (tree exp)
if (DECIMAL_FLOAT_TYPE_P (expt) != DECIMAL_FLOAT_TYPE_P (subt))
return exp;
- if (TYPE_PRECISION (subt) > TYPE_PRECISION (expt))
+ if (element_precision (subt) > element_precision (expt))
return exp;
return strip_float_extensions (sub);
--
2.35.3
reply other threads:[~2023-11-06 8:56 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=20231106085558.okBuJePejpJGyf4M2gN-7F6Rxx8m0ao10eThxrgYmeY@z \
--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).