aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/vect/vect-widen-shift-s16.c
blob: efee60437077171f4c6a770eeac5475750189f5c (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/* { dg-require-effective-target vect_int } */
/* { dg-require-effective-target vect_shift } */

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

#define N 64
#define C 16

__attribute__ ((noinline)) void
foo (short *src, int *dst)
{
  int i;
  short b, b0, b1, b2, b3, *s = src;
  int *d = dst;

  for (i = 0; i < N/4; i++)
    {
      b0 = *s++;
      b1 = *s++;
      b2 = *s++;
      b3 = *s++;
      *d = b0 << C;
      d++;
      *d = b1 << C;
      d++;
      *d = b2 << C;
      d++;
      *d = b3 << C;
      d++;
    }

  s = src;
  d = dst;
  for (i = 0; i < N; i++)
    {
      b = *s++;
      if (*d != b << C)
        abort ();
      d++;
    }

  s = src;
  d = dst;
  for (i = 0; i < N/4; i++)
    {
      b0 = *s++;
      b1 = *s++;
      b2 = *s++;
      b3 = *s++;
      *d = b0 << C;
      d++;
      *d = b1 << C;
      d++;
      *d = b2 << C;
      d++;
      *d = b3 << 6;
      d++;
    }

  s = src;
  d = dst;
  for (i = 0; i < N/4; i++)
    {
      b = *s++;
      if (*d != b << C)
        abort ();
      d++;
      b = *s++;
      if (*d != b << C)
        abort ();
      d++;
      b = *s++;
      if (*d != b << C)
        abort ();
      d++;
      b = *s++;
      if (*d != b << 6)
        abort ();
      d++;
    }
}

int main (void)
{
  int i;
  short in[N];
  int out[N];

  check_vect ();

  for (i = 0; i < N; i++)
    {
      in[i] = i;
      out[i] = 255;
      __asm__ volatile ("");
    }

  foo (in, out);

  return 0;
}

/* { dg-final { scan-tree-dump-times "vect_recog_widen_shift_pattern: detected" 8 "vect" { target vect_widen_shift } } } */
/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */