reload1: detect chained reloads

DJ Delorie dj@redhat.com
Thu Mar 2 19:30:00 GMT 2006


> Incidentally, when I ran into this type of issue myself, for the
> MIPS16, I invented RELOAD_FOR_INPADDR_ADDRESS and
> RELOAD_FOR_OUTADDR_ADDRESS to permit more separation in
> reload_conflict.  So, why do you get RELOAD_FOR_OPERAND_ADDRESS for
> both of your reloads?  Why isn't one of them
> RELOAD_FOR_INPADDR_ADDRESS or at least RELOAD_FOR_OPADDR_ADDR?  No
> doubt there is some horrible answer.

Ok, I added some debug printfs to track down what the reloads were
doing.  The reloads are initially pushed as follows (note that compare
can take two (mem)s but $r0..$r3 can't be used as addresses, and "p" is
on the stack but beyond the $fb's (frame base) addressing range):

find_reloads
(insn 7573 2611 7574 160 regex.i:2923 (set (reg:CC 10 flg)
        (compare (mem:QI (reg/f:HI 0 r0 [1935]) [0 S1 A8])
            (mem:QI (reg/v/f:HI 1747 [ p ]) [0 S1 A8]))) 47 {cmpqi} (nil)
    (expr_list:REG_DEAD (reg/f:HI 0 r0 [1935])
        (nil)))
push reload 0 type RELOAD_FOR_INPUT_ADDRESS	<- to copy $r0 to an address register
push reload 1 type RELOAD_FOR_INPADDR_ADDRESS	<- to copy $fb to an address register, to reach p
push reload 2 type RELOAD_FOR_INPUT_ADDRESS	<- to copy "p" to an address register
push reload 3 type RELOAD_FOR_INPUT		<- to copy the first mem to a general register, optional
push reload 4 type RELOAD_FOR_INPUT		<- to copy the second mem to a general register, optional

but reload.c changes them to RELOAD_FOR_OPERAND_ADDRESS here (plus or
minus a few lines):

4235: here, reload 0
4235: here, reload 2
4328: here, reload 1

Both these changes have big comment blocks talking about then:

  /* Scan all the reloads and update their type.
     If a reload is for the address of an operand and we didn't reload
     that operand, change the type.  Similarly, change the operand number
     of a reload when two operands match.  If a reload is optional, treat it
     as though the operand isn't reloaded.

	. . . */

  /* Scan all the reloads, and check for RELOAD_FOR_OPERAND_ADDRESS reloads.
     If we have more than one, then convert all RELOAD_FOR_OPADDR_ADDR
     reloads to RELOAD_FOR_OPERAND_ADDRESS reloads.

	. . . */

We end up with this:

Spilling for insn 7573.
Using reg 4 for reload 0
Using reg 5 for reload 1		<- reg 4 could have been reused here.
reload failure for reload 2

Reloads for insn # 7573
Reload 0: reload_in (HI) = (reg/f:HI 0 r0 [1935])
	A_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 0)
	reload_in_reg: (reg/f:HI 0 r0 [1935])
Reload 1: reload_in (HI) = (plus:HI (reg/f:HI 7 fb)
                                                    (const_int 0 [0x0]))
	A_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 1)
	reload_in_reg: (plus:HI (reg/f:HI 7 fb)
                                                    (const_int 0 [0x0]))
Reload 2: reload_in (HI) = (mem/c:HI (plus:HI (plus:HI (reg/f:HI 7 fb)
                                                            (const_int 0 [0x0]))
                                                        (const_int -158 [0xffffffffffffff62])) [242 p+0 S2 A8])
	A_REGS, RELOAD_FOR_OPERAND_ADDRESS (opnum = 1), can't combine
	reload_in_reg: (reg/v/f:HI 1747 [ p ])
Reload 3: reload_in (QI) = (mem:QI (reg/f:HI 0 r0 [1935]) [0 S1 A8])
	HL_REGS, RELOAD_FOR_INPUT (opnum = 0), optional
	reload_in_reg: (mem:QI (reg/f:HI 0 r0 [1935]) [0 S1 A8])
	reload_reg_rtx: (reg:QI 0 r0)
Reload 4: reload_in (QI) = (mem:QI (reg/v/f:HI 1747 [ p ]) [0 S1 A8])
	HL_REGS, RELOAD_FOR_INPUT (opnum = 1), optional
	reload_in_reg: (mem:QI (reg/v/f:HI 1747 [ p ]) [0 S1 A8])



More information about the Gcc-patches mailing list