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: Swapping commutable binary expressions


Geert Bosch <bosch at gnat dot com> writes:

> This is a commonly used optimization in many compilers.
> Usually one evaluates the most complex operand first,
> to keep the number of temporaries required lowest.
> 
> For example:
>    a + (b + (c + (d + e)))
> 
> should be expanded as (postfix notation)
>    d e + c + b + a +     (requires only one register)
> instead of
>    a b c d e + + + +

I'm not quite convinced about that. Actually, I would expect something
like

(a + b) + (c + d) + e

to be fastest, since it can take better advantage of instruction
parallelism.

-- 
	Falk


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