Debian Codegraph @

gcc/testsuite/gcc.dg/vect/vect-over-widen-1-big-array.c

raw
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 512
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&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5));
24 d++;
25 }
26
27 s = src;
28 d = (unsigned short *)dst;
29 #pragma GCC novector
30 for (i = 0; i < N/4; i++)
31 {
32 const int b = *s++;
33 const int g = *s++;
34 const int r = *s++;
35 const int a = *s++;
36 if (*d != ((b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8) | (a>>5)))
37 abort ();
38 d++;
39 }
40 }
41
42 int main (void)
43 {
44 int i;
45 unsigned char in[N], out[N];
46
47 check_vect ();
48
49 for (i = 0; i < N; i++)
50 {
51 in[i] = i;
52 out[i] = 255;
53 __asm__ volatile ("");
54 }
55
56 foo (in, out);
57
58 return 0;
59 }
60
61 /* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 2 "vect" { target vect_widen_shift } } } */
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]* >> 5} "vect" } } */
64 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
65