public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] simplify-rtx: Fix VOIDmode operand handling in simplify_subreg [PR108805]
@ 2023-02-16 17:39 Uros Bizjak
  2023-02-17  7:38 ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Uros Bizjak @ 2023-02-16 17:39 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Sandiford, Richard Biener

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

simplify_subreg can return VOIDmode const_int operand and will
cause ICE in simplify_gen_subreg when this operand is passed to it.

The patch prevents VOIDmode temporary from entering simplify_gen_subreg.
We can't process const_int operand any further, since outermode
is not an integer mode here.

2023-02-16  Uroš Bizjak  <ubizjak@gmail.com>

gcc/ChangeLog:

    PR target/108805
    * simplify_rtx.cc (simplify_context::simplify_subreg): Prevent
    VOIDmode const_int result from simplify_subreg from entering
    simplify_gen_subreg.

gcc/testsuite/ChangeLog:

    PR target/108805
    * gcc.dg/pr108805.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

OK for master and release branches?

Uros.

[-- Attachment #2: p.diff.txt --]
[-- Type: text/plain, Size: 1174 bytes --]

diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 0a1dd88b0a8..281bc418df0 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -7664,7 +7664,7 @@ simplify_context::simplify_subreg (machine_mode outermode, rtx op,
 			    0).exists (&int_outermode))
     {
       rtx tem = simplify_subreg (int_outermode, op, innermode, byte);
-      if (tem)
+      if (tem && GET_MODE (tem) != VOIDmode)
 	return simplify_gen_subreg (outermode, tem, GET_MODE (tem), 0);
     }
 
diff --git a/gcc/testsuite/gcc.dg/pr108805.c b/gcc/testsuite/gcc.dg/pr108805.c
new file mode 100644
index 00000000000..280d3f5c377
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr108805.c
@@ -0,0 +1,20 @@
+/* { dg-do compile { target longlong64 } } */
+/* { dg-options "-O" } */
+/* { dg-additional-options "-msse2" { target x86_64-*-* i?86-*-* } } */
+
+typedef __INT8_TYPE__ __attribute__((__vector_size__ (4))) U;
+typedef __INT32_TYPE__ __attribute__((__vector_size__ (4))) V;
+typedef __UINT64_TYPE__ __attribute__((__vector_size__ (8))) W;
+
+int i;
+U h;
+W g;
+
+U
+foo (void)
+{
+  W w = i != g;
+  V v = __builtin_convertvector (i | w >> 2, V);
+  U u = (U) v[0] + h;
+  return u;
+}

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-03-02 14:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 17:39 [PATCH] simplify-rtx: Fix VOIDmode operand handling in simplify_subreg [PR108805] Uros Bizjak
2023-02-17  7:38 ` Richard Biener
2023-02-17  8:51   ` Uros Bizjak
2023-02-17 11:31     ` Richard Biener
2023-02-17 15:05       ` Uros Bizjak
2023-02-27 15:46     ` Richard Sandiford
2023-03-02 10:08       ` Andre Vieira (lists)
2023-03-02 10:13         ` Richard Sandiford
2023-03-02 14:15           ` Andre Vieira (lists)

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