| 1 |
/* PR66119 - MOVE_RATIO is not constant in a compiler run, so Scalar |
| 2 |
Reduction of Aggregates must ask the back-end more than once what |
| 3 |
the value of MOVE_RATIO now is. */ |
| 4 |
|
| 5 |
/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && c++11 } } } */ |
| 6 |
/* { dg-options "-O3 -mavx -fdump-tree-sra -march=slm -mtune=slm -fno-early-inlining" } */ |
| 7 |
// { dg-skip-if "requires hosted libstdc++ for cstdlib malloc" { ! hostedlib } } |
| 8 |
|
| 9 |
#include <immintrin.h> |
| 10 |
|
| 11 |
class MyAVX |
| 12 |
{ |
| 13 |
__m256d data; |
| 14 |
public: |
| 15 |
MyAVX () = default; |
| 16 |
MyAVX (const MyAVX &) = default; |
| 17 |
MyAVX (__m256d _data) : data(_data) { ; } |
| 18 |
|
| 19 |
MyAVX & operator= (const MyAVX &) = default; |
| 20 |
|
| 21 |
operator __m256d () const { return data; } |
| 22 |
MyAVX operator+ (MyAVX s2) { return data+s2.data; } |
| 23 |
}; |
| 24 |
|
| 25 |
template <typename T> class AVX_trait { ; }; |
| 26 |
|
| 27 |
template <> class AVX_trait<double> { |
| 28 |
public: |
| 29 |
typedef __m256d TSIMD; |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
template <typename T> |
| 34 |
class MyTSIMD |
| 35 |
{ |
| 36 |
typename AVX_trait<T>::TSIMD data; |
| 37 |
|
| 38 |
public: |
| 39 |
MyTSIMD () = default; |
| 40 |
MyTSIMD (const MyTSIMD &) = default; |
| 41 |
// MyTSIMD (const MyTSIMD & s2) : data(s2.data) { ; } |
| 42 |
MyTSIMD (typename AVX_trait<T>::TSIMD _data) : data(_data) { ; } |
| 43 |
|
| 44 |
operator typename AVX_trait<T>::TSIMD() const { return data; } |
| 45 |
MyTSIMD operator+ (MyTSIMD s2) { return data+s2.data; } |
| 46 |
}; |
| 47 |
|
| 48 |
// using MyVec = MyAVX; |
| 49 |
using MyVec = MyTSIMD<double>; |
| 50 |
|
| 51 |
class Vec2 |
| 52 |
{ |
| 53 |
MyVec a, b; |
| 54 |
public: |
| 55 |
Vec2 (MyVec aa, MyVec ab) : a(aa), b(ab) { ; } |
| 56 |
Vec2 operator+ (Vec2 v2) { return Vec2(a+v2.a, b+v2.b); } |
| 57 |
}; |
| 58 |
|
| 59 |
inline __attribute__ ((__always_inline__)) |
| 60 |
Vec2 ComputeSomething (Vec2 a, Vec2 b) |
| 61 |
{ |
| 62 |
return a+b; |
| 63 |
} |
| 64 |
|
| 65 |
Vec2 TestFunction (Vec2 a, Vec2 b) |
| 66 |
{ |
| 67 |
return ComputeSomething (a,b); |
| 68 |
} |
| 69 |
|
| 70 |
/* { dg-final { scan-tree-dump "Created a replacement for b" "sra" } } */ |