crtfastmath.c (set_fast_math): Use __builtin_ia32_fxsave.

* config/i386/crtfastmath.c (set_fast_math): Use __builtin_ia32_fxsave.
	Clear only fxsave.mxcsr_mask.  Use saved mxcsr from fxsave structure
	when appropriate.  Correct structure element types.
	* config/i386/t-crtfm (crtfastmath.o): Compile with -mfxsr, remove
	-minline-all-stringops from compile flags.

From-SVN: r192855
This commit is contained in:
Uros Bizjak 2012-10-26 19:54:50 +02:00
parent 85c2f96c1c
commit eff6ca85db
3 changed files with 32 additions and 19 deletions

View File

@ -1,10 +1,18 @@
2012-10-26 Uros Bizjak <ubizjak@gmail.com>
* config/i386/crtfastmath.c (set_fast_math): Use __builtin_ia32_fxsave.
Clear only fxsave.mxcsr_mask. Use saved mxcsr from fxsave structure
when appropriate. Correct structure element types.
* config/i386/t-crtfm (crtfastmath.o): Compile with -mfxsr, remove
-minline-all-stringops from compile flags.
2012-10-25 Ralf Corsépius <ralf.corsepius@rtems.org>
* config.host (sparc64-*-rtems*): Remove sparc/t-elf.
2012-10-25 Ralf Corsépius <ralf.corsepius@rtems.org>
* config.host (sh*-*-rtems*): Add sh*-*-elf*'s extra_parts.
* config.host (sh*-*-rtems*): Add sh*-*-elf*'s extra_parts.
2012-10-25 Sebastian Huber <sebastian.huber@embedded-brains.de>

View File

@ -91,36 +91,41 @@ set_fast_math (void)
return;
#endif /* __sun__ && __svr4__ */
mxcsr = __builtin_ia32_stmxcsr () | MXCSR_FTZ;
if (edx & bit_FXSAVE)
{
/* Check if DAZ is available. */
struct
{
unsigned short int cwd;
unsigned short int swd;
unsigned short int twd;
unsigned short int fop;
long int fip;
long int fcs;
long int foo;
long int fos;
long int mxcsr;
long int mxcsr_mask;
long int st_space[32];
long int xmm_space[32];
long int padding[56];
unsigned short cwd;
unsigned short swd;
unsigned short twd;
unsigned short fop;
unsigned int fip;
unsigned int fcs;
unsigned int foo;
unsigned int fos;
unsigned int mxcsr;
unsigned int mxcsr_mask;
unsigned int st_space[32];
unsigned int xmm_space[32];
unsigned int padding[56];
} __attribute__ ((aligned (16))) fxsave;
__builtin_memset (&fxsave, 0, sizeof (fxsave));
/* This is necessary since some implementations of FXSAVE
do not modify reserved areas within the image. */
fxsave.mxcsr_mask = 0;
asm volatile ("fxsave %0" : "=m" (fxsave) : "m" (fxsave));
__builtin_ia32_fxsave (&fxsave);
mxcsr = fxsave.mxcsr;
if (fxsave.mxcsr_mask & MXCSR_DAZ)
mxcsr |= MXCSR_DAZ;
}
else
mxcsr = __builtin_ia32_stmxcsr ();
mxcsr |= MXCSR_FTZ;
__builtin_ia32_ldmxcsr (mxcsr);
}
#else

View File

@ -1,4 +1,4 @@
# This is an endfile, Use -minline-all-stringops to ensure
# that __builtin_memset doesn't refer to the lib function memset().
crtfastmath.o: $(srcdir)/config/i386/crtfastmath.c
$(gcc_compile) -msse -minline-all-stringops -c $<
$(gcc_compile) -mfxsr -msse -c $<