From: liuhongt <hongtao.liu@intel.com>
To: gcc-patches@gcc.gnu.org
Cc: richard.guenther@gmail.com, rdsandiford@googlemail.com,
crazylht@gmail.com
Subject: [PATCH] Disallow paradoxical subregs when outer mode is SCALAR_FLOAT_MODE_P.
Date: Fri, 10 Sep 2021 12:52:26 +0800 [thread overview]
Message-ID: <20210910045226.3752863-1-hongtao.liu@intel.com> (raw)
Hi:
In general_operand, paradoxical subregs w/ outermode SCALAR_FLOAT_MODE_P
are not allowed unless lra_in_progress, so this patch add the restriction
to validate_subreg as well.
Bootstrapped and regtested on x86_64-linux-gnu{-m32,}
Also the newly added tests are compiled with aarch64-linux-gnu-gcc w/o ICE.
Ok for trunk?
gcc/ChangeLog:
PR middle-end/102254
PR middle-end/102154
* emit-rtl.c (validate_subreg): Disallow paradoxical subregs
when omode is SCALAR_FLOAT_MODE_P.
gcc/testsuite/ChangeLog:
* gcc.target/i386/pr102254.c: New test.
---
gcc/emit-rtl.c | 8 ++++++--
gcc/testsuite/gcc.target/i386/pr102254.c | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/i386/pr102254.c
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 77ea8948ee8..29fa29e1001 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -922,9 +922,13 @@ validate_subreg (machine_mode omode, machine_mode imode,
poly_uint64 regsize = REGMODE_NATURAL_SIZE (imode);
- /* Paradoxical subregs must have offset zero. */
+ /* Paradoxical subregs must have offset zero and omode not
+ SCALAR_FLOAT_MODE_P.
+ i.e. things like (subreg:DF (reg:SF)) or (subreg:DF (reg:SI))
+ are not allowed. */
if (maybe_gt (osize, isize))
- return known_eq (offset, 0U);
+ return known_eq (offset, 0U)
+ && (!SCALAR_FLOAT_MODE_P (omode) || lra_in_progress);
/* This is a normal subreg. Verify that the offset is representable. */
diff --git a/gcc/testsuite/gcc.target/i386/pr102254.c b/gcc/testsuite/gcc.target/i386/pr102254.c
new file mode 100644
index 00000000000..93d25c3d317
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr102254.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-Og" } */
+
+#define MODFL __builtin_modfl
+void
+foo (void)
+{
+ int x;
+ *((double *) &x) = 0;
+}
+
+void
+foo1 (void)
+{
+ float x;
+
+ *((double *) &x) = 0;
+}
+
+void foo2() {
+ long iptrll;
+ MODFL(0.5l, (long double *)&iptrll);
+}
--
2.27.0
reply other threads:[~2021-09-10 4:52 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=20210910045226.3752863-1-hongtao.liu@intel.com \
--to=hongtao.liu@intel.com \
--cc=crazylht@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=rdsandiford@googlemail.com \
--cc=richard.guenther@gmail.com \
/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).