1 /* { 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 #include <string.h>
17
18 typedef char T __attribute__((may_alias));
19 struct S { __m128i d; };
20
21 __m128i
22 __attribute__((noinline))
foo(__m128i y,char x)23 foo (__m128i y, char x)
24 {
25 struct S s;
26
27 s.d = y;
28 ((T *) &s.d)[1] = x;
29 return s.d;
30 }
31
32 static void
TEST(void)33 TEST (void)
34 {
35 union
36 {
37 __m128i x;
38 unsigned int i[4];
39 unsigned char c[16];
40 } res, val, tmp;
41 unsigned char ins[4] = { 3, 4, 5, 6 };
42
43 val.i[0] = 0x35251505;
44 val.i[1] = 0x75655545;
45 val.i[2] = 0xB5A59585;
46 val.i[3] = 0xF5E5D5C5;
47
48 res.x = foo (val.x, ins[3]);
49
50 tmp.x = val.x;
51 tmp.c[1] = ins[3];
52 if (memcmp (&tmp, &res, sizeof (tmp)))
53 abort ();
54 }
55