public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* CAN_ELIMINATE question
@ 2006-02-13 15:43 Denis Chertykov
  2006-02-13 17:48 ` Eric Christopher
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Chertykov @ 2006-02-13 15:43 UTC (permalink / raw)
  To: gcc

Hi All.

While I have debugging AVR target bug I found that something wrong in
port code or in reload.

Is it right to use of get_frame_size() inside CAN_ELIMINATE macro valid ?
If yes then reload have a bug.
If no then AVR and probably MIPS ports have invalid definitions of
CAN_ELIMINATE.

Denis.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-13 15:43 CAN_ELIMINATE question Denis Chertykov
@ 2006-02-13 17:48 ` Eric Christopher
  2006-02-13 19:07   ` Denis Chertykov
  0 siblings, 1 reply; 8+ messages in thread
From: Eric Christopher @ 2006-02-13 17:48 UTC (permalink / raw)
  To: Denis Chertykov; +Cc: gcc


On Feb 13, 2006, at 7:43 AM, Denis Chertykov wrote:

> Hi All.
>
> While I have debugging AVR target bug I found that something wrong in
> port code or in reload.
>
> Is it right to use of get_frame_size() inside CAN_ELIMINATE macro  
> valid ?
> If yes then reload have a bug.
> If no then AVR and probably MIPS ports have invalid definitions of
> CAN_ELIMINATE.

Can you point to where you think reload is getting this wrong?

-eric

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-13 17:48 ` Eric Christopher
@ 2006-02-13 19:07   ` Denis Chertykov
  2006-02-15 23:48     ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Chertykov @ 2006-02-13 19:07 UTC (permalink / raw)
  To: Eric Christopher; +Cc: Denis Chertykov, gcc

Eric Christopher <echristo@apple.com> writes:

> On Feb 13, 2006, at 7:43 AM, Denis Chertykov wrote:
> 
> > Hi All.
> >
> > While I have debugging AVR target bug I found that something wrong in
> > port code or in reload.
> >
> > Is it right to use of get_frame_size() inside CAN_ELIMINATE macro
> > valid ?
> > If yes then reload have a bug.
> > If no then AVR and probably MIPS ports have invalid definitions of
> > CAN_ELIMINATE.
> 
> Can you point to where you think reload is getting this wrong?

Yes.

Code fragment from reload1.c: reload()
----------------------------------------------------
      if (caller_save_needed)
	setup_save_areas ();

      /* If we allocated another stack slot, redo elimination bookkeeping.  */
      if (starting_frame_size != get_frame_size ())
	continue;

      if (caller_save_needed)
	{
	  save_call_clobbered_regs ();
	  /* That might have allocated new insn_chain structures.  */
	  reload_firstobj = obstack_alloc (&reload_obstack, 0);
	}

      calculate_needs_all_insns (global);
----------------------------------------------------

Call to setup_save_areas () can change frame size but only offsets on
eliminable registers will be changed before call to calculate_needs_all_insns.
calculate_needs_all_insns will calculate wrong needs for elimination.

Example for AVR:

avr target can eliminate fp -> sp only if get_frame_size () == 0.

Before call to setup_save_areas() frame size was 0 (CAN_ELIMINATE (FP,SP) != 0)

setup_save_areas() increase frame size.
set_initial_elim_offsets() correct offsets but can_eliminate isn't changed.

save_call_clobbered_regs () emit save insn
(insn 659 161 162 16 (set (mem/c:HI (plus:HI (reg/f:HI 28 r28) # it's FP
                (const_int 1 [0x1])) [29 S2 A8])
        (reg:HI 24 r24)) 12 {*movhi} (nil)
    (nil))

calculate_needs_all_insns() try to eliminate (reg/f:HI 28 r28) to SP.
It's wrong because get_frame_size () != 0 and CAN_ELIMINATE (FP,SP) == 0




I think that better to call update_eliminables() somewhere after
setup_save_areas()


Denis.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-13 19:07   ` Denis Chertykov
@ 2006-02-15 23:48     ` Ian Lance Taylor
  2006-02-16 17:28       ` Denis Chertykov
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2006-02-15 23:48 UTC (permalink / raw)
  To: Denis Chertykov; +Cc: Eric Christopher, gcc

Denis Chertykov <denisc@overta.ru> writes:

