public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Disallow paradoxical subregs when outer mode is SCALAR_FLOAT_MODE_P.
@ 2021-09-10  4:52 liuhongt
  0 siblings, 0 replies; only message in thread
From: liuhongt @ 2021-09-10  4:52 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.guenther, rdsandiford, crazylht

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


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

only message in thread, other threads:[~2021-09-10  4:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  4:52 [PATCH] Disallow paradoxical subregs when outer mode is SCALAR_FLOAT_MODE_P liuhongt

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).