[LLVMdev] sincos optimization
dg at cowlark.com
Tue Jan 22 02:59:14 PST 2013
On 22/01/13 05:30, Redmond, Paul wrote:
> I'm looking at http://llvm.org/bugs/show_bug.cgi?id=13204 which involves converting calls to sin and cos to sincos (when available)
> Initially I thought about transforming calls to sinf/cosf to sincosf. However, I don't think this is a legal transformation given that a declaration for a function called sinf is not necessarily the standard library function.
I've actually just dealt with this --- standard library calls, including
sinf, *are* promoted to intrinsics if the compiler sees them (and are
then usually converted back to library calls again later). The list of
recognised names is here:
The list of functions which are considered candidates for promotion is
in hasOptimizedCodeGen() in here:
...and the code that actually does it is here:
Look for SelectionDAGBuilder::visitUnaryFloatCall() and visitCall().
It appears that such functions are only promoted if they're declared
readnone, which provides some protection against overriding a standard
library function, but I haven't found anything that explicitly checks
for this yet.
Disclaimer: I learnt this yesterday...
┌─── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ───── http://www.cowlark.com ─────
│ "Of course, on a sufficiently small planet, 40 km/hr is, in fact,
│ sufficient to punt the elastic spherical cow into low orbit." ---
│ Brooks Moses on r.a.sf.c
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 262 bytes
Desc: OpenPGP digital signature
More information about the llvm-dev