: Fix ICE in expand_expr_real_2 (PR target/91204)
diff mbox series

Message ID 20190720064538.GB2125@tucnak
State New
Headers show
Series
  • : Fix ICE in expand_expr_real_2 (PR target/91204)
Related show

Commit Message

Jakub Jelinek July 20, 2019, 6:45 a.m. UTC
On Fri, Jul 19, 2019 at 04:41:06PM +0200, Uros Bizjak wrote:
> As suggested by Jakub in the PR, add missing vector one_cmpl<mode>2 to
> mmx.md. A generic fix is in the works by Jakub.

Yes, here it is.  Bootstrapped/regtested on x86_64-linux and i686-linux, ok
for trunk?

2019-07-20  Jakub Jelinek  <jakub@redhat.com>

	PR target/91204
	* optabs.c (expand_unop): As fallback, expand ~op0 as op0 ^ -1.

	* gcc.c-torture/compile/pr91204.c: New test.



	Jakub

Comments

Richard Biener July 20, 2019, 4:54 p.m. UTC | #1
On July 20, 2019 8:45:38 AM GMT+02:00, Jakub Jelinek <jakub@redhat.com> wrote:
>On Fri, Jul 19, 2019 at 04:41:06PM +0200, Uros Bizjak wrote:
>> As suggested by Jakub in the PR, add missing vector one_cmpl<mode>2
>to
>> mmx.md. A generic fix is in the works by Jakub.
>
>Yes, here it is.  Bootstrapped/regtested on x86_64-linux and
>i686-linux, ok
>for trunk?

Ok. 

Richard. 

>2019-07-20  Jakub Jelinek  <jakub@redhat.com>
>
>	PR target/91204
>	* optabs.c (expand_unop): As fallback, expand ~op0 as op0 ^ -1.
>
>	* gcc.c-torture/compile/pr91204.c: New test.
>
>--- gcc/optabs.c.jj	2019-07-15 10:53:10.743205405 +0200
>+++ gcc/optabs.c	2019-07-19 00:38:20.271852242 +0200
>@@ -2972,6 +2972,17 @@ expand_unop (machine_mode mode, optab un
>       return target;
>     }
> 
>+  /* Emit ~op0 as op0 ^ -1.  */
>+  if (unoptab == one_cmpl_optab
>+      && (SCALAR_INT_MODE_P (mode) || GET_MODE_CLASS (mode) ==
>MODE_VECTOR_INT)
>+      && optab_handler (xor_optab, mode) != CODE_FOR_nothing)
>+    {
>+      temp = expand_binop (mode, xor_optab, op0, CONSTM1_RTX (mode),
>+			   target, unsignedp, OPTAB_DIRECT);
>+      if (temp)
>+	return temp;
>+    }
>+
>   if (optab_to_code (unoptab) == NEG)
>     {
>    /* Try negating floating point values by flipping the sign bit.  */
>--- gcc/testsuite/gcc.c-torture/compile/pr91204.c.jj	2019-07-19
>09:29:32.366011373 +0200
>+++ gcc/testsuite/gcc.c-torture/compile/pr91204.c	2019-07-19
>09:29:11.011340662 +0200
>@@ -0,0 +1,11 @@
>+/* PR target/91204 */
>+
>+int a, b, c[64];
>+
>+void
>+foo (void)
>+{
>+  int i;
>+  for (i = 2; i < 64; i++)
>+    c[i] &= b ^ c[i] ^ c[i - 2];
>+}
>
>
>	Jakub

Patch
diff mbox series

--- gcc/optabs.c.jj	2019-07-15 10:53:10.743205405 +0200
+++ gcc/optabs.c	2019-07-19 00:38:20.271852242 +0200
@@ -2972,6 +2972,17 @@  expand_unop (machine_mode mode, optab un
       return target;
     }
 
+  /* Emit ~op0 as op0 ^ -1.  */
+  if (unoptab == one_cmpl_optab
+      && (SCALAR_INT_MODE_P (mode) || GET_MODE_CLASS (mode) == MODE_VECTOR_INT)
+      && optab_handler (xor_optab, mode) != CODE_FOR_nothing)
+    {
+      temp = expand_binop (mode, xor_optab, op0, CONSTM1_RTX (mode),
+			   target, unsignedp, OPTAB_DIRECT);
+      if (temp)
+	return temp;
+    }
+
   if (optab_to_code (unoptab) == NEG)
     {
       /* Try negating floating point values by flipping the sign bit.  */
--- gcc/testsuite/gcc.c-torture/compile/pr91204.c.jj	2019-07-19 09:29:32.366011373 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr91204.c	2019-07-19 09:29:11.011340662 +0200
@@ -0,0 +1,11 @@ 
+/* PR target/91204 */
+
+int a, b, c[64];
+
+void
+foo (void)
+{
+  int i;
+  for (i = 2; i < 64; i++)
+    c[i] &= b ^ c[i] ^ c[i - 2];
+}