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: Failure introduced by the sahf patch(es)


H. J. Lu wrote:

There has been a recent addition to add this "sahf" to the
instructions used by the i386 back-end.
This is mine, but from asm dump:

.L120:
       fprem
       fnstsw  %ax
       sahf
       jp      .L120
       fstp    %st(1)
       xorpd   %xmm2, %xmm2

This is perfectly good asm for MOD() a.k.a. fmod() function.

64bit sahf was enabled by


http://sourceware.org/ml/binutils/2004-11/msg00313.html

I think we should either use .byte with a commment and check if
assembler supports 64bit sahf if we want to generate 64bit sahf.
Attached patch fixes this annoyance.

2007-03-14 Uros Bizjak <ubizjak@gmail.com>

       * configure.ac (HAVE_AS_IX86_SAHF): On x86 targets check whether
       the configured assembler supports the sahf mnemonic.
       * configure: Regenerate.
       * config.in: Regenerate.

       * config/i386/i386.md (x86_sahf_1): Depending on HAVE_AS_IX86_SAHF,
       emit "sahf" or ".byte\t0x9e" as asm template.

Patch is regression tested on x86_64-pc-linux-gnu for all default languages. Patch is commited to SVN.

Uros.


Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md	(revision 122924)
+++ config/i386/i386.md	(working copy)
@@ -988,7 +988,7 @@
 	(unspec:CC [(match_operand:HI 0 "register_operand" "a")]
 		   UNSPEC_SAHF))]
   "TARGET_SAHF"
-  "sahf"
+  "* return HAVE_AS_IX86_SAHF ? \"sahf\" : \".byte\t0x9e\";"
   [(set_attr "length" "1")
    (set_attr "athlon_decode" "vector")
    (set_attr "amdfam10_decode" "direct")
Index: config.in
===================================================================
--- config.in	(revision 122924)
+++ config.in	(working copy)
@@ -228,6 +228,12 @@
 #endif
 
 
+/* Define if your assembler supports the sahf mnemonic. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_IX86_SAHF
+#endif
+
+
 /* Define if your assembler supports the lituse_jsrdirect relocation. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_JSRDIRECT_RELOCS
Index: configure
===================================================================
--- configure	(revision 122924)
+++ configure	(working copy)
@@ -15237,6 +15237,39 @@
 
 fi
 
+    echo "$as_me:$LINENO: checking assembler for sahf mnemonic" >&5
+echo $ECHO_N "checking assembler for sahf mnemonic... $ECHO_C" >&6
+if test "${gcc_cv_as_ix86_sahf+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  gcc_cv_as_ix86_sahf=no
+  if test x$gcc_cv_as != x; then
+    echo 'sahf' > conftest.s
+    if { ac_try='$gcc_cv_as  -o conftest.o conftest.s >&5'
+  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }
+    then
+	gcc_cv_as_ix86_sahf=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+echo "$as_me:$LINENO: result: $gcc_cv_as_ix86_sahf" >&5
+echo "${ECHO_T}$gcc_cv_as_ix86_sahf" >&6
+if test $gcc_cv_as_ix86_sahf = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_AS_IX86_SAHF 1
+_ACEOF
+
+fi
+
     echo "$as_me:$LINENO: checking assembler for different section symbol subtraction" >&5
 echo $ECHO_N "checking assembler for different section symbol subtraction... $ECHO_C" >&6
 if test "${gcc_cv_as_ix86_diff_sect_delta+set}" = set; then
Index: configure.ac
===================================================================
--- configure.ac	(revision 122924)
+++ configure.ac	(working copy)
@@ -2808,6 +2808,12 @@
       [AC_DEFINE(HAVE_AS_IX86_FFREEP, 1,
         [Define if your assembler supports the ffreep mnemonic.])])
 
+    gcc_GAS_CHECK_FEATURE([sahf mnemonic],
+      gcc_cv_as_ix86_sahf,,,
+      [sahf],,
+      [AC_DEFINE(HAVE_AS_IX86_SAHF, 1,
+        [Define if your assembler supports the sahf mnemonic.])])
+
     gcc_GAS_CHECK_FEATURE([different section symbol subtraction],
       gcc_cv_as_ix86_diff_sect_delta,,,
       [.section .rodata

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