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: Reload Problem in delete_output_reload


Erwin Unruh wrote:

> I have a problem with delete_output_reload. It sometimes deletes
> instructions
> which are needed. Here an analysis of a recent case (In a private
> version of
> the S390 port). The original S390 shows almost the same reloads, but
> chooses
> different registers.

What GCC version your compiler based on?

> Reloads for insn # 1598
> Reload 0: reload_in (SI) =3D (const_int 4080 [0xff0])
> 	ADDR_REGS, RELOAD_FOR_OUTPUT_ADDRESS (opnum =3D 0)
> 	reload_in_reg: (const_int 4080 [0xff0])
> 	reload_reg_rtx: (reg:SI 2 2)
> Reload 1: reload_in (SI) =3D (const_int 4080 [0xff0])
> 	ADDR_REGS, RELOAD_FOR_OTHER_ADDRESS (opnum =3D 0)
> 	reload_in_reg: (const_int 4080 [0xff0])
> 	reload_reg_rtx: (reg:SI 2 2)
> Reload 2: reload_in (SI) =3D (const_int 4080 [0xff0])
> 	ADDR_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum =3D 2)
> 	reload_in_reg: (const_int 4080 [0xff0])
> 	reload_reg_rtx: (reg:SI 2 2)
> Reload 3: reload_in (DI) =3D (mem/c:DI (plus:SI (plus:SI (reg/f:SI 15 15)
>                                                             (const_int
> 4080 [0xff0]))
>                                                         (const_int 3144
> [0xc48])) [0 S8 A8])
> 	reload_out (DI) =3D (mem/c:DI (plus:SI (plus:SI (reg/f:SI 15 15)
>                                                             (const_int
> 4080 [0xff0]))
>                                                         (const_int 3136
> [0xc40])) [0 S8 A8])
> 	GENERAL_REGS, RELOAD_OTHER (opnum =3D 0), can't combine
> 	reload_in_reg: (reg:DI 1391)
> 	reload_out_reg: (reg:DI 1393)
> 	reload_reg_rtx: (reg:DI 0 0)
> Reload 4: ADDR_REGS, RELOAD_FOR_INPUT_ADDRESS (opnum =3D 2), can't
> combine, secondary_reload_p
> 	reload_reg_rtx: (reg:SI 3 3)
> Reload 5: reload_in (SI) =3D (plus:SI (plus:SI (reg/f:SI 15 15)
>                                                         (const_int 4080
> [0xff0]))
>                                                     (const_int 3136
> [0xc40]))
> 	ADDR_REGS, RELOAD_FOR_INPUT (opnum =3D 2), inc by 8
> 	reload_in_reg: (plus:SI (plus:SI (reg/f:SI 15 15)
>                                                         (const_int 4080
> [0xff0]))
>                                                     (const_int 3136
> [0xc40]))
> 	reload_reg_rtx: (reg:SI 2 2)
> 	secondary_in_reload =3D 4
> 	secondary_in_icode =3D reload_insi
> 
> These reloads are ok. In do_output_reload it is noted that both
> insn_1597.Reload_2 and insn_1598.Reload_3 write to the same stack slot.
> So the compiler decides to remove the first reload and use register
> (reg:DI 2) > directly. In this analysis it misses the fact that (reg:SI 2)
> is used for input reloads of insn 1598.

This should actually be caught by the free_for_value_p check in
choose_reload_regs.  You cannot inherit a value for a RELOAD_OTHER
reload (3) in a register that is already in use for a RELOAD_FOR_INPUT_
ADDRESS reload (2).

Could you try to find out why this doesn't work correctly?

> One critical point is the timing on the variables reg_reloaded_valid and
> spill_reg_store.
> Within the function emit_reload_insns they are first checked (within
> do_output_reload) and later updated (after the reload instructions are
> written).
> So they reflect the state before the "reload sequence". Not all usages
> reflect
> this semantics. Especially the check within delete_output_reload is not
> correct.

I'm not sure how delete_output_reload comes into play here.  The decision
to inherit was already made long ago, in choose_reload_regs, and that is
already incorrect.  Even if the output reload for insn 1597 were not 
deleted at this point, the code would still be incorrect.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com


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