On 10/4/18 11:29 AM, Joseph Myers wrote: > On Wed, 3 Oct 2018, Jeff Law wrote: > >> That led me to wonder if we could prove that for the majority of FP >> intensive codes that even if the library set errno that nobody could >> possibly be reading it, then we could in large part treat those builtin >> calls as -fno-math-errno (we'd mark them somehow and check the mark at >> GIMPLE->RTL expansion time (and possibly other points) to allow us to >> generate machine instructions rather than library calls). That would >> get most of the benefit without the possibility to breaking user code. > > 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. But as Richi reminded us it can be exceedingly painful to find reads of errno because of the way it's defined by glibc (presumably for thread safety). So this may be academic in practice. Jeff