OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [vect/] [vect-shift-2-big-array.c] - Blame information for rev 801

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-require-effective-target vect_shift } */
2
/* { dg-require-effective-target vect_int } */
3
/* Check the standard integer types for left and right shifts to see if the
4
   compiler replaced a scalar instruction with a vector instruction whether the
5
   correct value is generated.  */
6
 
7
#ifdef TRACE
8
#endif
9
 
10
#include <stdarg.h>
11
#include "tree-vect.h"
12
 
13
#ifndef ALIGN
14
#define ALIGN __attribute__((__aligned__(__BIGGEST_ALIGNMENT__)))
15
#endif
16
 
17
#ifndef NOINLINE
18
#define NOINLINE __attribute__((__noinline__))
19
#endif
20
 
21
#ifdef TRACE
22
#define TRACE_FUNC(PREFIX, NAME) printf (#PREFIX #NAME "\n")
23
#define TRACE_DONE()  printf ("done!\n")
24
#define TRACE_ABORT(I,E,G)                                              \
25
do {                                                                    \
26
  printf ("Element %d, expected 0x%lx, got 0x%lx\n",                    \
27
          I, (long)(E), (long)(G));                                     \
28
  abort ();                                                             \
29
} while (0)
30
 
31
#else
32
#define TRACE_FUNC(PREFIX, A)
33
#define TRACE_DONE()
34
#define TRACE_ABORT(I,E,G) abort ()
35
#endif
36
 
37
#define NAME(A,B) A ## B
38
 
39
#define VECT_TESTS(PREFIX, TYPE, N)                                     \
40
 /* Restrict the optimizer from optimizing the setup loops.  */         \
41
volatile TYPE NAME (PREFIX, zero) = 0;                                   \
42
                                                                        \
43
TYPE NAME (PREFIX, a)[N] ALIGN;                                         \
44
TYPE NAME (PREFIX, b)[N] ALIGN;                                         \
45
TYPE NAME (PREFIX, c)[N] ALIGN;                                         \
46
TYPE NAME (PREFIX, d)[N] ALIGN;                                         \
47
                                                                        \
48
static void NOINLINE                                                    \
49
NAME (PREFIX, lshift_2) (void)                                          \
50
{                                                                       \
51
  int i;                                                                \
52
                                                                        \
53
  TRACE_FUNC (PREFIX, lshift_2);                                        \
54
  for (i = 0; i < N; i++)                                                \
55
    NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << 2;                     \
56
}                                                                       \
57
                                                                        \
58
static void NOINLINE                                                    \
59
NAME (PREFIX, lshift_var) (int shift)                                   \
60
{                                                                       \
61
  int i;                                                                \
62
                                                                        \
63
  TRACE_FUNC (PREFIX, lshift_var);                                      \
64
  for (i = 0; i < N; i++)                                                \
65
    NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << shift;                 \
66
}                                                                       \
67
                                                                        \
68
static void NOINLINE                                                    \
69
NAME (PREFIX, lshift_vect) (void)                                       \
70
{                                                                       \
71
  int i;                                                                \
72
                                                                        \
73
  TRACE_FUNC (PREFIX, lshift_vect);                                     \
74
  for (i = 0; i < N; i++)                                                \
75
    NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] << NAME (PREFIX, c)[i];   \
76
}                                                                       \
77
                                                                        \
78
static void NOINLINE                                                    \
79
NAME (PREFIX, rshift_2) (void)                                          \
80
{                                                                       \
81
  int i;                                                                \
82
                                                                        \
83
  TRACE_FUNC (PREFIX, rshift_2);                                        \
84
  for (i = 0; i < N; i++)                                                \
85
    NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> 2;                     \
86
}                                                                       \
87
                                                                        \
88
static void NOINLINE                                                    \
89
NAME (PREFIX, rshift_var) (int shift)                                   \
90
{                                                                       \
91
  int i;                                                                \
92
                                                                        \
93
  TRACE_FUNC (PREFIX, rshift_var);                                      \
94
  for (i = 0; i < N; i++)                                                \
95
    NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> shift;                 \
96
}                                                                       \
97
                                                                        \
