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]
Other format: [Raw text]

[PATCH] Fix s390x PR target/14533


Hi!

This testcase causes ICE on gcc-3_3-branch, but mainline has the same code,
just uses UNSPEC_* constants instead of hardcoding values.

Strength reduction creates (via convert_modes/adjust_address_1)
(const:DI (plus:DI (unspec:DI [
                (symbol_ref:DI ("b"))
            ] UNSPEC_GOT)
        (const_int 4 [0x4])))
and calls legitimize_address on it.  legitimize_address should try to
legitimize it if possible and if not possible just return the original,
certainly not abort on something the compiler can validly throw at it.

Ok for mainline and gcc 3.3 branch if testing succeeds?

2004-03-11  Jakub Jelinek  <jakub@redhat.com>

	PR target/14533
	* config/s390/s390.c (legitimize_pic_address): Don't abort on UNSPEC
	other than UNSPEC_GOTOFF.

	* gcc.dg/20040311-2.c: New test.

--- gcc/config/s390/s390.c.jj	2004-03-09 16:09:07.000000000 +0100
+++ gcc/config/s390/s390.c	2004-03-11 19:25:18.357694816 +0100
@@ -2545,7 +2545,7 @@ legitimize_pic_address (rtx orig, rtx re
                   addr = gen_rtx_PLUS (Pmode, addr, op1);
                   addr = gen_rtx_CONST (Pmode, addr);
                   addr = force_const_mem (Pmode, addr);
-	  emit_move_insn (temp, addr);
+		  emit_move_insn (temp, addr);
 
                   new = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, temp);
                   if (reg != 0)
@@ -2560,12 +2560,11 @@ legitimize_pic_address (rtx orig, rtx re
              that was pulled out of the literal pool.  Force it back in.  */
 
 	  else if (GET_CODE (op0) == UNSPEC
-	           && GET_CODE (op1) == CONST_INT)
+	           && GET_CODE (op1) == CONST_INT
+	           && XINT (op0, 1) == UNSPEC_GOTOFF)
             {
 	      if (XVECLEN (op0, 0) != 1)
                 abort ();
-              if (XINT (op0, 1) != UNSPEC_GOTOFF)
-                abort ();
 
               new = force_const_mem (Pmode, orig);
             }
--- gcc/testsuite/gcc.dg/20040311-2.c.jj	2004-01-21 17:12:41.000000000 +0100
+++ gcc/testsuite/gcc.dg/20040311-2.c	2004-03-11 18:16:15.024866105 +0100
@@ -0,0 +1,36 @@
+/* PR target/14533 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fpic" } */
+
+void bar (char *, int);
+
+extern char b[];
+extern int d, e;
+struct S
+{
+  struct S *m;
+  int n;
+} **g;
+
+void
+foo (int x, char *y)
+{
+  struct S *h;
+  int k = 1, l;
+
+again:
+  for (h = *g; h != (struct S *) g; h = h->m)
+    {
+      if (k == 0 && h->n & 0x100000);
+      l = y - b;
+      if (e)
+        bar (b, l);
+      if (d)
+        bar (b, l);
+    }
+  if (k)
+    {
+      k = 0;
+      goto again;
+    }
+}

	Jakub


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