libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / bb-slp-over-widen-1.c
blob7646c4f5a8bb768a5e7c2d9c9045975062d90c64
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_shift } */
3 /* { dg-require-effective-target vect_pack_trunc } */
4 /* { dg-require-effective-target vect_unpack } */
6 #include "tree-vect.h"
8 /* Deliberate use of signed >>. */
9 #define DEF_LOOP(SIGNEDNESS) \
10 void __attribute__ ((noipa)) \
11 f_##SIGNEDNESS (SIGNEDNESS char *restrict a, \
12 SIGNEDNESS char *restrict b, \
13 SIGNEDNESS char *restrict c) \
14 { \
15 a[0] = (b[0] + c[0]) >> 1; \
16 a[1] = (b[1] + c[1]) >> 1; \
17 a[2] = (b[2] + c[2]) >> 1; \
18 a[3] = (b[3] + c[3]) >> 1; \
19 a[4] = (b[4] + c[4]) >> 1; \
20 a[5] = (b[5] + c[5]) >> 1; \
21 a[6] = (b[6] + c[6]) >> 1; \
22 a[7] = (b[7] + c[7]) >> 1; \
23 a[8] = (b[8] + c[8]) >> 1; \
24 a[9] = (b[9] + c[9]) >> 1; \
25 a[10] = (b[10] + c[10]) >> 1; \
26 a[11] = (b[11] + c[11]) >> 1; \
27 a[12] = (b[12] + c[12]) >> 1; \
28 a[13] = (b[13] + c[13]) >> 1; \
29 a[14] = (b[14] + c[14]) >> 1; \
30 a[15] = (b[15] + c[15]) >> 1; \
33 DEF_LOOP (signed)
34 DEF_LOOP (unsigned)
36 #define N 16
38 #define TEST_LOOP(SIGNEDNESS, BASE_B, BASE_C) \
39 { \
40 SIGNEDNESS char a[N], b[N], c[N]; \
41 for (int i = 0; i < N; ++i) \
42 { \
43 b[i] = BASE_B + i * 15; \
44 c[i] = BASE_C + i * 14; \
45 asm volatile ("" ::: "memory"); \
46 } \
47 f_##SIGNEDNESS (a, b, c); \
48 _Pragma("GCC novector") \
49 for (int i = 0; i < N; ++i) \
50 if (a[i] != (BASE_B + BASE_C + i * 29) >> 1) \
51 __builtin_abort (); \
54 int
55 main (void)
57 check_vect ();
59 TEST_LOOP (signed, -128, -120);
60 TEST_LOOP (unsigned, 4, 10);
62 return 0;
65 /* { dg-final { scan-tree-dump "demoting int to signed short" "slp2" { target { ! vect_widen_shift } } } } */
66 /* { dg-final { scan-tree-dump "demoting int to unsigned short" "slp2" { target { ! vect_widen_shift } } } } */
67 /* { dg-final { scan-tree-dump {\.AVG_FLOOR} "slp2" { target vect_avg_qi } } } */
68 /* { dg-final { scan-tree-dump-times "note: Basic block will be vectorized" 2 "slp2" { target vect_hw_misalign } } } */