> Code fragment from reload1.c: reload()
> ----------------------------------------------------
>       if (caller_save_needed)
> 	setup_save_areas ();
> 
>       /* If we allocated another stack slot, redo elimination bookkeeping.  */
>       if (starting_frame_size != get_frame_size ())
> 	continue;
> 
>       if (caller_save_needed)
> 	{
> 	  save_call_clobbered_regs ();
> 	  /* That might have allocated new insn_chain structures.  */
> 	  reload_firstobj = obstack_alloc (&reload_obstack, 0);
> 	}
> 
>       calculate_needs_all_insns (global);
> ----------------------------------------------------
> 
> Call to setup_save_areas () can change frame size but only offsets on
> eliminable registers will be changed before call to calculate_needs_all_insns.
> calculate_needs_all_insns will calculate wrong needs for elimination.
> 
> Example for AVR:
> 
> avr target can eliminate fp -> sp only if get_frame_size () == 0.
> 
> Before call to setup_save_areas() frame size was 0 (CAN_ELIMINATE (FP,SP) != 0)
> 
> setup_save_areas() increase frame size.
> set_initial_elim_offsets() correct offsets but can_eliminate isn't changed.
> 
> save_call_clobbered_regs () emit save insn
> (insn 659 161 162 16 (set (mem/c:HI (plus:HI (reg/f:HI 28 r28) # it's FP
>                 (const_int 1 [0x1])) [29 S2 A8])
>         (reg:HI 24 r24)) 12 {*movhi} (nil)
>     (nil))
> 
> calculate_needs_all_insns() try to eliminate (reg/f:HI 28 r28) to SP.
> It's wrong because get_frame_size () != 0 and CAN_ELIMINATE (FP,SP) == 0

But then we'll call update_eliminables(), notice that something
changed, and go around the loop again.

There may be a bug here, but it needs more explanation.

> I think that better to call update_eliminables() somewhere after
> setup_save_areas()

Exactly.  We do that.  About 15 lines after the lines you quoted
above.

What am I missing?

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-15 23:48     ` Ian Lance Taylor
@ 2006-02-16 17:28       ` Denis Chertykov
  2006-02-16 23:56         ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Chertykov @ 2006-02-16 17:28 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Denis Chertykov, Eric Christopher, gcc

Ian Lance Taylor <ian@airs.com> writes:


[...]

> 
> > I think that better to call update_eliminables() somewhere after
> > setup_save_areas()
> 
> Exactly.  We do that.  About 15 lines after the lines you quoted
> above.
> 
> What am I missing?

I'm (exactly AVR port) need in call to update_eliminables() somewhere
between setup_save_areas() and calculate_needs_all_insns()
(Not "about 15 lines after" ;) because all bad things happened inside
calculate_needs_all_insns(). 

calculate_needs_all_insns() collect wrong reloads because
reg_eliminate structure for FP->SP have wrong can_eliminate field.


Denis.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-16 17:28       ` Denis Chertykov
@ 2006-02-16 23:56         ` Ian Lance Taylor
  2006-02-17 17:49           ` Denis Chertykov
  0 siblings, 1 reply; 8+ messages in thread
From: Ian Lance Taylor @ 2006-02-16 23:56 UTC (permalink / raw)
  To: Denis Chertykov; +Cc: Eric Christopher, gcc

Denis Chertykov <denisc@overta.ru> writes:

> > > I think that better to call update_eliminables() somewhere after
> > > setup_save_areas()
> > 
> > Exactly.  We do that.  About 15 lines after the lines you quoted
> > above.
> > 
> > What am I missing?
> 
> I'm (exactly AVR port) need in call to update_eliminables() somewhere
> between setup_save_areas() and calculate_needs_all_insns()
> (Not "about 15 lines after" ;) because all bad things happened inside
> calculate_needs_all_insns(). 
> 
> calculate_needs_all_insns() collect wrong reloads because
> reg_eliminate structure for FP->SP have wrong can_eliminate field.

But then we go around the loop again, so everything should get
recalculated based on the new assumptions.  Doesn't that happen for
you?

Ian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-16 23:56         ` Ian Lance Taylor
@ 2006-02-17 17:49           ` Denis Chertykov
  2006-03-28 20:45             ` Denis Chertykov
  0 siblings, 1 reply; 8+ messages in thread
