]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Improve gcc.dg/vect/bb-slp-32.c testcase
authorRichard Biener <rguenther@suse.de>
Wed, 19 Jun 2024 09:39:51 +0000 (11:39 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 19 Jun 2024 09:41:18 +0000 (11:41 +0200)
The following adds a correctness check to the combined store/reduce
vectorization.

* gcc.dg/vect/bb-slp-32.c: Add check for correctness.

gcc/testsuite/gcc.dg/vect/bb-slp-32.c

index f10442e6d56855ed65146896ea7bfa26a3691ad3..4f72727b6948c904dfa317c6a341c559bd0d1237 100644 (file)
@@ -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;
+}