libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-over-widen-4.c
blob60c9c2cc1ec272b46b7bb9a5cf856a57591425b0
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_shift } */
4 #include <stdarg.h>
5 #include "tree-vect.h"
7 #if VECTOR_BITS > 128
8 #define N (VECTOR_BITS * 8 / 16)
9 #else
10 #define N 64
11 #endif
13 /* Modified rgb to rgb conversion from FFmpeg. */
14 __attribute__ ((noinline)) int
15 foo (unsigned char *src, unsigned char *dst)
17 unsigned char *s = src;
18 unsigned short *d = (unsigned short *)dst, res;
19 int i, result = 0;
21 for (i = 0; i < N/4; i++)
23 const int b = *s++;
24 const int g = *s++;
25 const int r = *s++;
26 const int a = *s++;
27 res = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5));
28 *d = res;
29 result += res;
30 d++;
33 s = src;
34 d = (unsigned short *)dst;
35 #pragma GCC novector
36 for (i = 0; i < N/4; i++)
38 const int b = *s++;
39 const int g = *s++;
40 const int r = *s++;
41 const int a = *s++;
42 if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)))
43 abort ();
44 d++;
47 return result;
50 int main (void)
52 int i;
53 unsigned char in[N], out[N];
55 check_vect ();
57 for (i = 0; i < N; i++)
59 in[i] = i;
60 out[i] = 255;
61 __asm__ volatile ("");
64 foo (in, out);
66 return 0;
69 /* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */
70 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */
71 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 5} "vect" } } */
72 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */