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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.target/] [i386/] [xop-hadduX.c] - Blame information for rev 691

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 691 jeremybenn
/* { dg-do run } */
2
/* { dg-require-effective-target xop } */
3
/* { dg-options "-O2 -mxop" } */
4
 
5
#include "xop-check.h"
6
 
7
#include <x86intrin.h>
8
#include <string.h>
9
 
10
#define NUM 10
11
 
12
union
13
{
14
  __m128i x[NUM];
15
  unsigned char  ssi[NUM * 16];
16
  unsigned short si[NUM * 8];
17
  unsigned int li[NUM * 4];
18
  unsigned long long  lli[NUM * 2];
19
} dst, res, src1;
20
 
21
static void
22
init_byte ()
23
{
24
  int i;
25
  for (i=0; i < NUM * 16; i++)
26
    src1.ssi[i] = i;
27
}
28
 
29
static void
30
init_word ()
31
{
32
  int i;
33
  for (i=0; i < NUM * 8; i++)
34
    src1.si[i] = i;
35
}
36
 
37
 
38
static void
39
init_dword ()
40
{
41
  int i;
42
  for (i=0; i < NUM * 4; i++)
43
    src1.li[i] = i;
44
}
45
 
46
static int
47
check_byte2word ()
48
{
49
  int i, j, s, t, check_fails = 0;
50
  for (i = 0; i < NUM * 16; i = i + 16)
51
    {
52
      for (j = 0; j < 8; j++)
53
        {
54
          t = i + (2 * j);
55
          s = (i / 2) + j;
56
          res.si[s] = src1.ssi[t] + src1.ssi[t + 1] ;
57
          if (res.si[s] != dst.si[s])
58
            check_fails++;
59
        }
60
    }
61
}
62
 
63
static int
64
check_byte2dword ()
65
{
66
  int i, j, s, t, check_fails = 0;
67
  for (i = 0; i < NUM * 16; i = i + 16)
68
    {
69
      for (j = 0; j < 4; j++)
70
        {
71
          t = i + (4 * j);
72
          s = (i / 4) + j;
73
          res.li[s] = (src1.ssi[t] + src1.ssi[t + 1]) + (src1.ssi[t + 2]
74
                      + src1.ssi[t + 3]);
75
          if (res.li[s] != dst.li[s])
76
            check_fails++;
77
        }
78
    }
79
  return check_fails++;
80
}
81
 
82
static int
83
check_byte2qword ()
84
{
85
  int i, j, s, t, check_fails = 0;
86
  for (i = 0; i < NUM * 16; i = i + 16)
87
    {
88
      for (j = 0; j < 2; j++)
89
        {
90
          t = i + (8 * j);
91
          s = (i / 8) + j;
92
          res.lli[s] = ((src1.ssi[t] + src1.ssi[t + 1]) + (src1.ssi[t + 2]
93
                       + src1.ssi[t + 3])) + ((src1.ssi[t + 4] + src1.ssi[t +5])
94
                       + (src1.ssi[t + 6] + src1.ssi[t + 7]));
95
          if (res.lli[s] != dst.lli[s])
96
            check_fails++;
97
        }
98
    }
99
  return check_fails++;
100
}
101
 
102
static int
103
check_word2dword ()
104
{
105
  int i, j, s, t, check_fails = 0;
106
  for (i = 0; i < (NUM * 8); i = i + 8)
107
    {
108
      for (j = 0; j < 4; j++)
109
        {
110
          t = i + (2 * j);
111
          s = (i / 2) + j;
112
          res.li[s] = src1.si[t] + src1.si[t + 1] ;
113
          if (res.li[s] != dst.li[s])
114
            check_fails++;
115
        }
116
    }
117
}
118
 
119
static int
120
check_word2qword ()
121
{
122
  int i, j, s, t, check_fails = 0;
123
  for (i = 0; i < NUM * 8; i = i + 8)
124
    {
125
      for (j = 0; j < 2; j++)
126
        {
127
          t = i + (4 * j);
128
          s = (i / 4) + j;
129
          res.lli[s] = (src1.si[t] + src1.si[t + 1]) + (src1.si[t + 2]
130
                       + src1.si[t + 3]);
131
          if (res.lli[s] != dst.lli[s])
132
            check_fails++;
133
        }
134
    }
135
  return check_fails++;
136
}
137
 
138
static int
139
check_dword2qword ()
140
{
141
  int i, j, s, t, check_fails = 0;
142
  for (i = 0; i < (NUM * 4); i = i + 4)
143
    {
144
      for (j = 0; j < 2; j++)
145
        {
146
          t = i + (2 * j);
147
          s = (i / 2) + j;
148
          res.lli[s] = src1.li[t] + src1.li[t + 1] ;
149
          if (res.lli[s] != dst.lli[s])
150
            check_fails++;
151
        }
152
    }
153
}
154
 
155
static void
156
xop_test (void)
157
{
158
  int i;
159
 
160
  /* Check haddubw */
161
  init_byte ();
162
 
163
  for (i = 0; i < NUM; i++)
164
    dst.x[i] = _mm_haddw_epu8 (src1.x[i]);
165
 
166
  if (check_byte2word())
167
  abort ();
168
 
169
  /* Check haddubd */
170
  for (i = 0; i < (NUM ); i++)
171
    dst.x[i] = _mm_haddd_epu8 (src1.x[i]);
172
 
173
  if (check_byte2dword())
174
    abort ();
175
 
176
  /* Check haddubq */
177
  for (i = 0; i < NUM; i++)
178
    dst.x[i] = _mm_haddq_epu8 (src1.x[i]);
179
 
180
  if (check_byte2qword())
181
    abort ();
182
 
183
  /* Check hadduwd */
184
  init_word ();
185
 
186
  for (i = 0; i < (NUM ); i++)
187
    dst.x[i] = _mm_haddd_epu16 (src1.x[i]);
188
 
189
  if (check_word2dword())
190
    abort ();
191
 
192
  /* Check haddbuwq */
193
 
194
  for (i = 0; i < NUM; i++)
195
    dst.x[i] = _mm_haddq_epu16 (src1.x[i]);
196
 
197
  if (check_word2qword())
198
    abort ();
199
 
200
  /* Check hadudq */
201
  init_dword ();
202
    for (i = 0; i < NUM; i++)
203
    dst.x[i] = _mm_haddq_epu32 (src1.x[i]);
204
 
205
  if (check_dword2qword())
206
    abort ();
207
}

powered by: WebSVN 2.1.0

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