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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [torture/] [pr44900.C] - Blame information for rev 774

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

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
2
/* { dg-options "-msse" } */
3
/* { dg-require-effective-target sse_runtime } */
4
 
5
typedef float __m128 __attribute__ ((__vector_size__ (16), __may_alias__));
6
typedef float __v4sf __attribute__ ((__vector_size__ (16)));
7
 
8
extern __inline __m128 __attribute__((__gnu_inline__, __always_inline__,
9
__artificial__))
10
_mm_set_ps (const float __Z, const float __Y, const float __X, const float __W)
11
{
12
  return __extension__ (__m128)(__v4sf){ __W, __X, __Y, __Z };
13
}
14
 
15
struct vec
16
{
17
        union {
18
                __m128 v;
19
                float  e[4];
20
        };
21
 
22
        static const vec & zero()
23
        {
24
                static const vec v = _mm_set_ps(0, 0, 0, 0);
25
                return v;
26
        }
27
 
28
        vec() {}
29
        vec(const __m128 & a) : v(a) {}
30
 
31
        operator const __m128&() const { return v; }
32
};
33
 
34
struct vec2
35
{
36
        vec _v1;
37
        vec _v2;
38
 
39
        vec2() {}
40
        vec2(const vec & a, const vec & b) : _v1(a), _v2(b) {}
41
 
42
        static vec2 load(const float * a)
43
        {
44
                return vec2(
45
                        __builtin_ia32_loadups(&a[0]),
46
                        __builtin_ia32_loadups(&a[4]));
47
        }
48
 
49
        const vec & v1() const { return _v1; }
50
        const vec & v2() const { return _v2; }
51
};
52
 
53
extern "C" void abort(void);
54
 
55
 
56
inline bool operator==(const vec & a, const vec & b)
57
{ return 0xf == __builtin_ia32_movmskps(__builtin_ia32_cmpeqps(a, b)); }
58
 
59
int main( int argc, char * argv[] )
60
{
61
        __attribute__((aligned(16))) float data[] =
62
        { 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5 };
63
 
64
        float * p = &data[2];
65
        vec2 a;
66
 
67
        a = vec2::load(p);
68
 
69
        vec v1 = a.v1();
70
        vec v2 = a.v2();
71
 
72
        if (v2.e[3] != 7.0)
73
          abort();
74
 
75
        return 0;
76
}

powered by: WebSVN 2.1.0

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