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]

PATCH: PR target/39590: inline asm %z on amd64 says "ll" instead of "q"


Hi,

Gcc generates "movll" for asm statement with "mov%z1" on a DImode memory.
The problem is "%z" was never updated for 64bit. We can't generate 'q'
for "%z" due to "fild%z1\t%1" in i386.md. Not all x86-64 assemblers
support "fildq".  This patch checks if assembler supports fildq and
generates fildq/movq when it works.  OK for trunk?

Thanks.


H.J.
----
gcc/

2009-04-01  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/39590
	* configure.ac: Check if x86 assemble supports fildq. 
	* config.in: Regenerated.
	* configure: Likewise.
	
	* config/i386/i386.c (print_operand): Print 'q' for "%z" if
	HAVE_AS_IX86_FILDQ is defined.

	* config/i386/i386.md: Update comments for "%z".

gcc/testsuite/

2009-04-01  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/39590
	* gcc.target/i386/fildq.c: New.
	* gcc.target/i386/pr39590.c: Likewise.

	* lib/target-supports.exp (check_effective_target_fildq): New.

--- gcc/config.in.fildq	2009-03-31 16:22:50.000000000 -0700
+++ gcc/config.in	2009-04-01 10:57:55.000000000 -0700
@@ -267,6 +267,12 @@
 #endif
 
 
+/* Define if your assembler supports the fildq mnemonic. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_IX86_FILDQ
+#endif
+
+
 /* Define if your assembler supports the sahf mnemonic. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_IX86_SAHF
--- gcc/config/i386/i386.c.fildq	2009-03-30 11:22:03.000000000 -0700
+++ gcc/config/i386/i386.c	2009-04-01 11:35:38.000000000 -0700
@@ -10891,7 +10893,7 @@ print_operand (FILE *file, rtx x, int co
 		{
 		  if (MEM_P (x))
 		    {
-#ifdef GAS_MNEMONICS
+#if defined (GAS_MNEMONICS) || defined (HAVE_AS_IX86_FILDQ)
 		      putc ('q', file);
 #else
 		      putc ('l', file);
--- gcc/config/i386/i386.md.fildq	2009-03-31 06:33:07.000000000 -0700
+++ gcc/config/i386/i386.md	2009-04-01 11:56:34.000000000 -0700
@@ -28,7 +28,8 @@
 ;;
 ;; The special asm out single letter directives following a '%' are:
 ;; 'z' mov%z1 would be movl, movw, or movb depending on the mode of
-;;     operands[1].
+;;     operands[1].  "movq" is supported only if assembler supports
+;;     "fildq".
 ;; 'L' Print the opcode suffix for a 32-bit integer opcode.
 ;; 'W' Print the opcode suffix for a 16-bit integer opcode.
 ;; 'B' Print the opcode suffix for an 8-bit integer opcode.
--- gcc/configure.ac.fildq	2009-03-31 16:22:20.000000000 -0700
+++ gcc/configure.ac	2009-04-01 10:56:41.000000000 -0700
@@ -2949,6 +2949,12 @@ foo:	nop
       [AC_DEFINE(HAVE_AS_IX86_SAHF, 1,
         [Define if your assembler supports the sahf mnemonic.])])
 
+    gcc_GAS_CHECK_FEATURE([fildq mnemonic],
+      gcc_cv_as_ix86_fildq,,,
+      [fildq (%eax)],,
+      [AC_DEFINE(HAVE_AS_IX86_FILDQ, 1,
+        [Define if your assembler supports the fildq mnemonic.])])
+
     gcc_GAS_CHECK_FEATURE([different section symbol subtraction],
       gcc_cv_as_ix86_diff_sect_delta,,,
       [.section .rodata
--- gcc/configure.fildq	2009-03-31 16:22:20.000000000 -0700
+++ gcc/configure	2009-04-01 10:57:18.000000000 -0700
@@ -22761,6 +22761,39 @@ _ACEOF
 
 fi
 
+    echo "$as_me:$LINENO: checking assembler for fildq mnemonic" >&5
+echo $ECHO_N "checking assembler for fildq mnemonic... $ECHO_C" >&6
+if test "${gcc_cv_as_ix86_fildq+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  gcc_cv_as_ix86_fildq=no
+  if test x$gcc_cv_as != x; then
+    echo 'fildq (%eax)' > 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_fildq=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_fildq" >&5
+echo "${ECHO_T}$gcc_cv_as_ix86_fildq" >&6
+if test $gcc_cv_as_ix86_fildq = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_AS_IX86_FILDQ 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
--- gcc/testsuite/gcc.target/i386/fildq.c.fildq	2009-04-01 11:52:37.000000000 -0700
+++ gcc/testsuite/gcc.target/i386/fildq.c	2009-04-01 11:32:19.000000000 -0700
@@ -0,0 +1,9 @@
+/* { dg-do assemble } */
+/* { dg-require-effective-target fildq } */
+/* { dg-options "-O0 -mfpmath=387" } */
+
+double
+foo (long long x)
+{
+  return (double) x;
+}
--- gcc/testsuite/gcc.target/i386/pr39590.c.fildq	2009-04-01 11:52:42.000000000 -0700
+++ gcc/testsuite/gcc.target/i386/pr39590.c	2009-04-01 11:51:37.000000000 -0700
@@ -0,0 +1,11 @@
+/* { dg-do assemble } */
+/* { dg-require-effective-target fildq } */
+/* { dg-options "-O2" } */
+
+extern __SIZE_TYPE__ foo;
+
+void
+bar ()
+{
+  asm volatile ("add%z0 %1, %0": "+m" (foo): "ir" (23));
+}
--- gcc/testsuite/lib/target-supports.exp.fildq	2009-03-31 16:22:19.000000000 -0700
+++ gcc/testsuite/lib/target-supports.exp	2009-04-01 11:29:52.000000000 -0700
@@ -2802,6 +2802,17 @@ proc check_effective_target_avx { } {
     } "-O2 -mavx" ]
 }
 
+# Return 1 if fildq instruction can be assembled.
+
+proc check_effective_target_fildq { } {
+    return [check_no_compiler_messages fildq object {
+	double fildq (long long x)
+	{
+	  return (double) x;
+	}
+    } "-O0 -mfpmath=387" ]
+}
+
 # Return 1 if C wchar_t type is compatible with char16_t.
 
 proc check_effective_target_wchar_t_char16_t_compatible { } {


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