diff mbox series

Improve gcc.dg/vect/bb-slp-32.c testcase

Message ID 20240619094132.B6BE838845A6@sourceware.org
State New
Headers show
Series Improve gcc.dg/vect/bb-slp-32.c testcase | expand

Commit Message

Richard Biener June 19, 2024, 9:41 a.m. UTC
The following adds a correctness check to the combined store/reduce
vectorization.

Tested on x86_64-unknown-linux-gnu, pushed.

	* gcc.dg/vect/bb-slp-32.c: Add check for correctness.
---
 gcc/testsuite/gcc.dg/vect/bb-slp-32.c | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-32.c b/gcc/testsuite/gcc.dg/vect/bb-slp-32.c
index f10442e6d56..4f72727b694 100644
--- a/gcc/testsuite/gcc.dg/vect/bb-slp-32.c
+++ b/gcc/testsuite/gcc.dg/vect/bb-slp-32.c
@@ -1,14 +1,15 @@ 
-/* { dg-do compile } */
 /* { dg-require-effective-target vect_int } */
 /* { dg-additional-options "-fvect-cost-model=dynamic" } */
 
-void bar (int *);
-int foo (int *p, int a, int b)
+#include "tree-vect.h"
+
+int __attribute__((noipa))
+foo (int * __restrict__ x, int *p, int a, int b)
 {
-  int x[4];
+  p = __builtin_assume_aligned (p, __BIGGEST_ALIGNMENT__);
+  x = __builtin_assume_aligned (x, __BIGGEST_ALIGNMENT__);
   int tem0, tem1, tem2, tem3;
   int sum = 0;
-  p = __builtin_assume_aligned (p, __BIGGEST_ALIGNMENT__);
   tem0 = p[0] + 1 + a;
   sum += tem0;
   x[0] = tem0;
@@ -21,6 +22,19 @@  int foo (int *p, int a, int b)
   tem3 = p[3] + 4 + a;
   sum += tem3;
   x[3] = tem3;
-  bar (x);
   return sum;
 }
+
+int x[4] __attribute__((aligned(__BIGGEST_ALIGNMENT__)));
+int p[4] __attribute__((aligned(__BIGGEST_ALIGNMENT__))) = { 0, 1, 2, 3 };
+
+int main()
+{
+  check_vect ();
+
+  if (foo (x, p, 7, 13) != 56)
+    abort ();
+  if (x[0] != 8 || x[1] != 16 || x[2] != 18 || x[3] != 14)
+    abort ();
+  return 0;
+}