This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] ia64 ICE fix


Hi!

The following testcase ICEs for me on ia64.
It is try_replace_reg some unrelated pseudo during GCSE into (const_int 32)
and while doing validate_replace_rtx_1 on
(insn 111 187 113 (set (reg:DI 386)
        (plus:DI (reg:DI 343)
            (const_int 32 [0x20]))) 67 {adddi3} (nil)
    (expr_list:REG_EQUAL (const:DI (plus:DI (symbol_ref:DI ("a"))
                (const_int 32 [0x20])))
        (nil)))
it changes (const:DI (plus:DI (symbol_ref:DI ("a")) (const_int 32 [0x20])))
into (const:DI (const:DI (plus:DI (symbol_ref:DI ("a")) (const_int 32 [0x20]))))
which later on ends up in the rtl stream and causes an instruction to be
unrecognized. This is because validate_replace_rtx_1 for CONST just calls
validate_replace_rtx_1 on its argument, but validate_replace_rtx_1 on PLUS
sees
      /* If we have a PLUS whose second operand is now a CONST_INT, use
         plus_constant to try to simplify it.  */
      if (GET_CODE (XEXP (x, 1)) == CONST_INT && XEXP (x, 1) == to)
        validate_change (object, loc, plus_constant (XEXP (x, 0), INTVAL (to)),
                         1);
as satisfied (the only problem is that XEXP (x, 1) was equal to to even
before validate_replace_rtx_1's on PLUS arguments) and plus_constant adds a
new CONST (cannot see it is already inside of an CONST).
To solve this, either validate_replace_rtx_1 would have to remember for
PLUS/MINUS what XEXP (x, 1) was before replacing and if it did not change,
should avoid changing anything, or, as implemented below, just check one
level up and remove one of the two CONSTs if that happens. This seems safer.
Ok to commit?

2001-04-26  Jakub Jelinek  <jakub@redhat.com>

	* recog.c (validate_replace_rtx_1): Avoid creating (const (const ()).

	* gcc.c-torture/compile/20010426-1.c: New test.

--- gcc/recog.c.jj	Tue Apr 24 09:59:31 2001
+++ gcc/recog.c	Thu Apr 26 11:59:32 2001
@@ -679,7 +679,14 @@ validate_replace_rtx_1 (loc, from, to, o
 	}
 
       break;
-      
+
+    case CONST:
+      /* Avoid creating (const (const ()).  */
+      validate_replace_rtx_1 (&XEXP (x, 0), from, to, object);
+      if (GET_CODE (XEXP (x, 0)) == CONST)
+	validate_change (object, &XEXP (x, 0), XEXP (XEXP (x, 0), 0), 1);
+      return;
+
     default:
       break;
     }
--- gcc/testsuite/gcc.c-torture/compile/20010426-1.c.jj	Sat Mar 24 04:35:12 2001
+++ gcc/testsuite/gcc.c-torture/compile/20010426-1.c	Thu Apr 26 12:01:43 2001
@@ -0,0 +1,19 @@
+struct { char *m; long n; } a[20];
+int b = 20, c;
+void bar(void) __attribute__((__noreturn__));
+
+int
+foo(int x)
+{
+  int i;
+
+  for (i = 0; i < x; i++)
+    {
+      a[0].m = "a"; a[0].n = 10; c=1;
+      a[c].m = "b"; a[c].n = 32; c++;
+      if (c >= b) bar ();
+      a[c].m = "c"; a[c].n = 80; c++;
+      if (c >= b) bar ();
+    }
+  return 0;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]