Compile-time evaluation of real expressions?
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jan 6 20:00:05 PST 2012
On Saturday, January 07, 2012 04:49:27 Timon Gehr wrote:
> On 01/07/2012 12:37 AM, Jonathan M Davis wrote:
> > On Saturday, January 07, 2012 00:03:39 Alex Rønne Petersen wrote:
> >> Most likely those functions are just implemented using inline
> >> assembly,
> >> therefore not usable in CTFE.
> > Yeah, several functions in std.math use inline assembly. So, for them to
> > be able to be used at compile time, either the compiler must be
> > expanded to be able to run asm statements at compile time (which may or
> > may not be planned and may or may not be reasonable), or those
> > functions need another branch (using __cfte in an if condition) which
> > doesn't use assembly. Or I suppose that if the extra check for __ctfe
> > isn't considered particularly acceptable (after all, they're already
> > using assembly) [snip.]
> If the if condition is a constant, there is no runtime overhead.
Ah, good point - though depending on what the compiler does, that may only be
the case with -O. But anyone who really cares about that level of performance
would be compiling with -O anyway.
- Jonathan M Davis
More information about the Digitalmars-d-learn