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][RFC]: Don't excessively simplify operands in calls.c


Hi,

While testing TLS support for m68k/ColdFire, I've came across the following hunk in calls.c (emit_library_call_value_1):

      /* Make sure it is a reasonable operand for a move or push insn.  */
      if (!REG_P (addr) && !MEM_P (addr)
	  && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
	addr = force_operand (addr, NULL_RTX);

This force_operand can cause very ugly code generated for TLS accesses on targets with little address registers.

The check above does not consider a common <symbol>@TLSGD(<pic_reg>) TLS reference:
(plus (<base_register>)
(const (unspec <tls_symbol>)))
to be a good enough operand for a push, so it forces it into a register. The bad thing about this is that combiner, due to copy propagation and other optimizations, sometimes can not later fix this. As a consequence, additional register may be allocated resulting in a spill.


This code was added long time ago (Kenner-93) and I'm wondering if the new RA can now deal with all the cases without this check. Comments?

The attached patch removing the checks was tested on x86_64-linux-gnu without regressions. OK for trunk?

--
Maxim
CodeSourcery
2009-05-26  Maxim Kuvyrkov  <maxim@codesourcery.com>

	* calls.c (emit_library_call_value_1): Don't force_operand for move
	and push insns.
Index: gcc-mainline-2/gcc/calls.c
===================================================================
--- gcc-mainline-2/gcc/calls.c	(revision 147467)
+++ gcc-mainline-2/gcc/calls.c	(working copy)
@@ -3412,11 +3412,6 @@ emit_library_call_value_1 (int retval, r
 
       nargs++;
 
-      /* Make sure it is a reasonable operand for a move or push insn.  */
-      if (!REG_P (addr) && !MEM_P (addr)
-	  && ! (CONSTANT_P (addr) && LEGITIMATE_CONSTANT_P (addr)))
-	addr = force_operand (addr, NULL_RTX);
-
       argvec[count].value = addr;
       argvec[count].mode = Pmode;
       argvec[count].partial = 0;
@@ -3452,11 +3447,6 @@ emit_library_call_value_1 (int retval, r
       gcc_assert (mode != BLKmode
 		  && (GET_MODE (val) == mode || GET_MODE (val) == VOIDmode));
 
-      /* Make sure it is a reasonable operand for a move or push insn.  */
-      if (!REG_P (val) && !MEM_P (val)
-	  && ! (CONSTANT_P (val) && LEGITIMATE_CONSTANT_P (val)))
-	val = force_operand (val, NULL_RTX);
-
       if (pass_by_reference (&args_so_far, mode, NULL_TREE, 1))
 	{
 	  rtx slot;

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