Debian Codegraph @

gcc/testsuite/gcc.target/i386/sse2-mmx-pmulhuw.c

raw
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
10 test_pmulhuw (long long *ll1, long long *ll2, long long *r)
11 {
12 __m64 t1 = *(__m64 *) ll1;
13 __m64 t2 = *(__m64 *) ll2;
14 *(__m64 *) r = _m_pmulhuw (t1, t2);
15 }
16
17 /* Routine to manually compute the results */
18 static void
19 compute_correct_result (long long *dst_p, long long *src_p,
20 long long *res_p)
21 {
22 unsigned short *dst = (unsigned short *) dst_p;
23 unsigned short *src = (unsigned short *) src_p;
24 unsigned short *res = (unsigned short *) res_p;
25 int i;
26 for (i = 0; i < 4; i++)
27 {
28 unsigned int t = dst[i] * src[i];
29 res[i] = t >> 16;
30 }
31 }
32
33 static void
34 sse2_test (void)
35 {
36 int i;
37 long long r, ck;
38 int fail = 0;
39
40 /* Run the MMX tests */
41 for (i = 0; i < MMX_num_ops; i += 2)
42 {
43 test_pmulhuw (&MMXops[i], &MMXops[i + 1], &r);
44 compute_correct_result (&MMXops[i], &MMXops[i + 1], &ck);
45 if (ck != r)
46 fail++;
47 }
48
49 if (fail != 0)
50 abort ();
51 }