1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-strict-aliasing -msse2" } */
3 /* { dg-additional-options "-mno-mmx" { target { ! ia32 } } } */
4
5 #include "sse2-check.h"
6 #include "mmx-vals.h"
7
8 __attribute__((noinline, noclone))
9 static void
test_packuswb(long long * ll1,long long * ll2,long long * r)10 test_packuswb (long long *ll1, long long *ll2, long long *r)
11 {
12 __m64 t1 = *(__m64 *) ll1;
13 __m64 t2 = *(__m64 *) ll2;
14 *(__m64 *) r = _m_packuswb (t1, t2);
15 }
16
17 /* Routine to manually compute the results */
18 static void
compute_correct_result(long long * dst_p,long long * src_p,long long * res_p)19 compute_correct_result (long long *dst_p, long long *src_p,
20 long long *res_p)
21 {
22 short *dst = (short *) dst_p;
23 short *src = (short *) src_p;
24 unsigned char *res = (unsigned char *) res_p;
25 int i;
26
27 for (i = 0; i < 4; i++)
28 {
29 res[i] = saturate_ub (dst[i]);
30 res[i + 4] = saturate_ub (src[i]);
31 }
32 }
33
34 static void
sse2_test(void)35 sse2_test (void)
36 {
37 int i;
38 long long r, ck;
39 int fail = 0;
40
41 /* Run the MMX tests */
42 for (i = 0; i < MMX_num_ops; i += 2)
43 {
44 test_packuswb (&MMXops[i], &MMXops[i + 1], &r);
45 compute_correct_result (&MMXops[i], &MMXops[i + 1], &ck);
46 if (ck != r)
47 fail++;
48 }
49
50 if (fail != 0)
51 abort ();
52 }
53