aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/pr64844.c
blob: cd3eacd99aa2f6d586d08fb54967c3b8e07c4d88 (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
40
41
42
43
44
45
46
47
48
49
50
/* { dg-require-effective-target vect_double } */
/* { dg-additional-options "-ffast-math" } */

#include "tree-vect.h"

extern void abort (void);

typedef __SIZE_TYPE__ size_t;

static double
compute(size_t n, double const * __restrict a, double const * __restrict b)
{
  double res = 0.0;
  size_t i;
  for (i = 0; i < n; ++i)
    res += a[i] + b[i];
  return res;
}

void init(double *, double *);

int
main()
{
  double ary1[1024];
  double ary2[1024];
  size_t i;

  check_vect ();

  // Initialize arrays
  for (i = 0; i < 1024; ++i)
    {
      ary1[i] = 1 / (double)(i + 1);
      ary2[i] = 1 + 1 / (double) (i + 1);
      __asm__ volatile ("" : : : "memory");
    }

  // Compute two results using different starting elements
  if ((int) compute (512, &ary1[0], &ary2[0]) != 525
      || (int) compute(512, &ary1[1], &ary2[1]) != 523)
    abort ();

  return 0;
}

/* All targets should allow vectorizing this by some means of
   dealing with the known misalignment in loop 2.  */

/* { dg-final { scan-tree-dump-times "loop vectorized" 2 "vect" } } */