crtfastmath.c (set_fast_math): Use __builtin_ia32_fxsave.
authorUros Bizjak <uros@gcc.gnu.org>
Fri, 26 Oct 2012 17:54:50 +0000 (19:54 +0200)
committerUros Bizjak <uros@gcc.gnu.org>
Fri, 26 Oct 2012 17:54:50 +0000 (19:54 +0200)
* 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

libgcc/ChangeLog
libgcc/config/i386/crtfastmath.c
libgcc/config/i386/t-crtfm

index 3f17f3f176957365c5837c6587710d4ef42311cf..3f073ab12eb0bb03e5bf114dd8054fde13a661fb 100644 (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>
 
index 7abe500e98194d4da37880ee6f973485d805def7..e923d8f46692e930e2fe2062f1ef88ace8514cba 100644 (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;
+
+         __builtin_ia32_fxsave (&fxsave);
 
-         asm volatile ("fxsave %0" : "=m" (fxsave) : "m" (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
index 46ce70bbb21f9794c29ba7a03661b3afaa3ba300..b9da06bfd20984364fc4cbbd95bd2d9c2314a7b4 100644 (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 $<