Debian Codegraph @

gcc/testsuite/gcc.target/powerpc/mmx-packs.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O3 -mvsx" } */
3 /* { dg-additional-options "-mdejagnu-cpu=power8" { target { ! has_arch_pwr8 } } } */
4 /* { dg-require-effective-target p8vector_hw } */
5
6 #define NO_WARN_X86_INTRINSICS 1
7 #include <mmintrin.h>
8 #include "mmx-check.h"
9
10 #ifndef TEST
11 #define TEST mmx_test
12 #endif
13
14 static void
15 __attribute__ ((noinline))
16 check_packs_pu16 (unsigned long long int src1, unsigned long long int src2,
17 unsigned long long int res_ref)
18 {
19 unsigned long long int res;
20
21 res = (unsigned long long int) _mm_packs_pu16 ((__m64 ) src1, (__m64 ) src2);
22
23 if (res != res_ref)
24 abort ();
25 }
26
27 static void
28 __attribute__ ((noinline))
29 check_packs_pi16 (unsigned long long int src1, unsigned long long int src2,
30 unsigned long long int res_ref)
31 {
32 unsigned long long int res;
33
34 res = (unsigned long long int) _mm_packs_pi16 ((__m64 ) src1, (__m64 ) src2);
35
36
37 if (res != res_ref)
38 abort ();
39 }
40
41 static void
42 __attribute__ ((noinline))
43 check_packs_pi32 (unsigned long long int src1, unsigned long long int src2,
44 unsigned long long int res_ref)
45 {
46 unsigned long long int res;
47
48 res = (unsigned long long int) _mm_packs_pi32 ((__m64 ) src1, (__m64 ) src2);
49
50 if (res != res_ref)
51 abort ();
52 }
53
54 static unsigned long long int src1[] =
55 { 0xffff0000fffe0000UL, 0x0001000000020000UL, 0xfffffffffffffffeUL,
56 0x0000000100000002UL, 0x0001000200030004UL, 0xfffffffefffdfffcUL,
57 0x0100020003000400UL, 0xff00fe01fe02fe03UL };
58
59 static unsigned long long int src2[] =
60 { 0xfffffffdfffffffcUL, 0x0000000200000003UL, 0xfffffffdfffffffcUL,
61 0x0000000300000004UL, 0x0005000600070008UL, 0xfffbfffafff9fff8UL,
62 0x0005000600070008UL, 0xfffbfffafff9fff8UL };
63
64 static unsigned long long int res_pi16[] =
65 { 0xfffdfffcff00fe00UL, 0x0002000301000200UL, 0xfffdfffcfffffffeUL,
66 0x0003000400010002UL, 0x0506070801020304UL, 0xfbfaf9f8fffefdfcUL,
67 0x050607087f7f7f7fUL, 0xfbfaf9f880808080UL };
68
69 static unsigned long long int res_pi32[] =
70 { 0xfffdfffc80008000UL, 0x000200037fff7fffUL, 0xfffdfffcfffffffeUL,
71 0x0003000400010002UL, 0x7fff7fff7fff7fffUL, 0x80008000fffe8000UL,
72 0x7fff7fff7fff7fffUL, 0x8000800080008000UL };
73
74 static unsigned long long int res_pu16[] =
75 { 0x0000000000000000UL, 0x0002000301000200UL, 0x0000000000000000UL,
76 0x0003000400010002UL, 0x0506070801020304UL, 0x000000000000000UL,
77 0x5060708ffffffffUL, 0x0000000000000000UL };
78
79 static void
80 TEST ()
81 {
82 long i;
83
84 for (i = 0; i < 8; i++)
85 {
86 check_packs_pu16 (src1[i], src2[i], res_pu16[i]);
87 check_packs_pi16 (src1[i], src2[i], res_pi16[i]);
88 check_packs_pi32 (src1[i], src2[i], res_pi32[i]);
89 }
90 }
91