This is the mail archive of the 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] Fold x + x to x * 2


> On Sat, 6 Nov 2004, Zdenek Dvorak wrote:
> > 	* fold-const.c (fold_mult_into, fold_sum_of_mult): New functions.
> > 	(fold): Use them.
> I don't think this patch (even with minor corrections) is suitable for
> stage3.  In addition to the trapping math issues mentioned previously,
> I'm concerned that you're efforts to partially implement full arithmetic
> reassociation in "fold" could potentially have disasterous compile-time
> and memory usage overheads.

... on examples that do not really exist in practice.  Bounding the
depth of search to 2 or 3 IMHO solves the problem and would work
equally well in any real case.

> As a simple case study, consider how many instructions your implementation
> actually requires to convert "x + x" into "x * 2", as mentioned in the
> title.

Some 40 simple C commands (I have no idea how this translates to
instructions).  It is definitely possible to make the transformation
more efficient in simple cases, however having it as a special case
of a more general transformation makes a cleaner code.

> But I agree that your problem of "x + x + x + x" generated by tree
> transformations needs to be fixed.  Its probably not urgent given that
> LNO and tree-ssa and much of stage3 never even noticed this.  Let me
> see what I can come up with, probably a local solution that addresses
> your needs, leaving an implementation of full reassociation, including
> negation, subtraction and left shifts to 4.1.  We'll probably even
> need several complementary patches should we decide that "x*2" is the
> canonical form of "x+1", including a new fast path for synth_mult.
> Do you have any timing figures for your patch?

Compile time neutral, no effect on produced code as far as I can tell
(the major impact of the patch is that I do not have to look at the
ugly expressions in the dumps :-)


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