PR target/55146
[official-gcc.git] / gcc / testsuite / gcc.dg / vect / vect-over-widen-4.c
blob70f12fef7d3801c2ed042606d210eadf8daa4ab5
1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_shift } */
4 #include <stdlib.h>
5 #include <stdarg.h>
6 #include "tree-vect.h"
8 #define N 64
10 /* Modified rgb to rgb conversion from FFmpeg. */
11 __attribute__ ((noinline)) int
12 foo (unsigned char *src, unsigned char *dst)
14 unsigned char *s = src;
15 unsigned short *d = (unsigned short *)dst, res;
16 int i, result = 0;
18 for (i = 0; i < N/4; i++)
20 const int b = *s++;
21 const int g = *s++;
22 const int r = *s++;
23 const int a = *s++;
24 res = ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5));
25 *d = res;
26 result += res;
27 d++;
30 s = src;
31 d = (unsigned short *)dst;
32 for (i = 0; i < N/4; i++)
34 const int b = *s++;
35 const int g = *s++;
36 const int r = *s++;
37 const int a = *s++;
38 if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)))
39 abort ();
40 d++;
43 return result;
46 int main (void)
48 int i;
49 unsigned char in[N], out[N];
51 check_vect ();
53 for (i = 0; i < N; i++)
55 in[i] = i;
56 out[i] = 255;
57 __asm__ volatile ("");
60 foo (in, out);
62 return 0;
65 /* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */
66 /* { dg-final { scan-tree-dump-times "vect_recog_over_widening_pattern: detected" 2 "vect" { target vect_widen_shift } } } */
67 /* { dg-final { scan-tree-dump-times "vect_recog_over_widening_pattern: detected" 4 "vect" { target { { ! vect_sizes_32B_16B } && { ! vect_widen_shift } } } } } */
68 /* { dg-final { scan-tree-dump-times "vect_recog_over_widening_pattern: detected" 8 "vect" { target vect_sizes_32B_16B } } } */
69 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
70 /* { dg-final { cleanup-tree-dump "vect" } } */