Stop find_split_point from clobbering constant pool entries

Richard Sandiford rsandifo@redhat.com
Mon Nov 3 18:27:00 GMT 2003


Richard Henderson <rth@redhat.com> writes:
> On Sat, Nov 01, 2003 at 11:33:16AM +0000, Richard Sandiford wrote:
> >       /* A MEM is allowed to be shared if its address is constant.
> > 
> > 	 We used to allow sharing of MEMs which referenced
> > 	 virtual_stack_vars_rtx or virtual_incoming_args_rtx, but
> > 	 that can lose.  instantiate_virtual_regs will not unshare
> > 	 the MEMs, and combine may change the structure of the address
> > 	 because it looks safe and profitable in one context, but
> > 	 in some other context it creates unrecognizable RTL.  */
> >       if (CONSTANT_ADDRESS_P (XEXP (x, 0)))
> 
> Personally I think this is bogus.  IIRC this can cause problems in
> rare cases for amd64 where 
> 
> 	(set (reg) (mem (64-bit-constant))
> 
> is valid for reg=%rax, but for a different destination register we
> have to reload the constant.  Which causes reload to run into shared
> rtl problems.
> 
> IMO we should just remove this special case.

OK, how's this?  It removes the code above and makes force_const_mem
return an unshared MEM.  Tested on the same mips targets as before.

Richard


	* emit-rtl.c (copy_rtx_if_shared): Don't allow MEMs with constant
	addresses to be shared.
	(force_const_mem): Return a copy of the pool entry.

Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.351
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.351 emit-rtl.c
--- emit-rtl.c	18 Oct 2003 18:45:15 -0000	1.351
+++ emit-rtl.c	2 Nov 2003 10:57:43 -0000
@@ -2690,20 +2690,6 @@ copy_rtx_if_shared (rtx orig)
       /* The chain of insns is not being copied.  */
       return x;
 
-    case MEM:
-      /* A MEM is allowed to be shared if its address is constant.
-
-	 We used to allow sharing of MEMs which referenced
-	 virtual_stack_vars_rtx or virtual_incoming_args_rtx, but
-	 that can lose.  instantiate_virtual_regs will not unshare
-	 the MEMs, and combine may change the structure of the address
-	 because it looks safe and profitable in one context, but
-	 in some other context it creates unrecognizable RTL.  */
-      if (CONSTANT_ADDRESS_P (XEXP (x, 0)))
-	return x;
-
-      break;
-
     default:
       break;
     }
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.395
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.395 varasm.c
--- varasm.c	25 Oct 2003 02:03:34 -0000	1.395
+++ varasm.c	2 Nov 2003 10:57:45 -0000
@@ -2915,7 +2915,7 @@ force_const_mem (enum machine_mode mode,
   hash = const_hash_rtx (mode, x);
   for (desc = const_rtx_hash_table[hash]; desc; desc = desc->next)
     if (compare_constant_rtx (mode, x, desc))
-      return desc->rtl;
+      return copy_rtx (desc->rtl);
 
   /* No constant equal to X is known to have been output.
      Make a constant descriptor to enter X in the hash table
@@ -2983,7 +2983,7 @@ force_const_mem (enum machine_mode mode,
   SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
   current_function_uses_const_pool = 1;
 
-  return def;
+  return copy_rtx (def);
 }
 
 /* Given a SYMBOL_REF with CONSTANT_POOL_ADDRESS_P true, return a pointer to



More information about the Gcc-patches mailing list