(i386-linux x sh-elf) More weak stack addressing

Joern Rennecke amylaar@cygnus.co.uk
Tue Jul 18 07:56:00 GMT 2000


In article <200006290530.WAA01339@netcom.com> you wrote:
: version: CVS
:    host: i386-linux
:  target: sh-elf
: options: -O2 -m4-single-only -ml -S -g

: More weak stack addressing samples from stress-1.14.tar.gz at:

: ftp://shell14.ba.best.com/pub.t/tm2/stress-1.14.tar.gz

: GCC creates multiple pointers to the same stack slot and unnecessarily
: eats up hard registers:

: 6363:./vtkTriangleStrip.ii ****       {

I suppose I have a slightly different code base, since I get slightly
different code.  Yet, the basic pattern seems to be the same:  Inheritance
is prevented because the register is immediately resued for something else.
The first pattern looks like this:

        mov     #124,r3
        mov     #124,r7
        mov.w   .L88,r2
        add     r14,r3
        mov.l   .L89,r1
        add     r14,r7
        mov.l   @(52,r3),r3

This insn is being reloaded:
(gdb) call debug_rtx(chain->insn)
(insn 4156 1297 1300 (set (mem:SI (plus:SI (plus:SI (reg:SI 14 r14)
                    (const_int 188 [0xbc]))
                (const_int 28 [0x1c])) 25)
        (mem:SI (plus:SI (plus:SI (reg:SI 14 r14)
                    (const_int 124 [0x7c]))
                (const_int 52 [0x34])) 15)) 83 {movsi_ie} (nil)
    (nil))

And we get these reloads:
(gdb) call debug_reload()
Reload 0: reload_in (SI) = (plus:SI (reg:SI 14 r14)
                                                    (const_int 188 [0xbc]))
        GENERAL_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 0)
        reload_in_reg: (plus:SI (reg:SI 14 r14)
                                                    (const_int 188 [0xbc]))
        reload_reg_rtx: (reg:SI 2 r2)
Reload 1: reload_in (SI) = (plus:SI (reg:SI 14 r14)
                                                    (const_int 124 [0x7c]))
        GENERAL_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum = 1)
        reload_in_reg: (plus:SI (reg:SI 14 r14)
                                                    (const_int 124 [0x7c]))
        reload_reg_rtx: (reg:SI 3 r3)
Reload 2: reload_out (SI) = (mem:SI (plus:SI (plus:SI (reg:SI 14 r14)
                                                            (const_int 188 [0xbc]))
                                                        (const_int 28 [0x1c])) 25)
        NO_REGS, RELOAD_FOR_OUTPUT (opnum = 0), optional
        reload_out_reg: (reg:SI 315)
Reload 3: reload_in (SI) = (mem:SI (plus:SI (plus:SI (reg:SI 14 r14)
                                                            (const_int 124 [0x7c]))
                                                        (const_int 52 [0x34])) 15)
        GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 1), can't combine
        reload_in_reg: (reg/v:SI 70)
        reload_reg_rtx: (reg:SI 3 r3)

This re-using of reload registers is actually intentional.
allocate_reload_reg prefers registers that have been used previously.
If I disable this logic, I get a .s file that is about 1% shorter.

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.216
diff -p -r1.216 reload1.c
*** reload1.c	2000/06/06 02:40:14	1.216
--- reload1.c	2000/07/18 14:53:09
*************** allocate_reload_reg (chain, r, last_relo
*** 5018,5025 ****
  		 don't share regs used for inherited reloads; they are
  		 the ones we want to preserve.  */
  	      && (pass
! 		  || (TEST_HARD_REG_BIT (reload_reg_used_at_all,
! 					 regnum)
  		      && ! TEST_HARD_REG_BIT (reload_reg_used_for_inherit,
  					      regnum))))
  	    {
--- 5018,5025 ----
  		 don't share regs used for inherited reloads; they are
  		 the ones we want to preserve.  */
  	      && (pass
! 		  || ((1 || TEST_HARD_REG_BIT (reload_reg_used_at_all,
! 					 regnum))
  		      && ! TEST_HARD_REG_BIT (reload_reg_used_for_inherit,
  					      regnum))))
  	    {

Should we have a target macro to disable this logic?  Or maybe we should
identify reloads that are particularily suitable for inheritance,
(i.e. constants, addresses on the stack, and pseudos), and add them to
reload_reg_used_for_inherit?


More information about the Gcc-bugs mailing list