OSDN Git Service

* config/ia64/ia64.c (ia64_expand_vecint_compare): Decompose to EQ
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 29 Jun 2005 00:32:25 +0000 (00:32 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 29 Jun 2005 00:32:25 +0000 (00:32 +0000)
        when using psubN.uuu.

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

gcc/ChangeLog
gcc/config/ia64/ia64.c
gcc/testsuite/gcc.dg/vect/vect-reduc-7.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-reduc-8.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-reduc-9.c [new file with mode: 0644]

index c494bc1..bd0a65c 100644 (file)
@@ -1,3 +1,8 @@
+2005-06-28  Richard Henderson  <rth@redhat.com>
+
+       * config/ia64/ia64.c (ia64_expand_vecint_compare): Decompose to EQ
+       when using psubN.uuu.
+
 2005-06-29  Kelley Cook <kcook@gcc.gnu.org>
 
        * doc/gcc.texi: Update FSF address.
index 0ece663..85d0bd2 100644 (file)
@@ -1568,7 +1568,7 @@ ia64_expand_vecint_compare (enum rtx_code code, enum machine_mode mode,
     }
 
   /* Unsigned parallel compare is not supported by the hardware.  Play some
-     tricks to turn this into a GT comparison against 0.  */
+     tricks to turn this into a signed comparison against 0.  */
   if (code == GTU)
     {
       switch (mode)
@@ -1592,6 +1592,10 @@ ia64_expand_vecint_compare (enum rtx_code code, enum machine_mode mode,
               in the sign bit set iff we saw unsigned underflow.  */
            x = gen_reg_rtx (V2SImode);
            emit_insn (gen_xorv2si3 (x, t1, t2));
+
+           code = GT;
+           op0 = x;
+           op1 = CONST0_RTX (mode);
          }
          break;
 
@@ -1601,15 +1605,16 @@ ia64_expand_vecint_compare (enum rtx_code code, enum machine_mode mode,
          x = gen_reg_rtx (mode);
          emit_insn (gen_rtx_SET (VOIDmode, x,
                                  gen_rtx_US_MINUS (mode, op0, op1)));
+
+         code = EQ;
+         op0 = x;
+         op1 = CONST0_RTX (mode);
+         negate = !negate;
          break;
 
        default:
          gcc_unreachable ();
        }
-
-      code = GT;
-      op0 = x;
-      op1 = CONST0_RTX (mode);
     }
 
   x = gen_rtx_fmt_ee (code, mode, op0, op1);
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-7.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-7.c
new file mode 100644 (file)
index 0000000..a7329df
--- /dev/null
@@ -0,0 +1,76 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+
+#define N 32
+
+extern void abort (void);
+typedef unsigned char T;
+
+void
+testmax (const T *c, T init, T result)
+{
+  T lc[N], accum = init;
+  int i;
+
+  __builtin_memcpy (lc, c, sizeof(lc));
+
+  for (i = 0; i < N; i++) {
+    accum = accum < lc[i] ? lc[i] : accum;
+  }
+
+  if (accum != result)
+    abort ();
+}
+
+void
+testmin (const T *c, T init, T result)
+{
+  T lc[N], accum = init;
+  int i;
+
+  __builtin_memcpy (lc, c, sizeof(lc));
+
+  for (i = 0; i < N; i++) {
+    accum = accum > lc[i] ? lc[i] : accum;
+  }
+
+  if (accum != result)
+    abort ();
+}
+
+int main (void)
+{ 
+  static unsigned char const A[N] = {
+    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+    0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+  };
+
+  static unsigned char const B[N] = {
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f
+  };
+
+  static unsigned char const C[N] = {
+    0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
+    0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+  };
+
+  check_vect ();
+  
+  testmin (A, 10, 1);
+  testmin (B, 0x7f, 0x70);
+  testmin (C, 0x7f, 0x09);
+
+  testmax (A, 0, 0x7f);
+  testmax (B, 0, 0x8f);
+  testmax (C, 0, 0xff);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-8.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-8.c
new file mode 100644 (file)
index 0000000..090b1c6
--- /dev/null
@@ -0,0 +1,76 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+
+#define N 32
+
+extern void abort (void);
+typedef signed char T;
+
+void
+testmax (const T *c, T init, T result)
+{
+  T lc[N], accum = init;
+  int i;
+
+  __builtin_memcpy (lc, c, sizeof(lc));
+
+  for (i = 0; i < N; i++) {
+    accum = accum < lc[i] ? lc[i] : accum;
+  }
+
+  if (accum != result)
+    abort ();
+}
+
+void
+testmin (const T *c, T init, T result)
+{
+  T lc[N], accum = init;
+  int i;
+
+  __builtin_memcpy (lc, c, sizeof(lc));
+
+  for (i = 0; i < N; i++) {
+    accum = accum > lc[i] ? lc[i] : accum;
+  }
+
+  if (accum != result)
+    abort ();
+}
+
+int main (void)
+{ 
+  static signed char const A[N] = {
+    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+    0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f
+  };
+
+  static signed char const B[N] = {
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+    0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f
+  };
+
+  static signed char const C[N] = {
+    0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8,
+    0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+    0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+    0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+  };
+
+  check_vect ();
+  
+  testmin (A, 0, 0);
+  testmin (B, 0, 0x80);
+  testmin (C, 0, 0x80);
+
+  testmax (A, 0, 0x7f);
+  testmax (B, 0, 0x7f);
+  testmax (C, 0, 0x77);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-9.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-9.c
new file mode 100644 (file)
index 0000000..5b89289
--- /dev/null
@@ -0,0 +1,76 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+
+#define N 32
+
+extern void abort (void);
+typedef unsigned short T;
+
+void
+testmax (const T *c, T init, T result)
+{
+  T lc[N], accum = init;
+  int i;
+
+  __builtin_memcpy (lc, c, sizeof(lc));
+
+  for (i = 0; i < N; i++) {
+    accum = accum < lc[i] ? lc[i] : accum;
+  }
+
+  if (accum != result)
+    abort ();
+}
+
+void
+testmin (const T *c, T init, T result)
+{
+  T lc[N], accum = init;
+  int i;
+
+  __builtin_memcpy (lc, c, sizeof(lc));
+
+  for (i = 0; i < N; i++) {
+    accum = accum > lc[i] ? lc[i] : accum;
+  }
+
+  if (accum != result)
+    abort ();
+}
+
+int main (void)
+{ 
+  static unsigned short const A[N] = {
+    0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, 0x0008,
+    0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
+    0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
+    0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff
+  };
+
+  static unsigned short const B[N] = {
+    0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
+    0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff,
+    0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
+    0x8008, 0x8009, 0x800a, 0x800b, 0x800c, 0x800d, 0x800e, 0x800f
+  };
+
+  static unsigned short const C[N] = {
+    0xffff, 0xfffe, 0xfffd, 0xfffc, 0xfffb, 0xfffa, 0xfff9, 0xfff8,
+    0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010,
+    0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007,
+    0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700,
+  };
+
+  check_vect ();
+  
+  testmin (A, 10, 1);
+  testmin (B, 0x7fff, 0x7000);
+  testmin (C, 0x7fff, 0x0009);
+
+  testmax (A, 0, 0x7fff);
+  testmax (B, 0, 0x800f);
+  testmax (C, 0, 0xffff);
+
+  return 0;
+}