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] Optimize x*x*x*x*x*x using 3 multiplications.


Michael Matz <matz@suse.de> writes:

> Hi,
>
> On Thu, 31 Jul 2003, Roger Sayle wrote:
>
>> extern int z1, z2;
>> void foo(int x, int y, int z)
>> {
>>   z1 = (x+y)+z;
>>   z2 = x+(y+z);
>> }
>>
>> gets optimized to z2 = z1 with MSVC but not by GCC.
>
> I have a somewhat ugly patch for this problem which basically reorders all
> operands of an associative, commutative operator into some canonical
> order.  This makes CSEing them possible.

We have to be careful ... is this optimization not forbidden in
Fortran? (with the parentheses present, anyway)

zw


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