------- Comment #6 from zippel at gcc dot gnu dot org  2007-07-09 15:27 -------
(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.

> 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.


-- 


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

Reply via email to