add alignment to enable store merging in strict-alignment targets
[official-gcc.git] / gcc / testsuite / g++.dg / pr80481.C
blob78c463b8e3b58b00428d815ffd93c79eb096802c
1 // { dg-do compile { target { i?86-*-* x86_64-*-* }  && { ! *-*-solaris* } } }
2 // { dg-options "-Ofast -funroll-loops -fopenmp -march=knl" }
3 // Disabling epilogues until we find a better way to deal with scans.
4 // { dg-additional-options "--param vect-epilogues-nomask=0" }
7 #include <math.h>
9 #include <xmmintrin.h>
11 #define max(a, b)   ( (a) > (b) ? (a) : (b) )
13 struct Sdata {
14   float w; 
15   float s;
16   float r;
17   float t;
18   float v;
20  extern int N1, N2, N3;
22 #define func(p, up, down) ((p)*(up) + (1.0f-(p)) * (down))
24 void foo (Sdata *in, int idx, float *out)
26   float* y1 = (float*)_mm_malloc(sizeof(float) * N1,16);
27   float* y2  = (float*)_mm_malloc(sizeof(float) * N1,16);
28   float* y3  = (float*)_mm_malloc(sizeof(float) * N1,16);
29   float* y4  = (float*)_mm_malloc(sizeof(float) * N1,16); 
31   for (int k = idx; k < idx + N3; k++) {
32     float x1 = in[k].r;
33     float x2    = in[k].s;
34     float x3      = in[k].w;
35     float x4     = in[k].v;
36     float x5         = in[k].t;
37     x5 /= N2;
38     float u = exp(x4 * sqrt(x5));
39     float d = exp(-x4 * sqrt(x5));
40     float a = exp(x1 * x5);
41     float m = exp(-x1 * x5);
42     float p = (a - d) / (u - d);
43     y2[0] = x2;
44     y3[0] = float(1.f);
45     for (int i = 1; i <= N2; i++) {
46       y2[i] = u * y2[i - 1];
47       y3[i] = d * y3[i - 1];
48     }
49 #pragma omp simd
50     for (int i = 0; i <= N2; i++) {
51       y1[i] =
52         max((x3 - y2[N2 - i] * y3[i]), float(0.f));
53     }
54     for (int i = N2 - 1; i >= 0; i--) {
55 #pragma omp simd
56       for (int j = 0; j <= i; j++) {
57         y4[j] = func(p,y1[j],y1[j+1]) * m;
58       }
59 #pragma omp simd
60       for (int j = 0; j <= i; j++) {
61         float t1 = y2[i - j] * y3[j];
62         float t2 = max(x3 - t1, float(0.f));
63         y1[j] = max(t2, y4[j]);
64       }
65     }
66     out[k] = y1[0];
67   }
68   _mm_free(y1);
69   _mm_free(y2);
70   _mm_free(y3);
71   _mm_free(y4);
74 // { dg-final { scan-assembler-not "vmovaps\[^\n\r]*zmm\[0-9]+,\[^\n\r]*zmm\[0-9]+" } }