[PATCH] Optimize x*x*x*x*x*x using 3 multiplications.
Richard Henderson
rth@redhat.com
Thu Jul 31 21:34:00 GMT 2003
On Thu, Jul 31, 2003 at 02:50:55PM -0600, Roger Sayle wrote:
> I apologise for loading the dice.
:-)
> I now have a new life goal to implement better reassociation
> in GCC's constant folding and RTL optimizers.
Well, I'll not stop you, but given my druthers I'd really prefer that
this work be done for tree-ssa.
In the first case because the constant folder only sees full expressions
if they are written that way by the user. E.g. suppose we have a smart
programmer who has done his own reassociation for x^23, but doesn't know
about the power table approach. In that case we'll not be able to put
it all back together to generate optimial code.
In the second case because we'd like to relegate rtl optimization to
what it is good at -- target-specific representation and optimization.
If I remember right, you can do reassociation at the same time that you
do global value numbering. Something like: first pass of GVN collects
the as-written expression tree, then you apply height reduction
transformations to the expression tree (reassociation), then the final
pass of GVN writes it all back out again in the optimal places in the CFG.
> Can I take that as an approval for the current patch?
Yes.
r~
More information about the Gcc-patches
mailing list