[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inline assembler functions returning double as 80-bit extended-preci
From: |
DavidIMcIntosh |
Subject: |
Re: inline assembler functions returning double as 80-bit extended-precision double |
Date: |
Tue, 10 May 2011 19:34:12 -0700 (PDT) |
User-agent: |
G2/1.0 |
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.