OSDN Git Service

* config/h8300/h8300.c (output_logical_op): Use 'not.w' instead
authorkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 Jan 2002 00:50:50 +0000 (00:50 +0000)
committerkazu <kazu@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 4 Jan 2002 00:50:50 +0000 (00:50 +0000)
of 'neg.w' when xoring with 0x0000ffff or 0xffff0000.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48524 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/h8300/h8300.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/20020103-1.c [new file with mode: 0644]

index 7a81576..7283a0c 100644 (file)
@@ -1,3 +1,8 @@
+2002-01-03  Kazu Hirata  <kazu@hxi.com>
+
+       * config/h8300/h8300.c (output_logical_op): Use 'not.w' instead
+       of 'neg.w' when xoring with 0x0000ffff or 0xffff0000.
+
 2002-01-03  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * cpperror.c: Update comments and copyright.
index 2a0e260..3a5832e 100644 (file)
@@ -1681,7 +1681,7 @@ output_logical_op (mode, code, operands)
       /* First, see if we can finish with one insn.
 
         If code is either AND or XOR, we exclude two special cases,
-        0xffffff00 and 0xffff00ff, because insns like sub.w or neg.w
+        0xffffff00 and 0xffff00ff, because insns like sub.w or not.w
         can do a better job.  */
       if ((TARGET_H8300H || TARGET_H8300S)
          && ((det & 0x0000ffff) != 0)
@@ -1704,7 +1704,7 @@ output_logical_op (mode, code, operands)
              && ((det & 0x0000ffff) == 0x0000ffff)
              && code != IOR)
            output_asm_insn ((code == AND)
-                            ? "sub.w\t%f0,%f0" : "neg.w\t%f0",
+                            ? "sub.w\t%f0,%f0" : "not.w\t%f0",
                             operands);
          else if ((TARGET_H8300H || TARGET_H8300S)
                   && ((det & 0x000000ff) != 0)
@@ -1731,7 +1731,7 @@ output_logical_op (mode, code, operands)
              && ((det & 0xffff0000) == 0xffff0000)
              && code != IOR)
            output_asm_insn ((code == AND)
-                            ? "sub.w\t%e0,%e0" : "neg.w\t%e0",
+                            ? "sub.w\t%e0,%e0" : "not.w\t%e0",
                             operands);
          else if (TARGET_H8300H || TARGET_H8300S)
            {
index 1838539..ad7b553 100644 (file)
@@ -1,3 +1,7 @@
+2002-01-03  Kazu Hirata  <kazu@hxi.com>
+
+       * gcc.c-torture/execute/20020103-1.c: New test.
+
 2002-01-03  Jakub Jelinek  <jakub@redhat.com>
 
        * g++.dg/other/debug2.C: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/20020103-1.c b/gcc/testsuite/gcc.c-torture/execute/20020103-1.c
new file mode 100644 (file)
index 0000000..c010aea
--- /dev/null
@@ -0,0 +1,28 @@
+/* On h8300 port, the following used to be broken with -mh or -ms.  */
+
+extern void abort (void);
+extern void exit (int);
+
+unsigned long
+foo (unsigned long a)
+{
+  return a ^ 0x0000ffff;
+}
+
+unsigned long
+bar (unsigned long a)
+{
+  return a ^ 0xffff0000;
+}
+
+int
+main ()
+{
+  if (foo (0) != 0x0000ffff)
+    abort ();
+
+  if (bar (0) != 0xffff0000)
+    abort ();
+
+  exit (0);
+}