summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2005-06-28 17:32:25 -0700
committerRichard Henderson <rth@gcc.gnu.org>2005-06-28 17:32:25 -0700
commit6283ba266f3f633712cfdf2ebe68010f2187513a (patch)
treeda67355587399ea84200b3dbdbc8ce925675704f /gcc
parenta415a2505de0a3858eeab1c57bb31cae49069a15 (diff)
downloadgcc-6283ba266f3f633712cfdf2ebe68010f2187513a.tar.gz
ia64.c (ia64_expand_vecint_compare): Decompose to EQ when using psubN.uuu.
* config/ia64/ia64.c (ia64_expand_vecint_compare): Decompose to EQ when using psubN.uuu. From-SVN: r101405
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/ia64/ia64.c15
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-7.c76
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-8.c76
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-9.c76
5 files changed, 243 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c494bc1ea28..bd0a65ca5fd 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 0ece66300ca..85d0bd22cd8 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -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
index 00000000000..a7329df14b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-7.c
@@ -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
index 00000000000..090b1c67fbd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-8.c
@@ -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
index 00000000000..5b89289a7ee
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-9.c
@@ -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;
+}