https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66736

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to dhekir from comment #2)
> Isn't the library implementation of log10f used to compute the literal
> constants generated in the assembly code? Would it then be a double
> precision result that would be precomputed and rounded to single precision
> in this case?

No, GCC uses the GMP / mpfr / mpc libraries to constant fold math functions.
The library implementation is for example not available when cross-compiling.

> Well, sorry for the noise, I compared the results with other compilers and,
> even if the numerical results themselves were different, they were
> consistent between precomputed constant literals and the underlying libc,
> therefore such surprising situations do not arrive. I assumed that it was
> not intented in GCC and so it would be useful to report it, but if it's not
> the same library function used in both cases, that explains the issue.

Yes, that explains it.  GCC produces exact results for constant folding.

Note that with other compilers you may fall into the trap of not executing
the library function in any case so I suggest to make the 'float r' variable
global and volatile.

Reply via email to