My apologies to the Gnu compiler team: I guess it just might help a
little bit to turn optimization on, eh?

The following source:

typedef const unsigned char Double80[10];
Double80 s_oneOverRootTwoPi = { 0x68, 0x84, 0xB2, 0xA1, 0x9E, 0x29,
0x42, 0xCC, 0xFD, 0x3F};

double oneOverRootTwoPi() __attribute__(( cdecl ));
double oneOverRootTwoPi() {
        register double dReturnValue;
        __asm__(
                "fldt %[s_oneOverRootTwoPi]"
                : "=t" (dReturnValue)
                : [s_oneOverRootTwoPi] "m" (*s_oneOverRootTwoPi)
                :
                );
        return dReturnValue;
}

compiled with -O3, generates the following code (when not inlined)

Dump of assembler code for function _Z14oneOverRootTwov:
   0x004013d8 <+0>:     push   %ebp
   0x004013d9 <+1>:     mov    %esp,%ebp
   0x004013db <+3>:     fldt   0x404305
   0x004013e1 <+9>:     leave
   0x004013e2 <+10>:    ret
   0x004013e3 <+11>:    nop
End of assembler dump.

which, for anything but the simplest of functions (above example is
unreasonably simple) is ideal, and it inlines perfectly for such a
simple function.
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
https://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to