On Sat, 14 Sep 2019, Jakub Jelinek wrote: > Hi! > > As mentioned in the PR, the sqrt (x) < c optimization into x < c*c > sometimes breaks the boundary case, if c2=c*c is inexact then in some cases > we need to optimize it into x <= c*c rather than x < c*c. The original
And in some cases the boundary case is wrong in the other direction and we need to optimize it into x < nextdown (c*c). For example, say c == 0x1.001002p+0f; (double) c * c == 0x1.002005004004p+0, and rounding to nearest float gives c * c == 0x1.002006p+0f, so nextdownf (c * c) == 0x1.002004p+0f; in double precision, sqrt (0x1.002004p+0f) == 0x1.0010017fe8006p+0, and rounding to nearest float gives c again. So x < c*c does not in fact imply sqrt (x) < c in that case. -- Joseph S. Myers jos...@codesourcery.com