re PR rtl-optimization/49145 (ICE in simplify_const_unary_operation, at simplify...
authorRichard Sandiford <rdsandiford@googlemail.com>
Mon, 6 Jun 2011 18:16:18 +0000 (18:16 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 6 Jun 2011 18:16:18 +0000 (18:16 +0000)
gcc/
PR rtl-optimization/49145
* combine.c (make_compound_operation): Handle ZERO_EXTEND specially.

gcc/testsuite/
PR rtl-optimization/49145
From Ryan Mansfield
* gcc.c-torture/compile/pr49145.c: New test.

From-SVN: r174718

gcc/ChangeLog
gcc/combine.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr49145.c [new file with mode: 0644]

index a4164a3eabfbdad07ffa226c4bb2b350a6a27d77..5333f528b51eb830da4b1c94e6e9ad034ffb7f76 100644 (file)
@@ -1,3 +1,8 @@
+2011-06-06  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       PR rtl-optimization/49145
+       * combine.c (make_compound_operation): Handle ZERO_EXTEND specially.
+
 2011-06-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/49262
index 8af86f2c545aa25af204ff3ed76652a24b520521..5b68bab12d796c32598fc948bc0d03fde917f165 100644 (file)
@@ -7881,7 +7881,20 @@ make_compound_operation (rtx x, enum rtx_code in_code)
       code = GET_CODE (x);
     }
 
-  /* Now recursively process each operand of this operation.  */
+  /* Now recursively process each operand of this operation.  We need to
+     handle ZERO_EXTEND specially so that we don't lose track of the
+     inner mode.  */
+  if (GET_CODE (x) == ZERO_EXTEND)
+    {
+      new_rtx = make_compound_operation (XEXP (x, 0), next_code);
+      tem = simplify_const_unary_operation (ZERO_EXTEND, GET_MODE (x),
+                                           new_rtx, GET_MODE (XEXP (x, 0)));
+      if (tem)
+       return tem;
+      SUBST (XEXP (x, 0), new_rtx);
+      return x;
+    }
+
   fmt = GET_RTX_FORMAT (code);
   for (i = 0; i < GET_RTX_LENGTH (code); i++)
     if (fmt[i] == 'e')
index fdfc9a9ed2ef13e8672bcecf193fb3f5f0b603b3..761935012aba76285387c58120084a4fc2fc4703 100644 (file)
@@ -1,3 +1,9 @@
+2011-06-06  Richard Sandiford  <rdsandiford@googlemail.com>
+
+       PR rtl-optimization/49145
+       From Ryan Mansfield
+       * gcc.c-torture/compile/pr49145.c: New test.
+
 2011-06-06  Jakub Jelinek  <jakub@redhat.com>
 
        PR testsuite/49288
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr49145.c b/gcc/testsuite/gcc.c-torture/compile/pr49145.c
new file mode 100644 (file)
index 0000000..079fc88
--- /dev/null
@@ -0,0 +1,30 @@
+static int
+func1 (int a, int b)
+{
+  return b ? a : a / b;
+}
+
+static unsigned char
+func2 (unsigned char a, int b)
+{
+  return b ? a : b;
+}
+
+int i;
+
+void
+func3 (const int arg)
+{
+  for (i = 0; i != 10; i = foo ())
+    {
+      if (!arg)
+       {
+         int j;
+         for (j = 0; j < 5; j += 1)
+           {
+             int *ptr;
+             *ptr = func2 (func1 (arg, *ptr), foo (arg));
+           }
+       }
+    }
+}