1 /* { dg-require-effective-target vect_int } */ 2 /* { dg-require-effective-target vect_shift } */ 3 4 #include <stdlib.h> 5 #include <stdarg.h> 6 #include "tree-vect.h" 7 8 #define N 128 9 10 /* Modified rgb to rgb conversion from FFmpeg. */ 11 __attribute__ ((noinline)) void foo(unsigned char * src,unsigned char * dst)12foo (unsigned char *src, unsigned char *dst) 13 { 14 unsigned char *s = src; 15 unsigned short *d = (unsigned short *)dst; 16 int i; 17 18 for (i = 0; i < N/4; i++) 19 { 20 const int b = *s++; 21 const int g = *s++; 22 const int r = *s++; 23 const int a = *s++; 24 *d = ((b>>3) | ((g&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9)); 25 d++; 26 } 27 28 s = src; 29 d = (unsigned short *)dst; 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&0xFFC)<<3) | ((r+0xF8)>>8) | (a<<9))) 37 abort (); 38 d++; 39 } 40 } 41 main(void)42int 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_over_widening_pattern: detected" 1 "vect" } } */ 62 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ 63 /* { dg-final { cleanup-tree-dump "vect" } } */ 64 65