CGBuiltin.cpp?

Why is that many of the gcc builtins are not mapped to the llvm ir builtins, in cases
where there is a corresponding llvm ir builtin/intrinsic.

For example, sin, cos, log, log2, exp, exp2.....??

Of the normal math functions is seems that just pow and fabs are there.

Reed

The idea is that the builtins are wrapped by portable intrinsics (e.g. mm* on x86) and therefore those should be used as an interface in programming. If there’s no suitable intrinsic then we’ll expose the builtin.

-eric

The question isn’t about the Intel mm* intrinsics, it’s about the C math builtins we provide under __builtin_pow, etc. I think most of them are mapped to their libc calls for convenience. Some have been added on an ad-hoc basis as needed.

I believe that GCC lowers most calls to __builtin_sqrt and such to instructions before library calls, so we can go ahead and map most of those down to LLVM intrinsics without worrying about things like errno. It’s worth checking as you go, though, rather than blindly mapping everything to LLVM intrinsics.

The question isn’t about the Intel mm* intrinsics, it’s about the C math builtins we provide under __builtin_pow, etc. I think most of them are mapped to their libc calls for convenience. Some have been added on an ad-hoc basis as needed.

Right. Same general principle :slight_smile:

I believe that GCC lowers most calls to __builtin_sqrt and such to instructions before library calls, so we can go ahead and map most of those down to LLVM intrinsics without worrying about things like errno. It’s worth checking as you go, though, rather than blindly mapping everything to LLVM intrinsics.

Agreed.

-eric

You want me to submit the patches for these changes?

It would be nice to clean up this module.

There are probably dejagnu tests worth porting to llvm test suite for this too.

My manager gave me approval to work on it.

(Sorry for the delay, slipped off of my email radar)

Sure, happy to take a look at them.

-eric