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]

Re: MIPS gcc `leasi' pattern bug [PATCH]


On Tue, Jul 18, 2000 at 03:10:07PM -0700, Chris G. Demetriou wrote:
> about three weeks ago, i wrote about a bug in the mips.md 'leasi'
> insn, in the message:
> 
> 	http://gcc.gnu.org/ml/gcc-patches/2000-06/msg00893.html
> 
> (There was one reply: http://gcc.gnu.org/ml/gcc-patches/2000-06/msg00895.html 
> which seemed to confirm that it was an issue with 'leasi' rather than
> gas.)
> 
> I did additional testing with my patch applied, and found that I could
> kill the compiler when it tried really hard to use the leasi pattern
> (which I had constrained it to not use.
> 
> An updated patch, which fixes that problem, is below.  The test case
> from my original message still applies.

Out of curiousity, is this an elf target?  If so, are you configuring
gcc --with-gnu-as and --with-gnu-ld?  I ask this because you mentioned
using gas, but leasi won't be used if you are using gas and gnu ld
when generating elf, because MASK_SPLIT_ADDR will be set in the
target_flags, and for your test case we'll generate something like:

li	$4,-2147483648
addu	$2,$2,$4	

instead of 

la 	$2,-2147483648($2)

However, without MASK_SPLIT_ADDR, leasi is probably getting picked up
because cse will fold:

(set (reg a) (big const_int))

(set (reg b) (plus (reg c) (reg a)))

into 

(set (reg b) (plus (reg c) (big const_int)))

since GO_IF_LEGITIMATE_ADDRESS will allow this, although it isn't
really a valid addressing mode, in the hope that the assembler will
generate better code.

I think the proper fix is not to add another leasi pattern, but rather
to fix GO_IF_LEGITIMATE_ADDRESS for this case.  A patch is appended to
do this.  It fixes your test case; the regression tests are still
running on mips64-elf with -mno-split-addresses.

				-Clint


Wed Jul 19 00:54:53 2000  Clinton Popetz  <cpopetz@cygnus.com>

	* (mips_legitimate_address_p): Don't allow register+offset 
	if the offset is large and negative, and we are compiling 
	for 64 bit registers.


Index: mips.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/mips/mips.c,v
retrieving revision 1.93
diff -c -2 -p -r1.93 mips.c
*** mips.c	2000/07/17 13:27:54	1.93
--- mips.c	2000/07/19 05:49:58
*************** mips_legitimate_address_p (mode, xinsn, 
*** 1330,1333 ****
--- 1330,1337 ----
  		  || code1 != CONST					
  		  || GET_CODE (XEXP (xplus1, 0)) != MINUS)		
+ 	      /* When assembling for machines with 64 bit registers, 
+ 	         the assembler will not sign-extend the constant "foo"
+ 		 in "la x, foo(x)" */
+ 	      && (!TARGET_64BIT || (INTVAL (xplus1) > 0))
  	      && !TARGET_MIPS16)					
  	    return 1;							

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