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: PTR-PLUS merge into the mainline


On 7/5/07, Roman Zippel <zippel@linux-m68k.org> wrote:
Hi,

On Thu, 5 Jul 2007, I wrote:

> Exactly and that's why I think this transformation is done far too early.
> It doesn't make sense that these two examples produce different code:
>
> int foo1(int x)
> {
>       return (x * 4) + 4;
> }
> int foo2(int x)
> {
>       int y = x * 4;
>       return y + 4;
> }

Another example:

int foo3(int x, int y)
{
        return (x * y) + (y * 5);
}
int foo4(int x, int y)
{
        x *= y;
        return x + (y * 5);
}

Here the generated code depends on how the constant multiply is expanded,
so that combine can do the optimization.

This is easily fixable see the patch i posted to 32120.


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