public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Disabling x87 instructions in -O3 X86_64 sse enabled code
@ 2006-08-29 18:36 Alex Bennee
  2006-08-29 21:19 ` Rask Ingemann Lambertsen
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Bennee @ 2006-08-29 18:36 UTC (permalink / raw)
  To: gcc-help

Hi,

I posted a reply to http://gcc.gnu.org/ml/gcc-help/2006-03/msg00159.html
but seeing as it was in March it's probably disappeared under the radar.

I'm running gcc 4:

$: /export/BobTheBuilder/compilers/x86-linux-cross/x86_64-linux-gcc-4.1.0/bin/x86_64-linux-gcc --version
x86_64-linux-gcc (GCC) 4.1.0

And I'm seeing problems with signalling NaN propagation in my code if I
compile with -O3. The problem is is the compiler is putting the operands
into the x87 registers with code like:

 flds   0x108(%rsp)
 fstps  0x20(%rsp)

Which kills the Signalling aspect of the NaN so when it gets to my hand
crafted SSE2 assembler routine the signal isn't thrown.

I'm compiling the code with:
 -march=nocona -mfpmath=sse -msse2 -ffast-math

But it doesn't seem to make any difference. Putting a fprintf to dump
the operands before the call does change the register allocation and
keep the numbers un-molested in xmm registers. However I'm under the
impression gcc shouldn't be generating any x87 code unless explicitly
enabled.

I also tried:
 -ffixed-st0 -ffixed-st1 -ffixed-st2 -ffixed-st3 -ffixed-st4 -ffixed-st5
-ffixed-st6 -ffixed-st7

To try and force the x87 floating point registers from being used.
Unfortunately gcc didn't recognise the registers and I couldn't find the
REGISTER_NAMES macro definition in the sources for what the correct
incantation was.

The previously mentioned message seemed to imply this was fixed but I
can't find any reference in the 4.1.1 ChangeLog. Any suggestions on how
I can work around this bug?

--
Alex, homepage: http://www.bennee.com/~alex/
The qotc (quote of the con) was Liz's: "My brain is paged out to my
liver"

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disabling x87 instructions in -O3 X86_64 sse enabled code
  2006-08-29 18:36 Disabling x87 instructions in -O3 X86_64 sse enabled code Alex Bennee
@ 2006-08-29 21:19 ` Rask Ingemann Lambertsen
  2006-09-01 17:15   ` Alex Bennee
  0 siblings, 1 reply; 3+ messages in thread
From: Rask Ingemann Lambertsen @ 2006-08-29 21:19 UTC (permalink / raw)
  To: Alex Bennee; +Cc: gcc-help

On Tue, Aug 29, 2006 at 06:23:52PM +0100, Alex Bennee wrote:

> However I'm under the
> impression gcc shouldn't be generating any x87 code unless explicitly
> enabled.

   There's an undocumented option -mno-80387 (at least in GCC 4.2).
 
> I also tried:
>  -ffixed-st0 -ffixed-st1 -ffixed-st2 -ffixed-st3 -ffixed-st4 -ffixed-st5
> -ffixed-st6 -ffixed-st7
> 
> To try and force the x87 floating point registers from being used.
> Unfortunately gcc didn't recognise the registers and I couldn't find the
> REGISTER_NAMES macro definition in the sources for what the correct
> incantation was.

   From gcc/config/i386/i386.h (still GCC 4.2, but I doubt this is much
different in GCC 4.1):

#define HI_REGISTER_NAMES                                               \
{"ax","dx","cx","bx","si","di","bp","sp",                               \
 "st","st(1)","st(2)","st(3)","st(4)","st(5)","st(6)","st(7)",          \
 "argp", "flags", "fpsr", "dirflag", "frame",                           \
 "xmm0","xmm1","xmm2","xmm3","xmm4","xmm5","xmm6","xmm7",               \
 "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" ,               \
 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",                  \
 "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15"}

#define REGISTER_NAMES HI_REGISTER_NAMES

#define ADDITIONAL_REGISTER_NAMES \
{ { "eax", 0 }, { "edx", 1 }, { "ecx", 2 }, { "ebx", 3 },       \
  { "esi", 4 }, { "edi", 5 }, { "ebp", 6 }, { "esp", 7 },       \
  { "rax", 0 }, { "rdx", 1 }, { "rcx", 2 }, { "rbx", 3 },       \
  { "rsi", 4 }, { "rdi", 5 }, { "rbp", 6 }, { "rsp", 7 },       \
  { "al", 0 }, { "dl", 1 }, { "cl", 2 }, { "bl", 3 },           \
  { "ah", 0 }, { "dh", 1 }, { "ch", 2 }, { "bh", 3 } }

-- 
Rask Ingemann Lambertsen

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Disabling x87 instructions in -O3 X86_64 sse enabled code
  2006-08-29 21:19 ` Rask Ingemann Lambertsen
@ 2006-09-01 17:15   ` Alex Bennee
  0 siblings, 0 replies; 3+ messages in thread
From: Alex Bennee @ 2006-09-01 17:15 UTC (permalink / raw)
  To: Rask Ingemann Lambertsen; +Cc: gcc-help

On Tue, 2006-08-29 at 22:55 +0200, Rask Ingemann Lambertsen wrote:
> On Tue, Aug 29, 2006 at 06:23:52PM +0100, Alex Bennee wrote:
> 
> > However I'm under the
> > impression gcc shouldn't be generating any x87 code unless explicitly
> > enabled.
> 
>    There's an undocumented option -mno-80387 (at least in GCC 4.2).

Cool - that has indeed fixed the problem with our gcc 4.1 build.

Thanks :-)

--
Alex, homepage: http://www.bennee.com/~alex/
The world is coming to an end ... SAVE YOUR BUFFERS!!!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-01 17:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-29 18:36 Disabling x87 instructions in -O3 X86_64 sse enabled code Alex Bennee
2006-08-29 21:19 ` Rask Ingemann Lambertsen
2006-09-01 17:15   ` Alex Bennee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).