gcc/
authoruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 25 Jan 2003 23:57:30 +0000 (23:57 +0000)
committeruweigand <uweigand@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 25 Jan 2003 23:57:30 +0000 (23:57 +0000)
        * reload.c (maybe_memory_address_p): New function.
        (find_reloads_address): Use it instead of memory_address_p.

gcc/testsuite/
* gcc.dg/20030123-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@61805 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/reload.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20030123-1.c [new file with mode: 0644]

index dc05aee..a308d0f 100644 (file)
@@ -1,3 +1,8 @@
+2003-01-25  Ulrich Weigand  <uweigand@de.ibm.com>
+
+        * reload.c (maybe_memory_address_p): New function.
+        (find_reloads_address): Use it instead of memory_address_p.
+
 2003-01-25  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * final.c (shorten_branches): Align the address of code label
index 866cd25..a16012c 100644 (file)
@@ -260,6 +260,7 @@ static int alternative_allows_memconst PARAMS ((const char *, int));
 static rtx find_reloads_toplev PARAMS ((rtx, int, enum reload_type, int,
                                         int, rtx, int *));
 static rtx make_memloc         PARAMS ((rtx, int));
+static int maybe_memory_address_p PARAMS ((enum machine_mode, rtx, rtx *));
 static int find_reloads_address        PARAMS ((enum machine_mode, rtx *, rtx, rtx *,
                                       int, enum reload_type, int, rtx));
 static rtx subst_reg_equivs    PARAMS ((rtx, rtx));
@@ -4587,6 +4588,27 @@ make_memloc (ad, regno)
   return tem;
 }
 
+/* Returns true if AD could be turned into a valid memory reference
+   to mode MODE by reloading the part pointed to by PART into a 
+   register.  */
+
+static int
+maybe_memory_address_p (mode, ad, part)
+     enum machine_mode mode;
+     rtx ad;
+     rtx *part;
+{
+  int retv;
+  rtx tem = *part;
+  rtx reg = gen_rtx_REG (GET_MODE (tem), max_reg_num ());
+
+  *part = reg;
+  retv = memory_address_p (mode, ad);
+  *part = tem;
+
+  return retv;
+}
+
 /* Record all reloads needed for handling memory address AD
    which appears in *LOC in a memory reference to mode MODE
    which itself is found in location  *MEMREFLOC.
@@ -4886,7 +4908,7 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
               || XEXP (XEXP (ad, 0), 0) == arg_pointer_rtx
 #endif
               || XEXP (XEXP (ad, 0), 0) == stack_pointer_rtx)
-          && ! memory_address_p (mode, ad))
+          && ! maybe_memory_address_p (mode, ad, &XEXP (XEXP (ad, 0), 1)))
     {
       *loc = ad = gen_rtx_PLUS (GET_MODE (ad),
                                plus_constant (XEXP (XEXP (ad, 0), 0),
@@ -4911,7 +4933,7 @@ find_reloads_address (mode, memrefloc, ad, loc, opnum, type, ind_levels, insn)
               || XEXP (XEXP (ad, 0), 1) == arg_pointer_rtx
 #endif
               || XEXP (XEXP (ad, 0), 1) == stack_pointer_rtx)
-          && ! memory_address_p (mode, ad))
+          && ! maybe_memory_address_p (mode, ad, &XEXP (XEXP (ad, 0), 0)))
     {
       *loc = ad = gen_rtx_PLUS (GET_MODE (ad),
                                XEXP (XEXP (ad, 0), 0),
index d26eb16..0f62daf 100644 (file)
@@ -1,3 +1,7 @@
+2003-01-25  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * gcc.dg/20030123-1.c: New test.
+
 Sat Jan 25 21:06:49 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        PR opt/8492
diff --git a/gcc/testsuite/gcc.dg/20030123-1.c b/gcc/testsuite/gcc.dg/20030123-1.c
new file mode 100644 (file)
index 0000000..1f58588
--- /dev/null
@@ -0,0 +1,17 @@
+/* This used to ICE due to a reload bug on s390*.  */
+
+/* { dg-do compile { target s390*-*-* } } */
+/* { dg-options "-O2" } */
+
+void func (char *p);
+
+void test (void)
+{
+   char *p = alloca (4096);
+   long idx;
+
+   asm ("" : "=r" (idx) : : "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
+
+   func (p + idx + 1);
+}
+