Merged with mainline at revision 128810.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / ssse3-pabsd.c
blobe677cc50fa8d9ddb0687e29801bbb7651585c8b9
1 /* { dg-do run } */
2 /* { dg-require-effective-target ssse3 } */
3 /* { dg-options "-O2 -mssse3" } */
5 #include "ssse3-check.h"
6 #include "ssse3-vals.h"
8 #include <tmmintrin.h>
10 /* Test the 64-bit form */
11 static void
12 ssse3_test_pabsd (int *i1, int *r)
14 __m64 t1 = *(__m64 *) i1;
15 *(__m64 *) r = _mm_abs_pi32 (t1);
16 _mm_empty ();
19 /* Test the 128-bit form */
20 static void
21 ssse3_test_pabsd128 (int *i1, int *r)
23 /* Assumes incoming pointers are 16-byte aligned */
24 __m128i t1 = *(__m128i *) i1;
25 *(__m128i *) r = _mm_abs_epi32 (t1);
28 /* Routine to manually compute the results */
29 static void
30 compute_correct_result (int *i1, int *r)
32 int i;
34 for (i = 0; i < 4; i++)
35 if (i1[i] < 0)
36 r[i] = -i1[i];
37 else
38 r[i] = i1[i];
41 static void
42 ssse3_test (void)
44 int i;
45 int r [4] __attribute__ ((aligned(16)));
46 int ck [4];
47 int fail = 0;
49 for (i = 0; i < 256; i += 4)
51 /* Manually compute the result */
52 compute_correct_result(&vals[i + 0], ck);
54 /* Run the 64-bit tests */
55 ssse3_test_pabsd (&vals[i + 0], &r[0]);
56 ssse3_test_pabsd (&vals[i + 2], &r[2]);
57 fail += chk_128 (ck, r);
59 /* Run the 128-bit tests */
60 ssse3_test_pabsd128 (&vals[i + 0], r);
61 fail += chk_128(ck, r);
64 if (fail != 0)
65 abort ();