[LLVMdev] replace hardcoded function names by intrinsics

Duncan Sands baldrick at free.fr
Fri Mar 2 07:05:17 PST 2012


Hi,

>> in the llvm code there are several places with hardcoded function
>> names for e.g. sin, sinf, sqrt, sqrtf etc., namely
>> ConstantFolding.cpp
>> InlineCost.cpp
>> SelectionDAGBuilder.cpp
>> IntrinsicLowering.cpp
>> TargetLowering.cpp
>>
>> my question is: wouldn't it be beneficial to use intrinsics for this?
>> for example a c/c++
>> frontend (clang) could translate the function calls to intrinsics and
>> then in a very late
>> step (IntrinsicLowering.cpp?) translate it back to function calls.
>> an opencl frontend then could use the intrinsics on vector types and
>> ConstantFolding.cpp
>> would work on sin/cos of vector types. currently the intrinsics for
>> sin/cos are missing in
>> ConstantFolding.
>> To summarize, using only intrinsics would reduce complexity and
>> increase flexibility as
>> vector types are supported.
>
> I also think that this is a good idea.

intrinsics don't have the same semantics as the library functions.  For example
they don't set errno and in general they are less accurate.  Thus you can't turn
every use of eg sqrt into an intrinsic.  However you will still want to constant
fold instances of sqrt that weren't turned into an intrinsic, and thus all those
names will still need to exist in constant fold etc, so this change wouldn't buy
you much.

Ciao, Duncan.



More information about the llvm-dev mailing list