| 1 |
// PR/99728 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-O2 -fdump-tree-lim2-details -w -Wno-psabi" } |
| 4 |
|
| 5 |
typedef double __m256d __attribute__((vector_size(sizeof (double) * 4))); |
| 6 |
extern __inline __m256d __attribute__((__gnu_inline__, __always_inline__, __artificial__)) |
| 7 |
_mm256_set1_pd (double __A) |
| 8 |
{ |
| 9 |
return __extension__ (__m256d){ __A, __A, __A, __A }; |
| 10 |
} |
| 11 |
|
| 12 |
// simple OO wrapper around __m256d |
| 13 |
struct Tvsimple |
| 14 |
{ |
| 15 |
__m256d v; |
| 16 |
Tvsimple &operator+=(const Tvsimple &other) {v+=other.v; return *this;} |
| 17 |
Tvsimple operator*(double val) const { Tvsimple res; res.v = v*_mm256_set1_pd(val); return res;} |
| 18 |
Tvsimple operator*(Tvsimple val) const { Tvsimple res; res.v = v*val.v; return res; } |
| 19 |
Tvsimple operator+(Tvsimple val) const { Tvsimple res; res.v = v+val.v; return res; } |
| 20 |
Tvsimple operator+(double val) const { Tvsimple res; res.v = v+_mm256_set1_pd(val); return res;} |
| 21 |
}; |
| 22 |
|
| 23 |
template<typename vtype> struct s0data_s |
| 24 |
{ vtype sth, corfac, scale, lam1, lam2, csq, p1r, p1i, p2r, p2i; }; |
| 25 |
|
| 26 |
template<typename vtype> void foo(s0data_s<vtype> & __restrict__ d, |
| 27 |
const double * __restrict__ coef, const double * __restrict__ alm, |
| 28 |
unsigned long l, unsigned long il, unsigned long lmax) |
| 29 |
{ |
| 30 |
// critical loop |
| 31 |
while (l<=lmax) |
| 32 |
{ |
| 33 |
d.p1r += d.lam2*alm[2*l]; |
| 34 |
d.p1i += d.lam2*alm[2*l+1]; |
| 35 |
d.p2r += d.lam2*alm[2*l+2]; |
| 36 |
d.p2i += d.lam2*alm[2*l+3]; |
| 37 |
Tvsimple tmp = d.lam2*(d.csq*coef[2*il] + coef[2*il+1]) + d.lam1; |
| 38 |
d.lam1 = d.lam2; |
| 39 |
d.lam2 = tmp; |
| 40 |
++il; l+=2; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
// this version has dead stores at the end of the loop |
| 45 |
template void foo<>(s0data_s<Tvsimple> & __restrict__ d, |
| 46 |
const double * __restrict__ coef, const double * __restrict__ alm, |
| 47 |
unsigned long l, unsigned long il, unsigned long lmax); |
| 48 |
|
| 49 |
// The aggregate copy in the IL should not prevent all store-motion |
| 50 |
// { dg-final { scan-tree-dump-times "Executing store motion" 4 "lim2" } } |