This is the mail archive of the gcc@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]

Re: [m68k] asm regression with 3.3/3.4/3.5


Richard Henderson <rth@redhat.com> writes:

[ regarding using hard register variables as an asm input ]

> On Wed, May 12, 2004 at 02:35:54PM -0400, Ian Lance Taylor wrote:
> > And it doesn't appear to work.
> 
> It *does* work on other systems.  We have tests for it in the
> testsuite, and glibc would fail to work if it didn't.

Interesting.  I think this should be documented.  I looked to see how
this is implemented in the source code, but I don't see it.

The appended untested patch fixes the problem at hand.  When gcc finds
a register which is invariant and is used once in a loop, it tries to
replace it with the invariant value.  This patch tells gcc not to do
that if the register is a hard register which is used in an asm
statement.

But in the absence of a general principle it's hard to know why this
is required.

Here is a test case showing the same problem on the Alpha:

extern void bar ();
void
foo (long a)
{
  for (;;)
    {
      register long b __asm ("$11") = a;

      __asm volatile ("callsys %0" : : "r" (b));
      bar ();
    }
}

Ian

Index: loop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop.c,v
retrieving revision 1.497
diff -u -p -r1.497 loop.c
--- loop.c	18 Mar 2004 16:42:31 -0000	1.497
+++ loop.c	13 May 2004 04:57:42 -0000
@@ -925,6 +925,10 @@ scan_loop (struct loop *loop, int flags)
 			  == INSN_UID (regs->array[regno].single_usage))
 		      && regs->array[regno].set_in_loop == 1
 		      && GET_CODE (SET_SRC (set)) != ASM_OPERANDS
+		      && (regno >= FIRST_PSEUDO_REGISTER
+			  || asm_noperands (PATTERN (regs->array[regno]
+						     .single_usage))
+			  < 0)
 		      && ! side_effects_p (SET_SRC (set))
 		      && ! find_reg_note (p, REG_RETVAL, NULL_RTX)
 		      && (! SMALL_REGISTER_CLASSES


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