[llvm-dev] [RFC] Canonicalize libcalls to intrinsics

Matt Arsenault via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 27 17:53:33 PST 2016


I would like to propose that when available, if a C builtin function has 
an equivalent llvm intrinsic, that the intrinsic be the preferred form. 
The equivalent clang __builtin should emit the intrinsic, and 
SimplifyLibCalls should replace calls with the intrinsic.

For context, this came up on an old review thread: 

There are a few motivations for this:

1. Intrinsics have additional properties that help optimizations. They 
are more widely considered by optimization passes, such as being 
vectorizable and speculatively executable.
2. More useful for targets where the concept of libcalls is not useful. 
On GPU targets where there is no machine level linked library, a correct 
TargetLibraryInfo would report no supported library functions, disabling 
optimizations on that function. Ideally we could specify libcalls as 
another function defined in the IR, but that is a separate problem.
3. Consistency. Some __builtins emit the llvm intrinsics, and others do not.
4. It seems unnatural to me to emit a special DAG node for specific 
calls, then for most targets to later on expand it again as a call later.
5. Eliminate redundant code. Places like ConstantFolding currently have 
to handle the intrinsic and the libcall


More information about the llvm-dev mailing list