On Wed, Jul 13, 2011 at 01:01:59PM +0400, Ilya Enkovich wrote:
> > Well, if it is clearly a win to reassociate, you can always reassociate
> > them by doing arithmetics in corresponding unsigned type and afterwards
> > converting back to the signed type.
> 
> You are right. But in this case we again make all operands have
> wrap-around type and thus disable some other optimization. It would be
> nice to have opportunity to reassociate and still have undefined
> behavior on overflow for optimizations. One way to do it for add/sub
> is to use wider type (long long instead of int).

I disagree.  Widening would result in worse code in most cases, as you need
to sign extend all the operands.  On the other side, I doubt you can
actually usefully use the undefinedness of signed overflow for a series of
3 or more operands of the associative operation.

        Jakub

Reply via email to