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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [i386/] [sse4_1-packusdw.c] - Blame information for rev 318

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 318 jeremybenn
/* { dg-do run } */
2
/* { dg-require-effective-target sse4 } */
3
/* { dg-options "-O2 -msse4.1" } */
4
 
5
#ifndef CHECK_H
6
#define CHECK_H "sse4_1-check.h"
7
#endif
8
 
9
#ifndef TEST
10
#define TEST sse4_1_test
11
#endif
12
 
13
#include CHECK_H
14
 
15
#include <smmintrin.h>
16
 
17
#define NUM 64
18
 
19
static unsigned short
20
int_to_ushort (int iVal)
21
{
22
  unsigned short sVal;
23
 
24
  if (iVal < 0)
25
    sVal = 0;
26
  else if (iVal > 0xffff)
27
    sVal = 0xffff;
28
  else sVal = iVal;
29
 
30
  return sVal;
31
}
32
 
33
static void
34
TEST (void)
35
{
36
  union
37
    {
38
      __m128i x[NUM / 4];
39
      int i[NUM];
40
    } src1, src2;
41
  union
42
    {
43
      __m128i x[NUM / 4];
44
      unsigned short s[NUM * 2];
45
    } dst;
46
  int i, sign = 1;
47
 
48
  for (i = 0; i < NUM; i++)
49
    {
50
      src1.i[i] = i * i * sign;
51
      src2.i[i] = (i + 20) * sign;
52
      sign = -sign;
53
    }
54
 
55
  for (i = 0; i < NUM; i += 4)
56
    dst.x[i / 4] = _mm_packus_epi32 (src1.x [i / 4], src2.x [i / 4]);
57
 
58
  for (i = 0; i < NUM; i ++)
59
    {
60
      int dstIndex;
61
      unsigned short sVal;
62
 
63
      sVal = int_to_ushort (src1.i[i]);
64
      dstIndex = (i % 4) + (i / 4) * 8;
65
      if (sVal != dst.s[dstIndex])
66
        abort ();
67
 
68
      sVal = int_to_ushort (src2.i[i]);
69
      dstIndex += 4;
70
      if (sVal != dst.s[dstIndex])
71
        abort ();
72
    }
73
}

powered by: WebSVN 2.1.0

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