From 69e69c01e715cf576c55d03214cd1f85d7e9c598 Mon Sep 17 00:00:00 2001 From: Alan Lawrence Date: Mon, 22 Sep 2014 16:36:06 +0000 Subject: [PATCH] [Testsuite] Add tests of reductions using whole-vector-shifts (ior) * gcc.dg/vect/vect-reduc-or_1.c: New test. * gcc.dg/vect/vect-reduc-or_2.c: New test. From-SVN: r215475 --- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/vect/vect-reduc-or_1.c | 35 +++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/vect-reduc-or_2.c | 31 ++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-reduc-or_1.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-reduc-or_2.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 92efa6efddd..efbb084ddb7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-22 Alan Lawrence + + * gcc.dg/vect/vect-reduc-or_1.c: New test. + * gcc.dg/vect/vect-reduc-or_2.c: Likewise. + 2014-09-22 Alan Lawrence * lib/target-supports.exp (check_effective_target_whole_vector_shift): diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-or_1.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-or_1.c new file mode 100644 index 00000000000..4e1a8577ce2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-or_1.c @@ -0,0 +1,35 @@ +/* { dg-require-effective-target whole_vector_shift } */ + +/* Write a reduction loop to be reduced using vector shifts. */ + +extern void abort(void); + +unsigned char in[16] __attribute__((__aligned__(16))); + +int +main (unsigned char argc, char **argv) +{ + unsigned char i = 0; + unsigned char sum = 1; + + for (i = 0; i < 16; i++) + in[i] = (i + i + 1) & 0xfd; + + /* Prevent constant propagation of the entire loop below. */ + asm volatile ("" : : : "memory"); + + for (i = 0; i < 16; i++) + sum |= in[i]; + + if (sum != 29) + { + __builtin_printf("Failed %d\n", sum); + abort(); + } + + return 0; +} + +/* { dg-final { scan-tree-dump "Reduce using vector shifts" "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-or_2.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-or_2.c new file mode 100644 index 00000000000..e25467e5922 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-or_2.c @@ -0,0 +1,31 @@ +/* { dg-require-effective-target whole_vector_shift } */ + +/* Write a reduction loop to be reduced using vector shifts and folded. */ + +extern void abort(void); + +int +main (unsigned char argc, char **argv) +{ + unsigned char in[16] __attribute__((aligned(16))); + unsigned char i = 0; + unsigned char sum = 1; + + for (i = 0; i < 16; i++) + in[i] = (i + i + 1) & 0xfd; + + for (i = 0; i < 16; i++) + sum |= in[i]; + + if (sum != 29) + { + __builtin_printf("Failed %d\n", sum); + abort(); + } + + return 0; +} + +/* { dg-final { scan-tree-dump "Reduce using vector shifts" "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ + -- 2.30.2