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 #define N VECTOR_BITS
8
9 /* Modified rgb to rgb conversion from FFmpeg. */
10 __attribute__ ((noinline)) void
11 foo (unsigned char *src, unsigned char *dst)
12 {
13 unsigned char *s = src;
14 unsigned short *d = (unsigned short *)dst;
15 int i;
16
17 for (i = 0; i < N/4; i++)
18 {
19 const int b = *s++;
20 const int g = *s++;
21 const int r = *s++;
22 const int a = *s++;
23 *d = ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9));
24 d++;
25 }
26
27 s = src;
28 d = (unsigned short *)dst;
29 for (i = 0; i < N/4; i++)
30 {
31 const int b = *s++;
32 const int g = *s++;
33 const int r = *s++;
34 const int a = *s++;
35 unsigned short expected
36 = ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9));
37 if (*d != expected)
38 abort ();
39 d++;
40 }
41 }
42
43 int main (void)
44 {
45 int i;
46 unsigned char in[N], out[N];
47
48 check_vect ();
49
50 for (i = 0; i < N; i++)
51 {
52 in[i] = i;
53 out[i] = 255;
54 __asm__ volatile ("");
55 }
56
57 foo (in, out);
58
59 return 0;
60 }
61
62 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */
63 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 8} "vect" } } */
64 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
65