| 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 |
#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 |
unsigned short expected |
| 37 |
= ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9)); |
| 38 |
if (*d != expected) |
| 39 |
abort (); |
| 40 |
d++; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
int main (void) |
| 45 |
{ |
| 46 |
int i; |
| 47 |
unsigned char in[N], out[N]; |
| 48 |
|
| 49 |
check_vect (); |
| 50 |
|
| 51 |
for (i = 0; i < N; i++) |
| 52 |
{ |
| 53 |
in[i] = i; |
| 54 |
out[i] = 255; |
| 55 |
__asm__ volatile (""); |
| 56 |
} |
| 57 |
|
| 58 |
foo (in, out); |
| 59 |
|
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 3} "vect" } } */ |
| 64 |
/* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 8} "vect" } } */ |
| 65 |
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ |
| 66 |
|