From: Denis Chertykov @ 2006-02-17 17:49 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: Denis Chertykov, Eric Christopher, gcc

Ian Lance Taylor <ian@airs.com> writes:

> Denis Chertykov <denisc@overta.ru> writes:
> 
> > > > I think that better to call update_eliminables() somewhere after
> > > > setup_save_areas()
> > > 
> > > Exactly.  We do that.  About 15 lines after the lines you quoted
> > > above.
> > > 
> > > What am I missing?
> > 
> > I'm (exactly AVR port) need in call to update_eliminables() somewhere
> > between setup_save_areas() and calculate_needs_all_insns()
> > (Not "about 15 lines after" ;) because all bad things happened inside
> > calculate_needs_all_insns(). 
> > 
> > calculate_needs_all_insns() collect wrong reloads because
> > reg_eliminate structure for FP->SP have wrong can_eliminate field.
> 
> But then we go around the loop again, so everything should get
> recalculated based on the new assumptions.  Doesn't that happen for
> you?

If you mean the "continue" here:
      if (caller_save_needed)
	setup_save_areas ();

      /* If we allocated another stack slot, redo elimination bookkeeping.  */
      if (starting_frame_size != get_frame_size ())
	continue;
-------^^^^^^^^^
then answer no because only set_initial_elim_offsets() will be called.
set_initial_elim_offsets() doesn't change reg_eliminate[].can_eliminate
flag.

If you mean a call update_eliminables() after
calculate_needs_all_insns() then answer no (again :) because all wrong
things already happened inside calculate_needs_all_insns() and
compiler will call
select_reload_regs() -> find_reload_regs() -> spill_failure()

Denis.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: CAN_ELIMINATE question
  2006-02-17 17:49           ` Denis Chertykov
@ 2006-03-28 20:45             ` Denis Chertykov
  0 siblings, 0 replies; 8+ messages in thread
From: Denis Chertykov @ 2006-03-28 20:45 UTC (permalink / raw)
  To: Denis Chertykov; +Cc: Ian Lance Taylor, Eric Christopher, gcc

Denis Chertykov <denisc@overta.ru> writes:

> Ian Lance Taylor <ian@airs.com> writes:
> 
> > Denis Chertykov <denisc@overta.ru> writes:
> > 
> > > > > I think that better to call update_eliminables() somewhere after
> > > > > setup_save_areas()
> > > > 
> > > > Exactly.  We do that.  About 15 lines after the lines you quoted
> > > > above.
> > > > 
> > > > What am I missing?
> > > 
> > > I'm (exactly AVR port) need in call to update_eliminables() somewhere
> > > between setup_save_areas() and calculate_needs_all_insns()
> > > (Not "about 15 lines after" ;) because all bad things happened inside
> > > calculate_needs_all_insns(). 
> > > 
> > > calculate_needs_all_insns() collect wrong reloads because
> > > reg_eliminate structure for FP->SP have wrong can_eliminate field.
> > 
> > But then we go around the loop again, so everything should get
> > recalculated based on the new assumptions.  Doesn't that happen for
> > you?
> 
> If you mean the "continue" here:
>       if (caller_save_needed)
> 	setup_save_areas ();
> 
>       /* If we allocated another stack slot, redo elimination bookkeeping.  */
>       if (starting_frame_size != get_frame_size ())
> 	continue;
> -------^^^^^^^^^
> then answer no because only set_initial_elim_offsets() will be called.
> set_initial_elim_offsets() doesn't change reg_eliminate[].can_eliminate
> flag.
> 
> If you mean a call update_eliminables() after
> calculate_needs_all_insns() then answer no (again :) because all wrong
> things already happened inside calculate_needs_all_insns() and
> compiler will call
> select_reload_regs() -> find_reload_regs() -> spill_failure()

Can somebody comment the problem, please ?

Denis.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-03-28 18:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-13 15:43 CAN_ELIMINATE question Denis Chertykov
2006-02-13 17:48 ` Eric Christopher
2006-02-13 19:07   ` Denis Chertykov
2006-02-15 23:48     ` Ian Lance Taylor
2006-02-16 17:28       ` Denis Chertykov
2006-02-16 23:56         ` Ian Lance Taylor
2006-02-17 17:49           ` Denis Chertykov
2006-03-28 20:45             ` Denis Chertykov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).