[PATCH] Fix i386 clearing of MMX register

Jakub Jelinek jakub@redhat.com
Mon Oct 3 22:46:00 GMT 2005


Hi!

The following testcase results in invalid assembly on 4.0 branch.
        movl    $0, %mm0
is not a valid insn.  The problem is that type attribute got out of
sync with the output code in movsi_1 and movdi_1_rex64 instructions.
For *y, C alternative (alt 2 in movsi_1) it defines type to "mmx",
but then expects mmxadd:
    case TYPE_MMXADD:
      return "pxor\t%0, %0";
Either it should be consistently mmxadd, or mmx.
On HEAD, the testcase doesn't trigger, but that's just because of different
insn choice, the backend bug is still there.

Ok for HEAD/4.0 if testing succeeds?

2005-10-04  Jakub Jelinek  <jakub@redhat.com>

	* config/i386/i386.md (movsi_1, movdi_1_rex64): Use mmxadd type
	for setting MMX register to 0 rather than mmx.

	* g++.dg/opt/mmx2.C: New test.

--- gcc/config/i386/i386.md.jj	2005-09-28 21:12:50.000000000 +0200
+++ gcc/config/i386/i386.md	2005-10-04 00:12:50.000000000 +0200
@@ -1174,7 +1174,7 @@
 }
   [(set (attr "type")
      (cond [(eq_attr "alternative" "2")
-	      (const_string "mmx")
+	      (const_string "mmxadd")
 	    (eq_attr "alternative" "3,4,5")
 	      (const_string "mmxmov")
 	    (eq_attr "alternative" "6")
@@ -1980,7 +1980,7 @@
 }
   [(set (attr "type")
      (cond [(eq_attr "alternative" "5")
-	      (const_string "mmx")
+	      (const_string "mmxadd")
 	    (eq_attr "alternative" "6,7,8")
 	      (const_string "mmxmov")
 	    (eq_attr "alternative" "9")
--- gcc/testsuite/g++.dg/opt/mmx2.C.jj	2005-10-04 00:19:27.000000000 +0200
+++ gcc/testsuite/g++.dg/opt/mmx2.C	2005-10-04 00:35:47.000000000 +0200
@@ -0,0 +1,22 @@
+// { dg-do link { target i?86-*-* x86_64-*-* } }
+// { dg-options "-O2 -mmmx" }
+
+#include <mmintrin.h>
+
+static union u { __m64 m; long long l; } u;
+extern "C" void abort (void);
+
+__attribute__((noinline))
+void bar (__m64 x)
+{
+  u.m = x;
+}
+
+int
+main ()
+{
+  bar (_mm_set_pi32 (0x000000FF,0xFFFF00FF));
+  if (u.l != 0xffffff00ffLL)
+    abort ();
+  return 0;
+}

	Jakub



More information about the Gcc-patches mailing list