diff mbox

[8/14,Testsuite] Add tests of reductions using whole-vector-shifts (ior)

Message ID 541ACF23.3050602@arm.com
State New
Headers show

Commit Message

Alan Lawrence Sept. 18, 2014, 12:25 p.m. UTC
These are like the previous patch, but using | rather than * - I was unable to 
get the previous test to pass on PowerPC and MIPS.

I note there is no inherent vector operation here - a bitwise OR across a word, 
and a "reduction via shifts" using scalar (not vector) ops would be all that's 
necessary. However, GCC doesn't exploit this possibility at present, and I don't 
have any plans at present to add such myself.

Passing on x86_64-linux-gnu, aarch64-none-elf, aarch64_be-none-elf, arm-none-eabi.
The 'scan-tree-dump' part passes on mips64 and powerpc (although the latter is 
disabled as check_effective_target_whole_vector_shift gives 0, as per previous 
patch)

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/vect-reduc-or_1.c: New test.
	* gcc.dg/vect/vect-reduc-or_2.c: Likewise.

Comments

Richard Biener Sept. 22, 2014, 10:42 a.m. UTC | #1
On Thu, Sep 18, 2014 at 2:25 PM, Alan Lawrence <alan.lawrence@arm.com> wrote:
> These are like the previous patch, but using | rather than * - I was unable
> to get the previous test to pass on PowerPC and MIPS.
>
> I note there is no inherent vector operation here - a bitwise OR across a
> word, and a "reduction via shifts" using scalar (not vector) ops would be
> all that's necessary. However, GCC doesn't exploit this possibility at
> present, and I don't have any plans at present to add such myself.
>
> Passing on x86_64-linux-gnu, aarch64-none-elf, aarch64_be-none-elf,
> arm-none-eabi.
> The 'scan-tree-dump' part passes on mips64 and powerpc (although the latter
> is disabled as check_effective_target_whole_vector_shift gives 0, as per
> previous patch)

Ok.

Thanks,
Richard.

> gcc/testsuite/ChangeLog:
>
>         * gcc.dg/vect/vect-reduc-or_1.c: New test.
>         * gcc.dg/vect/vect-reduc-or_2.c: Likewise.
diff mbox

Patch

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 0000000000000000000000000000000000000000..4e1a8577ce21aad539fca7cf07700b99575dfab0
--- /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 0000000000000000000000000000000000000000..e25467e59221adc09cbe0bb7548842902a4bf6da
--- /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" } } */
+