> > 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. > > Jakub >
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). Ilya