summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vshift-3.c
blob: 367e66065510f6b3b0cb30b3dd07c9ae9567cd9d (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* { dg-do run } */
/* { dg-options "-O3" } */

#include <stdlib.h>

#define N 64

#ifndef TYPE1
#define TYPE1 int
#define TYPE2 long long
#endif

signed TYPE1 a[N], b, g[N];
unsigned TYPE1 c[N], h[N];
signed TYPE2 d[N], e, j[N];
unsigned TYPE2 f[N], k[N];

#ifndef S
#define S(x) x
#endif

__attribute__((noinline)) void
f1 (void)
{
  int i;
  for (i = 0; i < N; i++)
    g[i] = a[i] << S (b);
}

__attribute__((noinline)) void
f2 (void)
{
  int i;
  for (i = 0; i < N; i++)
    g[i] = a[i] >> S (b);
}

__attribute__((noinline)) void
f3 (void)
{
  int i;
  for (i = 0; i < N; i++)
    h[i] = c[i] >> S (b);
}

__attribute__((noinline)) void
f4 (void)
{
  int i;
  for (i = 0; i < N; i++)
    j[i] = d[i] << S (e);
}

__attribute__((noinline)) void
f5 (void)
{
  int i;
  for (i = 0; i < N; i++)
    j[i] = d[i] >> S (e);
}

__attribute__((noinline)) void
f6 (void)
{
  int i;
  for (i = 0; i < N; i++)
    k[i] = f[i] >> S (e);
}

__attribute__((noinline)) void
f7 (void)
{
  int i;
  for (i = 0; i < N; i++)
    j[i] = d[i] << S (b);
}

__attribute__((noinline)) void
f8 (void)
{
  int i;
  for (i = 0; i < N; i++)
    j[i] = d[i] >> S (b);
}

__attribute__((noinline)) void
f9 (void)
{
  int i;
  for (i = 0; i < N; i++)
    k[i] = f[i] >> S (b);
}

int
main ()
{
  int i;
  b = 7;
  e = 12;
  for (i = 0; i < N; i++)
    {
      asm ("");
      c[i] = (rand () << 1) | (rand () & 1);
      a[i] = c[i];
      d[i] = (rand () << 1) | (rand () & 1);
      d[i] |= (unsigned long long) c[i] << 32;
      f[i] = d[i];
    }
  f1 ();
  f3 ();
  f4 ();
  f6 ();
  for (i = 0; i < N; i++)
    if (g[i] != (signed TYPE1) (a[i] << S (b))
	|| h[i] != (unsigned TYPE1) (c[i] >> S (b))
	|| j[i] != (signed TYPE2) (d[i] << S (e))
	|| k[i] != (unsigned TYPE2) (f[i] >> S (e)))
      abort ();
  f2 ();
  f5 ();
  f9 ();
  for (i = 0; i < N; i++)
    if (g[i] != (signed TYPE1) (a[i] >> S (b))
	|| j[i] != (signed TYPE2) (d[i] >> S (e))
	|| k[i] != (unsigned TYPE2) (f[i] >> S (b)))
      abort ();
  f7 ();
  for (i = 0; i < N; i++)
    if (j[i] != (signed TYPE2) (d[i] << S (b)))
      abort ();
  f8 ();
  for (i = 0; i < N; i++)
    if (j[i] != (signed TYPE2) (d[i] >> S (b)))
      abort ();
  return 0;
}