1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_shift } */
3
4 #include <stdarg.h>
5 #include "tree-vect.h"
6
7 #if VECTOR_BITS > 128
8 #define N (VECTOR_BITS * 8 / 16)
9 #else
10 #define N 64
11 #endif
12
13 /* Modified rgb to rgb conversion from FFmpeg. */
14 __attribute__ ((noinline)) int
foo(unsigned char * src,unsigned char * dst)15 foo (unsigned char *src, unsigned char *dst)
16 {
17 unsigned char *s = src;
18 unsigned short *d = (unsigned short *)dst, res;
19 int i, result = 0;
20
21 for (i = 0; i < N/4; i++)
22 {
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++;
31 }
32
33 s = src;
34 d = (unsigned short *)dst;
35 for (i = 0; i < N/4; i++)
36 {
37 const int b = *s++;
38 const int g = *s++;
39 const int r = *s++;
40 const int a = *s++;
41 if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)))
42 abort ();
43 d++;
44 }
45
46 return result;
47 }
48
main(void)49 int main (void)
50 {
51 int i;
52 unsigned char in[N], out[N];
53
54 check_vect ();
55
56 for (i = 0; i < N; i++)
57 {
58 in[i] = i;
59 out[i] = 255;
60 __asm__ volatile ("");
61 }
62
63 foo (in, out);
64
65 return 0;
66 }
67
68 /* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */
69 /* { dg-final { scan-tree-dump-times "vect_recog_over_widening_pattern: detected" 2 "vect" { target vect_widen_shift } } } */
70 /* { dg-final { scan-tree-dump-times "vect_recog_over_widening_pattern: detected" 4 "vect" { target { { ! vect_sizes_32B_16B } && { ! vect_widen_shift } } } } } */
71 /* { dg-final { scan-tree-dump-times "vect_recog_over_widening_pattern: detected" 8 "vect" { target vect_sizes_32B_16B } } } */
72 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
73
74