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

Sanjay Patel via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 29 14:57:37 PST 2016


On Thu, Jan 28, 2016 at 6:57 AM, Joerg Sonnenberger via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> On Wed, Jan 27, 2016 at 05:53:33PM -0800, Matt Arsenault via llvm-dev
> wrote:
> > 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.
>
> As long as you make sure that it deals properly with renames used on the
> prototypes... E.g. a call to "double sin(double)" can easily be forced
> to use "my_better_sin_function" on the C level. One huge problem with
> the "everything as __builtin mess" GCC introduced was to effectively
> remove any sane way to model such behavior.
>

I'm not familiar with what happened to GCC, but I like this proposal
because I know there are optimization holes due to not matching both the
intrinsic and the libcall. Double --> float shrinking and fmax/fmin are
cases I noticed recently. Pulling the intrinsic optimizations out of
SimplifyLibCalls should also make it easier to refactor the library
function prototype checking. I made a few changes here after
https://llvm.org/bugs/show_bug.cgi?id=26211 , but it's still a mess.

cc'ing Davide as he might have some ideas about cleaning up
SimplifyLibCalls too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160129/4f8d9481/attachment.html>


More information about the llvm-dev mailing list