summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.target/i386/ssse3-pabsb.c')
-rw-r--r--gcc/testsuite/gcc.target/i386/ssse3-pabsb.c80
1 files changed, 80 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c b/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
new file mode 100644
index 000000000..7caa1b6c3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/ssse3-pabsb.c
@@ -0,0 +1,80 @@
+/* { dg-do run } */
+/* { dg-require-effective-target ssse3 } */
+/* { dg-options "-O2 -fno-strict-aliasing -mssse3" } */
+
+#ifndef CHECK_H
+#define CHECK_H "ssse3-check.h"
+#endif
+
+#ifndef TEST
+#define TEST ssse3_test
+#endif
+
+#include CHECK_H
+
+#include "ssse3-vals.h"
+#include <tmmintrin.h>
+
+#ifndef __AVX__
+/* Test the 64-bit form */
+static void
+ssse3_test_pabsb (int *i1, int *r)
+{
+ __m64 t1 = *(__m64 *) i1;
+ *(__m64 *) r = _mm_abs_pi8 (t1);
+ _mm_empty ();
+}
+#endif
+
+/* Test the 128-bit form */
+static void
+ssse3_test_pabsb128 (int *i1, int *r)
+{
+ /* Assumes incoming pointers are 16-byte aligned */
+ __m128i t1 = *(__m128i *) i1;
+ *(__m128i *) r = _mm_abs_epi8 (t1);
+}
+
+/* Routine to manually compute the results */
+static void
+compute_correct_result (int *i1, int *r)
+{
+ char *b1 = (char *) i1;
+ char *bout = (char *) r;
+ int i;
+
+ for (i = 0; i < 16; i++)
+ if (b1[i] < 0)
+ bout[i] = -b1[i];
+ else
+ bout[i] = b1[i];
+}
+
+static void
+TEST (void)
+{
+ int i;
+ int r [4] __attribute__ ((aligned(16)));
+ int ck [4];
+ int fail = 0;
+
+ for (i = 0; i < 256; i += 4)
+ {
+ /* Manually compute the result */
+ compute_correct_result(&vals[i + 0], ck);
+
+#ifndef __AVX__
+ /* Run the 64-bit tests */
+ ssse3_test_pabsb (&vals[i + 0], &r[0]);
+ ssse3_test_pabsb (&vals[i + 2], &r[2]);
+ fail += chk_128 (ck, r);
+#endif
+
+ /* Run the 128-bit tests */
+ ssse3_test_pabsb128 (&vals[i + 0], r);
+ fail += chk_128 (ck, r);
+ }
+
+ if (fail != 0)
+ abort ();
+}