This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize x*x*x*x*x*x using 3 multiplications.
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: Roger Sayle <roger at eyesopen dot com>, Richard Henderson <rth at redhat dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 31 Jul 2003 18:50:53 -0700
- Subject: Re: [PATCH] Optimize x*x*x*x*x*x using 3 multiplications.
- References: <Pine.LNX.4.44.0308010251520.17944-100000@wotan.suse.de>
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