On Thu, Aug 17, 2017 at 5:43 PM, Alexander Monakov <amona...@ispras.ru> wrote: > On Thu, 17 Aug 2017, Wilco Dijkstra wrote: > >> This patch simplifies pow (C, x) into exp (x * C1) if C > 0, C1 = log (C). > > Note this changes the outcome for C == +Inf, x == 0 (pow is specified to > return 1.0 in that case, but x * C1 == NaN). There's another existing > transform with the same issue, 'pow(expN(x), y) -> expN(x*y)', so this is > not a new problem. > > The whole set of these match.pd transforms is guarded by > flag_unsafe_math_optimizations, which is a bit strange, on the one hand > it does not include -ffinite-math-only, but on the other hand it's > defined broadly enough to imply that.
No, flag_unsafe_math_optimization doesn't imply -ffinite-math-only. -funsafe-math-optimization these days should guard transforms that affect the value of the result (but not its classification). There are more specific variants like -fassociative-math which also affects results but in a more specific way. > (to be clear, I'm not objecting to the patch, just pointing out an > existing inconsistency in case someone can offer clarifications) We shouldn't add such issue knowingly, I guess for this case it's easy to check that C is not +Inf. For the existing transforms with the same issue guarding with -ffinite-math-only is an appropriate fix. Richard. > Alexander