[llvm-commits] [llvm-gcc-4.0]Patch to make llvm-gcc emit llvm.pow/sin/cos.* [for review]

Duncan Sands baldrick at free.fr
Fri Nov 23 01:48:26 PST 2007

Hi Sheng,

> Here is the patch to make llvm-gcc/llvm-g++ emit llvm.pow.* when errno
> disabled.

thanks for doing this.  Yet I have to wonder whether there's any point
to using the llvm.pow.* intrinsic, or for that intrinsic to exist.
LLVM doesn't seem to do anything with it, so presumably the only
reason for it is so that LLVM knows that it is "pure".  But nowadays
gcc tells LLVM that directly.  Look:

#include <math.h>
double f(double x, double y) {
  return pow(x,y);

If you compile it with -fno-math-errno then pow gets declared as

declare double @pow(double, double) nounwind readonly

[I'm not sure why it is marked readonly rather than readnone].
[If you don't use -fno-math-errno then it is not declared readonly,
which is correct because it can set errno].
Since yesterday, alias analysis knows how to deal with readonly
and readnone functions.  So all the benefit you would get from
the intrinsic is already there!

So how about removing the llvm.pow.* intrinsic and other ones like it



More information about the llvm-commits mailing list