98
static void NOINLINE                                                    \
99
NAME (PREFIX, rshift_vect) (void)                                       \
100
{                                                                       \
101
  int i;                                                                \
102
                                                                        \
103
  TRACE_FUNC (PREFIX, rshift_vect);                                     \
104
  for (i = 0; i < N; i++)                                                \
105
    NAME (PREFIX, a)[i] = NAME (PREFIX, b)[i] >> NAME (PREFIX, c)[i];   \
106
}                                                                       \
107
                                                                        \
108
static void NOINLINE                                                    \
109
NAME (PREFIX, check) (void)                                             \
110
{                                                                       \
111
  int i;                                                                \
112
                                                                        \
113
  TRACE_FUNC (PREFIX, check);                                           \
114
  for (i = 0; i < N; i++)                                                \
115
    if (NAME (PREFIX, a)[i] != NAME (PREFIX, d)[i])                     \
116
      TRACE_ABORT (i, NAME (PREFIX, d)[i], NAME (PREFIX, a)[i]);        \
117
}                                                                       \
118
                                                                        \
119
static void NOINLINE                                                    \
120
NAME (PREFIX, tests) (void)                                             \
121
{                                                                       \
122
  int i;                                                                \
123
                                                                        \
124
  TRACE_FUNC (PREFIX, tests);                                           \
125
  for (i = 0; i < N; i++)                                                \
126
    {                                                                   \
127
      NAME (PREFIX, b)[i] = (i + NAME (PREFIX, zero));                  \
128
      NAME (PREFIX, c)[i] = 2;                                          \
129
      NAME (PREFIX, d)[i] = (i + NAME (PREFIX, zero)) << 2;             \
130
    }                                                                   \
131
                                                                        \
132
  NAME (PREFIX, lshift_2) ();                                           \
133
  NAME (PREFIX, check) ();                                              \
134
                                                                        \
135
  NAME (PREFIX, lshift_var) (2);                                        \
136
  NAME (PREFIX, check) ();                                              \
137
                                                                        \
138
  NAME (PREFIX, lshift_vect) ();                                        \
139
  NAME (PREFIX, check) ();                                              \
140
                                                                        \
141
  for (i = 0; i < N; i++)                                                \
142
    {                                                                   \
143
      NAME (PREFIX, b)[i] = ((i + NAME (PREFIX, zero)) << 4)            \
144
        | (((TYPE)0x80) << ((sizeof (TYPE) * 8) - 8));                  \
145
      NAME (PREFIX, c)[i] = 2;                                          \
146
      NAME (PREFIX, d)[i] = (TYPE)((NAME (PREFIX, b)[i]                 \
147
                                    + NAME (PREFIX, zero)) >> 2);       \
148
    }                                                                   \
149
                                                                        \
150
  NAME (PREFIX, rshift_2) ();                                           \
151
  NAME (PREFIX, check) ();                                              \
152
                                                                        \
153
  NAME (PREFIX, rshift_var) (2);                                        \
154
  NAME (PREFIX, check) ();                                              \
155
                                                                        \
156
  NAME (PREFIX, rshift_vect) ();                                        \
157
  NAME (PREFIX, check) ();                                              \
158
}
159
 
160
VECT_TESTS (uc_, unsigned char,  128)
161
VECT_TESTS (us_, unsigned short, 256)
162
VECT_TESTS (ui_, unsigned int,   256)
163
VECT_TESTS (ul_, unsigned long,  256)
164
 
165
VECT_TESTS (sc_, signed char,    128)
166
VECT_TESTS (ss_, short,          256)
167
VECT_TESTS (si_, int,            256)
168
VECT_TESTS (sl_, long,           256)
169
 
170
int main ()
171
{
172
  int i;
173
 
174
  check_vect ();
175
 
176
  uc_tests ();
177
  us_tests ();
178
  ui_tests ();
179
  ul_tests ();
180
 
181
  sc_tests ();
182
  ss_tests ();
183
  si_tests ();
184
  sl_tests ();
185
 
186
  TRACE_DONE ();
187
  return 0;
188
}
189
 
190
/* { dg-final { cleanup-tree-dump "vect" } } */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.