1 /* { dg-do run } */
2 /* { dg-require-effective-target avx512f_runtime } */
3 /* { dg-options "-O2 -mavx512f -ffast-math -fdump-tree-reassoc1" } */
4 
5 /* To test reassoc can undistribute vector bit_field_ref on multiple
6    vector machine modes, bypass those modes with only one candidate.
7 
8    v1, v2 of type vector 4 x float
9    v3     of type vector 8 x float
10    v5, v6 of type vector 16 x float
11 
12    reassoc transforms
13 
14      accumulator  +=  v1[0]  + v1[1]  + v1[2]  + v1[3]  +
15                       v2[0]  + v2[1]  + v2[2]  + v2[3]  +
16                       v3[0]  + v3[1]  + v3[2]  + v3[3]  +
17                       v3[4]  + v3[5]  + v3[6]  + v3[7]  +
18                       v5[0]  + v5[1]  + v5[2]  + v5[3]  +
19                       v5[4]  + v5[5]  + v5[6]  + v5[7]  +
20                       v5[8]  + v5[9]  + v5[10] + v5[11] +
21                       v5[12] + v5[13] + v5[14] + v5[15] +
22                       v6[0]  + v6[1]  + v6[2]  + v6[3]  +
23                       v6[4]  + v6[5]  + v6[6]  + v6[7]  +
24                       v6[8]  + v6[9]  + v6[10] + v6[11] +
25                       v6[12] + v6[13] + v6[14] + v6[15] ;
26 
27    into:
28 
29      T12 = v1 + v2;
30      T56 = v5 + v6;
31      accumulator += T12[0]  + T12[1]  + T12[2]  + T12[3]  +
32      accumulator += v3[0]   + v3[1]   + v3[2]   + v3[3]   +
33      accumulator += v3[4]   + v3[5]   + v3[6]   + v3[7]   +
34      accumulator += T56[0]  + T56[1]  + T56[2]  + T56[3]  +
35      accumulator += T56[4]  + T56[5]  + T56[6]  + T56[7]  +
36      accumulator += T56[8]  + T56[9]  + T56[10] + T56[11] +
37      accumulator += T56[12] + T56[13] + T56[14] + T56[15] ;  */
38 
39 typedef float v4sf __attribute__((vector_size(16)));
40 typedef float v8sf __attribute__((vector_size(32)));
41 typedef float v16sf __attribute__((vector_size(64)));
42 
43 __attribute__ ((noinline))
test(float accumulator,v4sf v1,v4sf v2,v8sf v3,v16sf v5,v16sf v6)44 float test(float accumulator, v4sf v1, v4sf v2, v8sf v3, v16sf v5, v16sf v6) {
45   accumulator += v1[0] + v1[1] + v1[2] + v1[3];
46   accumulator += v2[0] + v2[1] + v2[2] + v2[3];
47   accumulator += v3[0] + v3[1] + v3[2] + v3[3];
48   accumulator += v3[4] + v3[5] + v3[6] + v3[7];
49   accumulator += v5[0] + v5[1] + v5[2] + v5[3];
50   accumulator += v5[4] + v5[5] + v5[6] + v5[7];
51   accumulator += v5[8] + v5[9] + v5[10] + v5[11];
52   accumulator += v5[12] + v5[13] + v5[14] + v5[15];
53   accumulator += v6[0] + v6[1] + v6[2] + v6[3];
54   accumulator += v6[4] + v6[5] + v6[6] + v6[7];
55   accumulator += v6[8] + v6[9] + v6[10] + v6[11];
56   accumulator += v6[12] + v6[13] + v6[14] + v6[15];
57   return accumulator;
58 }
59 
60 extern void abort (void);
61 
62 int
main()63 main ()
64 {
65   v4sf v1 = {1.0, 2.0, 3.0, 4.0 };
66   v4sf v2 = {5.0, 6.0, 7.0, 8.0 };
67   v8sf v3 = {9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0 };
68   v16sf v5 = {17.0, 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0, 31.0, 32.0};
69   v16sf v6 = {33.0, 34.0, 35.0, 36.0, 37.0, 38.0, 39.0, 40.0, 41.0, 42.0, 43.0, 44.0, 45.0, 46.0, 47.0, 48.0};
70   float acc = 24.0;
71   double res = test (acc, v1, v2, v3, v5, v6);
72   if (res != 1200.0)
73     abort();
74   return 0;
75 }
76 
77 /* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 28 "reassoc1" } } */
78