[RFC PATCH] Convert pow(10.0,x) -> exp10(x), etc...
Kaveh R. Ghazi
ghazi@caip.rutgers.edu
Sat Apr 16 04:58:00 GMT 2005
> long double test1l(long double x)
> {
> return powl(10.0, x);
> }
Also, your testcases only ensure that GCC compiles the given code, not
that the transformation succeeds. Instead you can write code like
this:
if (powl(10.0, x) != exp10(x))
link_error();
This should get folded into
if (exp10(x) != exp10(x))
And since with -ffast-math exp10 is a const function, this expr is
always false and therefore link_error is never called and thus not
emitted. If the transformation fails, then the if-stmt isn't folded
away and the call to link_error() is emitted and the compilation
fails. So you can tell if the transformation was done using a compile
test.
Again, look at what I did in gcc.dg/torture/builtin-explog-1.c.
I also macroized everything to avoid cut-n-paste typos.
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu
More information about the Gcc-patches
mailing list