Debian Codegraph @

gcc/testsuite/g++.dg/vect/pr70729-nest.cc

raw
1 // { dg-do compile }
2 // { dg-additional-options "-ffast-math -fopenmp-simd" }
3 // { dg-additional-options "-msse2" { target x86_64-*-* i?86-*-* } }
4
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);}
7 float W[100];
8
9 template <typename T>
10 class Vec
11 {
12 const int isize;
13 T* data;
14
15 public:
16
17 Vec (int n) : isize (n) {data = (T*)my_alloc (isize*sizeof (T));}
18 ~Vec () {my_free(data);}
19
20 Vec& operator = (const Vec& other)
21 {
22 if (this != &other)
23 __builtin_memcpy (data, other.data, isize*sizeof (T));
24 return *this;
25 }
26
27 T& operator [] (int i) {return data[i];}
28 const T& operator [] (int i) const {return data[i];}
29 T& at (int i) {return data[i];}
30 const T& at (int i) const {return data[i];}
31
32 operator T* () {return data;}
33 int size () const {return isize;}
34 };
35
36 template <typename T>
37 class Cl
38 {
39 public:
40
41 Cl (int n, int m);
42 const int N, M;
43 Vec<T> v_x, v_y;
44 Vec<int> v_i;
45 Vec<float> v_z;
46 };
47
48 struct Ss
49 {
50 const int S_n, S_m;
51 Cl<float> v1;
52 float* C1;
53 float* C2;
54 Ss (int n1, int n2): S_n(n1), S_m(n2), v1(n1, n2)
55 {
56 C1 = new float[n1 * 3];
57 C2 = new float[n2 * 4];
58 }
59
60 ~Ss () { delete C1; delete C2;}
61 void foo (int n);
62 };
63 void Ss::foo (int n)
64 {
65 float w;
66 for (int j = 0; j < n; j++)
67 {
68 w = W[j];
69 #pragma omp simd
70 for (int i = 0; i < S_n; i++)
71 {
72 float w1 = C2[S_n + i] * w;
73 v1.v_i[i] += (int)w1;
74 C1[S_n + i] += w1;
75 }
76 }
77 }
78
79 // { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" { xfail *-*-* } } }