2014-08-04 Ed Schonberg <schonberg@adacore.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr50444.c
blob35a6141630f1f6457b069fee4d3833ef2d94d1e6
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-msse2" } */
3 /* { dg-require-effective-target sse2_runtime } */
5 typedef long long __m128i __attribute__ ((__vector_size__ (16),
6 __may_alias__));
7 typedef int __v4si __attribute__ ((__vector_size__ (16)));
8 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
9 typedef unsigned int uint32_t;
11 typedef struct {
12 uint32_t v[4];
13 } a4x32;
15 a4x32* incr(a4x32* x)
17 x->v[0] += 1;
18 return x;
21 typedef struct {
22 __m128i m;
23 } a1xm128i;
25 static inline a1xm128i ssefunc( a1xm128i in, a1xm128i k)
27 a1xm128i ret;
28 ret.m = (__m128i)__builtin_ia32_pxor128 ((__v2di)in.m, (__v2di)k.m);
29 return ret;
32 static a4x32 caster( a4x32 c4x32, a1xm128i k)
34 a1xm128i c1x128;
35 if( sizeof(c4x32) != sizeof(c1x128) ) __builtin_abort();
36 __builtin_memcpy(&c1x128, &c4x32, sizeof(c1x128));
37 c1x128 = ssefunc(c1x128, k);
38 __builtin_memcpy(&c4x32, &c1x128, sizeof(c4x32));
39 return c4x32;
42 typedef struct {
43 a1xm128i key;
44 a4x32 c;
45 __SIZE_TYPE__ elem;
46 a4x32 v;
47 } Engine;
49 void ctor(Engine *e)
51 e->elem = 0;
52 e->key.m = (__m128i)(__v4si){ 0, 0, 0, 0 };
53 e->c.v[0] = 0;
54 e->c.v[1] = 0;
55 e->c.v[2] = 0;
56 e->c.v[3] = 0;
59 uint32_t method( Engine *e)
61 if( e->elem == 0 )
63 e->v = caster(*incr(&e->c), e->key);
64 e->elem = 4;
66 return e->v.v[--e->elem];
69 int main()
71 Engine e4; ctor(&e4);
72 Engine e5; ctor(&e5);
73 if(method(&e4)!=method(&e5))
74 __builtin_abort ();
75 return 0;