summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect/pr37539.c
blob: 1e73425de9ea91265caf82fe958aabc713799933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* { dg-require-effective-target vect_int } */

#include <stdarg.h>
#include "tree-vect.h"

__attribute__ ((noinline)) void
ayuv2yuyv_ref (int *d, int *src, int n)
{
  char *dest = (char *)d;
  int i;

  for(i=0;i<n/2;i++){
    dest[i*4 + 0] = (src[i*2 + 0])>>16;
    dest[i*4 + 1] = (src[i*2 + 1])>>8;
    dest[i*4 + 2] = (src[i*2 + 0])>>16;
    dest[i*4 + 3] = (src[i*2 + 0])>>0;
  }

  /* Check results.  */
  for(i=0;i<n/2;i++){
   if (dest[i*4 + 0] != (src[i*2 + 0])>>16
       || dest[i*4 + 1] != (src[i*2 + 1])>>8
       || dest[i*4 + 2] != (src[i*2 + 0])>>16
       || dest[i*4 + 3] != (src[i*2 + 0])>>0) 
     abort();
  }
}

int main ()
{
  int d[256], src[128], i;
 
  check_vect ();

  for (i = 0; i < 128; i++)
    src[i] = i; 
  
  ayuv2yuyv_ref(d, src, 128);

  return 0;
}

/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target vect_strided_wide } } } */
/* { dg-final { cleanup-tree-dump "vect" } } */