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.


Hi,

On Thu, 31 Jul 2003, Roger Sayle wrote:

> A scheme like the one used in rtlanal.c's swap_commutative_operands
> would appear to be more scalable here.  For example, we want to move
> all of the constants together.

Yes.  Although note, that constants and literals are split away before the
reorder_summands() function sees it by the already existing machinery in
fold-const (split_trees and friends).  Nevertheless this can possibly be
merged with a general resort-everything.

> Eventually, we'd want to order x*c next to x in an addition chain and
> pow(x,c) next to x in a multiplication chain.  But this level of
> tweaking would require a very flexible "comparison" infrastructure.

Indeed.  It's currently specifically only doing what I needed, namely put
all indirect_refs or array_refs with non-zero index first, then all direct
var_decls, last all indirect_refs and array_refs with zero index (and then
all unhandled summands).  (The underlying reason having to do with the
fact that non-zero based refs can't alias with scalars)  And of course all
operands in the same group in some fixed order.

> Just my thoughts.  I think the concept itself looks sound.  Hopefully,
> the improvements in CSE and reduction in register pressure will outweigh
> the loss of parallelism available to the scheduler.

The current version shouldn't change the the parallelism systematically.
It just reorders operands, but doesn't change for instance the number of
operators.  With an extended version of course this would be the case.
But it does fix some (artificial I admit) CSE cases.


Ciao,
Michael.


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