summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/aarch64/sve_slp_7_run.c
blob: 5a8bf99bc5bdf6f16aa3577291403b5bde90698d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* { dg-do run { target aarch64_sve_hw } } */
/* { dg-options "-O2 -ftree-vectorize -march=armv8-a+sve -ffast-math" } */

#include "sve_slp_7.c"

#define N (54 * 4)

#define HARNESS(TYPE)							\
  {									\
    TYPE a[N], b[4] = { 40, 22, 75, 19 };				\
    for (unsigned int i = 0; i < N; ++i)				\
      {									\
	a[i] = i * 2 + i % 5;						\
	asm volatile ("" ::: "memory");					\
      }									\
    vec_slp_##TYPE (a, b, N / 4);					\
    TYPE x0 = 40;							\
    TYPE x1 = 22;							\
    TYPE x2 = 75;							\
    TYPE x3 = 19;							\
    for (unsigned int i = 0; i < N; i += 4)				\
      {									\
	x0 += a[i];							\
	x1 += a[i + 1];							\
	x2 += a[i + 2];							\
	x3 += a[i + 3];							\
	asm volatile ("" ::: "memory");					\
      }									\
    /* _Float16 isn't precise enough for this.  */			\
    if ((TYPE) 0x1000 + 1 != (TYPE) 0x1000				\
	&& (x0 != b[0] || x1 != b[1] || x2 != b[2] || x3 != b[3]))	\
      __builtin_abort ();						\
  }

int __attribute__ ((optimize (1)))
main (void)
{
  TEST_ALL (HARNESS)
}