1 /* { dg-do run { target { ! ia32 } } } */
2 /* { dg-options "-O2 -msse2 -mno-mmx" } */
3 /* { dg-require-effective-target sse2 } */
4 
5 #include "sse2-check.h"
6 
7 #include <string.h>
8 
9 #define FLOAT_X	2.3456
10 #define FLOAT_Y	-4.5987
11 
12 static float expected_x = FLOAT_X;
13 static float expected_y = FLOAT_Y;
14 static __v2sf expected1 = { FLOAT_X, FLOAT_Y };
15 static __v2sf expected2 = { FLOAT_X, 0 };
16 static __v2sf expected3 = { FLOAT_X, FLOAT_X };
17 
18 float
19 __attribute__((noinline, noclone))
foo1(__m64 x)20 foo1 (__m64 x)
21 {
22   return ((__v2sf) x)[0];
23 }
24 
25 float
26 __attribute__((noinline, noclone))
foo2(__m64 x)27 foo2 (__m64 x)
28 {
29   return ((__v2sf) x)[1];
30 }
31 
32 __m64
33 __attribute__((noinline, noclone))
foo3(float x)34 foo3 (float x)
35 {
36   return __extension__ (__m64) (__v2sf) { x, 0 };
37 }
38 
39 __m64
40 __attribute__((noinline, noclone))
foo4(float x)41 foo4 (float x)
42 {
43   return __extension__ (__m64) (__v2sf) { x, x };
44 }
45 
46 __m64
47 __attribute__((noinline, noclone))
foo5(float x,float y)48 foo5 (float x, float y)
49 {
50   return __extension__ (__m64) (__v2sf) { x, y };
51 }
52 
53 void
54 __attribute__((noinline))
sse2_test(void)55 sse2_test (void)
56 {
57   __m64 res;
58   float x;
59 
60   x = foo1 ((__m64) expected1);
61   if (x != expected_x)
62     abort ();
63 
64   x = foo2 ((__m64) expected1);
65   if (x != expected_y)
66     abort ();
67 
68   res = foo3 (FLOAT_X);
69   if (memcmp (&res, &expected2, sizeof (res)))
70     abort ();
71 
72   res = foo4 (FLOAT_X);
73   if (memcmp (&res, &expected3, sizeof (res)))
74     abort ();
75 
76   res = foo5 (FLOAT_X, FLOAT_Y);
77   if (memcmp (&res, &expected1, sizeof (res)))
78     abort ();
79 }
80