summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/pr68956.c
blob: 4fb2ced9dac85c6873ff0d45c88b312d8a26c047 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* { dg-do run } */
/* { dg-options "-O2 -ffast-math -mfpmath=sse -mavx2 -ftree-vectorize" } */
/* { dg-require-effective-target avx2 } */

#include "avx2-check.h"

extern void abort (void);

int l;

static void __attribute__((noclone,noinline))
test1 (double *in1, double *in2, double *out,
       int l1, int l2, int *n)
{
  double sum;
  int na = n[0];
  int nb = n[1];
  int i;
  _Bool ic, jc;

  jc = (l > na) && (l > nb);
  for (int i = 0; i < l2; i++)
    {
      ic = (i <= na) && (i <= nb);
      sum = 0;
      if (ic && jc)
	sum = in1[i] + in2[i];
      out[i] = sum;
    }
}

static void
avx2_test (void)
{
  double in1[40], in2[40], out[40], sum;
  int n[2],l1,l2,i,na,nb;
  _Bool ic, jc;

  l = 0;
  l1 = 8;
  l2 = 40;
  n[0] = 14;
  n[1] = 13;

  for (i = 0; i < l2; i++)
    {
      in1[i] = i;
      in2[i] = i;
      out[i] = 0;
    }

  test1 (in1, in2, out, l1, l2, n);

  na = n[0];
  nb = n[1];

  jc = (l > na) && (l > nb);
  for (int i = 0; i < l2; i++)
    {
      ic = (i <= na) && (i <= nb);
      sum = 0;
      if (ic && jc)
	sum = in1[i] + in2[i];
      if (out[i] != sum)
	abort ();
    }
}