summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/vect-reduc-7.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/vect/vect-reduc-7.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/vect/vect-reduc-7.c')
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-reduc-7.c78
1 files changed, 78 insertions, 0 deletions
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 000000000..a59a24ac7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-7.c
@@ -0,0 +1,78 @@
+/* { dg-require-effective-target vect_int } */
+
+#include "tree-vect.h"
+
+#define N 32
+
+extern void abort (void);
+typedef unsigned char T;
+
+__attribute__ ((noinline)) 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 ();
+}
+
+__attribute__ ((noinline)) 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;
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */