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]
Other format: [Raw text]

Re: [PATCH][auto-inc-dec.c] Account for cost of move operation in FORM_PRE_ADD and FORM_POST_ADD cases


On Mon, 2015-10-26 at 12:12 +0100, Bernd Schmidt wrote:
> On 10/26/2015 11:40 AM, Kyrill Tkachov wrote:
> > In the FORM_POST_ADD case the pass transforms:
> >             *a
> >             ...
> >             b <- a + c
> > 
> > into
> > 
> >             b <- a
> >             ...
> >             *(b += c) post
> > 
> > 
> > However, the code in attempt_change that compares the costs of the
> > before and after sequences
> > has an oversight. When calculating the cost of the new sequence it
> > doesn't take into account the cost of the
> > b <- a move. This patch fixes the calculation by calling seq_cost
> > on the
> > result of the emit_move_insn call
> > we do to emit that move.
> 
> But isn't that balanced by the fact that it doesn't seem to take into
> account the gain of removing the inc_insn either? So I think this
> can't 
> be right.
> 
> > +      new_mov_cost = seq_cost (mov_insn, speed);
> > +    }
> > +
> > +  new_cost = new_mem_cost + new_mov_cost;
> 
> Here I'd just replace the first line with
>    new_cost += seq_cost (...)
> and lose the extra variable.
> 
> I seem to recall Richard had a rewrite of all the autoinc code. I
> wonder 
> what happened to that?

BTW there's been another recent attempt at replacing auto-inc-dec with
a more generic addressing mode selection (AMS) pass.  It tries to take
into account costs of individual addressing modes for each mem access
and also combinations of address register modifications and addressing
modes.  The initial version is for SH only and still requires some work
before it can be merged into mainline.  I hope that I can make it for
GCC 6...

Cheers,
Oleg


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