This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH, i386] automatic MMX/x87 FPU mode switching (the realone)
- From: Uros Bizjak <uros at kss-loka dot si>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Uros Bizjak <uros dot bizjak at kss-loka dot si>,Richard Henderson <rth at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 27 Jun 2005 16:18:10 +0200
- Subject: Re: [PATCH, i386] automatic MMX/x87 FPU mode switching (the realone)
- References: <Pine.LNX.email@example.com>
Roger Sayle wrote:
I think your problems with reg-stack.c are caused by a misunderstanding
or overloading of the term "x87 registers are live". There's a semantic
difference with stack registers between being available for use, and
actually holding a value. reg-stack.c concerns itself with the latter,
and your code confuses it by telling it that an UNSPECV_EFPU pushes
all eight floating point values onto stack, and the UNSPECV_EMMS pops
everything off of the stack.
Presumably, if reload and flow.c have done their job, there should
be nothing to do in reg-stack.c, as the x87 stack should be empty at
both types of mode switching instructions. Instead, I think you need
to clobber all of the other register sets contents in these patterns,
to ensure this.
after some debugging, it looks that convert_regs_exit and
convert_regs_entry functions are emitting stack compensating code on its
own. So, when we have 8 fp registers live at function entry, reg-stack.c
fills register stack with NaNs. At the function exit, reg-stack.c looks
for the number of needed registers by itself, and then tries to
compensate register stack to fit into this. Indeed, the registers sets
are empty at the EFPU/EMMS boundaries, otherwise we wouldn't get as far
as _.33.stack with the compilation.
I was wandering, if it is possible to get away by reg-stack.c simply
ignoring the fact that EFPU/EMMS somehow load all 8 registers. It
works, but some other compensation hacks would be needed on funtion
entry and function exit. Currently a couple of lines are needed to
prevent entry/exit compensation code to outsmart us.
Unfortunatelly, there is one ICE left where reg-stack.c thinks that it
processes malformed ASM - I'll look into it tomorrow.