------- Comment #7 from rguenther at suse dot de  2007-07-09 15:37 -------
Subject: Re:  [4.3 regression] inefficient
 pointer expression

On Mon, 9 Jul 2007, zippel at gcc dot gnu dot org wrote:

> (In reply to comment #5)
> > as you suggest creates worse assembly (look at the extra shift)
> > 
> > foo:
> >         pushl   %ebp
> >         movl    %esp, %ebp
> >         movl    12(%ebp), %ecx
> >         movl    8(%ebp), %edx
> >         popl    %ebp
> >         sall    $2, %ecx
> >         movl    8(%ecx,%edx), %eax
> >         addl    4(%ecx,%edx), %eax
> >         addl    12(%ecx,%edx), %eax
> >         ret
> 
> The cost of this is dependent on the target, so IMO the shift could be
> propagated back into the address at RTL level.

Or the other way around.

> > so there is no form that is clearly better to canonicalize to.
> 
> Your example is rather artificial and depends on that (i + x) * y is 
> completely
> eliminated. My main point is still that such expression are far more difficult
> to translate into proper address operations.
> To generate addresses targeting a form of (i * x) + y is clearly better.

My example is not artificial.  It is quite common to have loops that
stream data from one type to another.  Also it's not 'clearly' better to 
me.

Anyway, fold () is certainly not able to decide this and both value
numbering and re-association can improve the IL by taking into account
context.

On the backend side we have the fwprop pass which is supposed to do
addressing mode selection and the backend which is supposed to provide
accurate costs for them.

Richard.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32698

Reply via email to