>> I think 2) is taken care of by -fassociative-math, or it should at least. > > I don't think it is (I haven't checked), and I don't see why it should. > This transformation has nothing to do with associativity : unless I'm > mistaken, it is always valid when rounding is to the nearest or towards > zero.
(-a) * b => -(a * b) is definitely reassociation (-a is -1 * a); no reassociation has to be valid in any rounding mode, which means two things: 1) it can be done even when other rounding-mode-dependent optimizations are disabled via flag_rounding_math (good); 2) it would also enable other optimization that you might not want (bad). Paolo