1 /* { dg-do run } */
2 /* { dg-options "-O2 -ffast-math -mfpmath=sse -mavx2 -ftree-vectorize" } */
3 /* { dg-require-effective-target avx2 } */
4
5 #include "avx2-check.h"
6
7 extern void abort (void);
8
9 int l;
10
11 static void __attribute__((noclone,noinline))
test1(double * in1,double * in2,double * out,int l1,int l2,int * n)12 test1 (double *in1, double *in2, double *out,
13 int l1, int l2, int *n)
14 {
15 double sum;
16 int na = n[0];
17 int nb = n[1];
18 int i;
19 _Bool ic, jc;
20
21 jc = (l > na) && (l > nb);
22 for (int i = 0; i < l2; i++)
23 {
24 ic = (i <= na) && (i <= nb);
25 sum = 0;
26 if (ic && jc)
27 sum = in1[i] + in2[i];
28 out[i] = sum;
29 }
30 }
31
32 static void
avx2_test(void)33 avx2_test (void)
34 {
35 double in1[40], in2[40], out[40], sum;
36 int n[2],l1,l2,i,na,nb;
37 _Bool ic, jc;
38
39 l = 0;
40 l1 = 8;
41 l2 = 40;
42 n[0] = 14;
43 n[1] = 13;
44
45 for (i = 0; i < l2; i++)
46 {
47 in1[i] = i;
48 in2[i] = i;
49 out[i] = 0;
50 }
51
52 test1 (in1, in2, out, l1, l2, n);
53
54 na = n[0];
55 nb = n[1];
56
57 jc = (l > na) && (l > nb);
58 for (int i = 0; i < l2; i++)
59 {
60 ic = (i <= na) && (i <= nb);
61 sum = 0;
62 if (ic && jc)
63 sum = in1[i] + in2[i];
64 if (out[i] != sum)
65 abort ();
66 }
67 }
68