On Thu, 4 Oct 2018, Jeff Law wrote: > > I doubt you could prove that without LTO of the whole program because an > > errno value set by a libm function call could always be checked in the > > caller of whatever function is being compiled. > Right, but if you have a series of calls like > > > t1 = sqrt (x); > t2 = sqrt (y); > t3 = sqrt (z); > return t1 + t2 + t3; > > You know that errno from the first two isn't examined and you could emit > the hardware insn for sqrt in those cases. You couldn't do so for the > 3rd because you don't necessarily have the caller context.
No, you don't know that error from the first two isn't examined. sqrt doesn't set errno on success. A caller could set errno to 0 before that code, then check for errno == EDOM afterwards, meaning that any of the sqrt arguments were negative. (The caller could also check whether the result is a NaN and so not need errno, of course.) -- Joseph S. Myers jos...@codesourcery.com