This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] convert math libcalls/builtins to equivalent LLVM intrinsics
ClosedPublic

Authored by spatel on Nov 14 2017, 11:26 AM.

Details

Summary

There are 20 LLVM math intrinsics that correspond to mathlib calls according to the LangRef:
http://llvm.org/docs/LangRef.html#standard-c-library-intrinsics

We were only converting 3 mathlib calls (sqrt, fma, pow) and 12 builtin calls (ceil, copysign, fabs, floor, fma, fmax, fmin, nearbyint, pow, rint, round, trunc) to their intrinsic-equivalents.

This patch pulls the transforms together and handles all 20 cases. The switch is guarded by a check for const-ness to make sure we're not doing the transform if errno could possibly be set by the libcall or builtin.

Diff Detail

Repository
rL LLVM