gcc/testsuite/ 2014-12-04 Yvan Roux <yvan.roux@linaro.org>
authoryroux <yroux@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Dec 2014 14:07:03 +0000 (14:07 +0000)
committerDongkyun, Son <dongkyun.s@samsung.com>
Sat, 6 Jun 2015 14:26:52 +0000 (23:26 +0900)
Backport from trunk r215473.
2014-09-22  Alan Lawrence  <alan.lawrence@arm.com>

* lib/target-supports.exp (check_effective_target_whole_vector_shift):
New.

* gcc.dg/vect/vect-reduc-mul_1.c: New test.
* gcc.dg/vect/vect-reduc-mul_2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro/gcc-4_9-branch@218366 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/testsuite/ChangeLog.linaro
gcc/testsuite/gcc.dg/vect/vect-reduc-mul_1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-reduc-mul_2.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp

index 91edde1..3a01dfb 100644 (file)
@@ -1,5 +1,16 @@
 2014-12-04  Yvan Roux  <yvan.roux@linaro.org>
 
+       Backport from trunk r215473.
+       2014-09-22  Alan Lawrence  <alan.lawrence@arm.com>
+
+       * lib/target-supports.exp (check_effective_target_whole_vector_shift):
+       New.
+
+       * gcc.dg/vect/vect-reduc-mul_1.c: New test.
+       * gcc.dg/vect/vect-reduc-mul_2.c: New test.
+
+2014-12-04  Yvan Roux  <yvan.roux@linaro.org>
+
        Backport from trunk r215177.
        2014-09-11  Alan Lawrence  <alan.lawrence@arm.com>
 
diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-mul_1.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-mul_1.c
new file mode 100644 (file)
index 0000000..44f026f
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-require-effective-target vect_int_mult } */
+/* { 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];
+
+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;
+
+  /* Prevent constant propagation of the entire loop below.  */
+  asm volatile ("" : : : "memory");
+
+  for (i = 0; i < 16; i++)
+    sum *= in[i];
+
+  if (sum != 33)
+    {
+      __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-mul_2.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-mul_2.c
new file mode 100644 (file)
index 0000000..414fba7
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-require-effective-target vect_int_mult } */
+/* { 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];
+  unsigned char i = 0;
+  unsigned char sum = 1;
+
+  for (i = 0; i < 16; i++)
+    in[i] = i + i + 1;
+
+  for (i = 0; i < 16; i++)
+    sum *= in[i];
+
+  if (sum != 33)
+    {
+      __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" } } */
+
index 7c011de..c46949c 100644 (file)
@@ -3324,6 +3324,22 @@ proc check_effective_target_vect_shift { } {
     return $et_vect_shift_saved
 }
 
+proc check_effective_target_whole_vector_shift { } {
+    if { [istarget x86_64-*-*]
+        || [istarget ia64-*-*]
+        || ([check_effective_target_arm32]
+            && [check_effective_target_arm_little_endian])
+        || ([istarget mips*-*-*]
+            && [check_effective_target_mips_loongson]) } {
+       set answer 1
+    } else {
+       set answer 0
+    }
+
+    verbose "check_effective_target_vect_long: returning $answer" 2
+    return $answer
+}
+
 # Return 1 if the target supports vector bswap operations.
 
 proc check_effective_target_vect_bswap { } {