This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, i386]: Rounding mode switching improvements


Quoting Richard Henderson <rth@redhat.com>:

> >   By adding entity that handles emms/femms mode switching, the same
> > approach can be used to implement emms/femms insertions to handle
> > automatic switching between MMX/x87 state
> 
> I'm less sure about this.  Here we pretend mmx and fpu registers are
> disjoint, when they aren't.  It seems to me you'd have to do something
> to prevent the register allocator from trying to use them simultaneously.


  I think that this can be solved by introducing an UNSPEC_VOLATILE, similar to
mmx_emms, that would clobber all x87 registers. This insn should be inserted via
LCM before mmx instructions, and will save all live x87 registers. This way,
expensive fnsave/frstor instructions could be avoided.

  Switching back to x87 mode, emms would be inserted, again via LCM (I'm not
sure, if emms really needs to clobber x87 registers, as it is used only at the
end of mmx mode, where no x87 regs should be live) that would save all mm
registers to memory and clear tag word of x87.

  I was under impression that x87 and mm registers could be used simultaneously,
but every mmx insn sets all tags in x87 tag register to 1, so the state of tag
reg is not preserved. To use them simultaneously, we would need fnsave/frstor
pair before every switch of modes.

  I have to experiment with this approach a bit, to see, how it will upset
reload :). 

> This patch is ok.

Thanks for reviewing it!

Uros.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]