libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / pr88497-1.c
blob8f9a14af1d347a45bc5031fee54025054ddb62fd
1 /* { dg-require-effective-target vect_double } */
2 /* { dg-require-effective-target vsx_hw { target { powerpc*-*-* } } } */
3 /* { dg-require-effective-target sse2_runtime { target { i?86-*-* x86_64-*-* } } } */
4 /* { dg-additional-options "-O2 -ffast-math -fdump-tree-reassoc1" } */
5 /* { dg-additional-options "-mvsx" { target { powerpc*-*-* } } } */
6 /* { dg-additional-options "-msse2" { target { i?86-*-* x86_64-*-* } } } */
8 /* To test reassoc can undistribute vector bit_field_ref summation.
10 arg1 and arg2 are two arrays whose elements of type vector double.
11 Assuming:
12 A0 = arg1[0], A1 = arg1[1], A2 = arg1[2], A3 = arg1[3],
13 B0 = arg2[0], B1 = arg2[1], B2 = arg2[2], B3 = arg2[3],
15 Then:
16 V0 = A0 * B0, V1 = A1 * B1, V2 = A2 * B2, V3 = A3 * B3,
18 reassoc transforms
20 accumulator += V0[0] + V0[1] + V1[0] + V1[1] + V2[0] + V2[1]
21 + V3[0] + V3[1];
23 into:
25 T = V0 + V1 + V2 + V3
26 accumulator += T[0] + T[1];
28 Fewer bit_field_refs, only two for 128 or more bits vector. */
30 typedef double v2df __attribute__ ((vector_size (16)));
31 __attribute__ ((noinline)) double
32 test (double accumulator, v2df arg1[], v2df arg2[])
34 v2df temp;
35 temp = arg1[0] * arg2[0];
36 accumulator += temp[0] + temp[1];
37 temp = arg1[1] * arg2[1];
38 accumulator += temp[0] + temp[1];
39 temp = arg1[2] * arg2[2];
40 accumulator += temp[0] + temp[1];
41 temp = arg1[3] * arg2[3];
42 accumulator += temp[0] + temp[1];
43 return accumulator;
46 extern void abort (void);
48 int
49 main ()
51 v2df v2[4] = {{1.0, 2.0}, {4.0, 8.0}, {1.0, 3.0}, {9.0, 27.0}};
52 v2df v3[4] = {{1.0, 4.0}, {16.0, 64.0}, {1.0, 2.0}, {3.0, 4.0}};
53 double acc = 100.0;
54 double res = test (acc, v2, v3);
55 if (res != 827.0)
56 abort ();
57 return 0;
59 /* { dg-final { scan-tree-dump-times "BIT_FIELD_REF" 2 "reassoc1" { target { powerpc*-*-* i?86-*-* x86_64-*-* } } } } */