Fix test-suite fallout of default -Wreturn-type.
[official-gcc.git] / gcc / testsuite / g++.dg / vect / pr70729.cc
blobeac4b4bd75c21dddc4280d76080be0f8d1e5648a
1 // { dg-do compile }
2 // { dg-additional-options "-ffast-math -fopenmp-simd" }
3 // { dg-additional-options "-msse2" { target x86_64-*-* i?86-*-* } }
5 inline void* my_alloc (__SIZE_TYPE__ bytes) {void *ptr; __builtin_posix_memalign (&ptr, bytes, 128); return 0; }
6 inline void my_free (void* memory) {__builtin_free (memory);}
8 template <typename T>
9 class Vec
11 const int isize;
12 T* data;
14 public:
16 Vec (int n) : isize (n) {data = (T*)my_alloc (isize*sizeof (T));}
17 ~Vec () {my_free(data);}
19 Vec& operator = (const Vec& other)
21 if (this != &other)
22 __builtin_memcpy (data, other.data, isize*sizeof (T));
23 return *this;
26 T& operator [] (int i) {return data[i];}
27 const T& operator [] (int i) const {return data[i];}
28 T& at (int i) {return data[i];}
29 const T& at (int i) const {return data[i];}
31 operator T* () {return data;}
32 int size () const {return isize;}
35 template <typename T>
36 class Cl
38 public:
40 Cl (int n, int m);
41 const int N, M;
42 Vec<T> v_x, v_y;
43 Vec<int> v_i;
44 Vec<float> v_z;
47 struct Ss
49 const int S_n, S_m;
50 Cl<float> v1;
51 float* C1;
52 float* C2;
53 Ss (int n1, int n2): S_n(n1), S_m(n2), v1(n1, n2)
55 C1 = new float[n1 * 3];
56 C2 = new float[n2 * 4];
59 ~Ss () { delete C1; delete C2;}
60 void foo (float *in, float w);
62 void Ss::foo (float *in, float w)
64 #pragma omp simd
65 for (int i = 0; i < S_n; i++)
67 float w1 = C2[S_n + i] * w;
68 v1.v_i[i] += (int)w1;
69 C1[S_n + i] += w1;
73 // { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { target x86_64-*-* i?86-*-* } } }