summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/sse4a-extract.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/sse4a-extract.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/sse4a-extract.c')
-rw-r--r--gcc/testsuite/gcc.target/i386/sse4a-extract.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/i386/sse4a-extract.c b/gcc/testsuite/gcc.target/i386/sse4a-extract.c
new file mode 100644
index 000000000..5fb190e44
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/sse4a-extract.c
@@ -0,0 +1,84 @@
+/* { dg-do run } */
+/* { dg-require-effective-target sse4a } */
+/* { dg-options "-O2 -msse4a" } */
+
+#include "sse4a-check.h"
+
+#include <ammintrin.h>
+
+typedef union
+{
+ long long i[2];
+ __m128i vec;
+} LI;
+
+static long long
+sse4a_test_extrq (long long in)
+{
+ __m128i v1, v2;
+ long long index_length, pad;
+ LI v_out;
+ index_length = 0x0000000000000810LL;
+ pad = 0x0;
+ v1 = _mm_set_epi64x (pad, in);
+ v2 = _mm_set_epi64x (pad, index_length);
+ v_out.vec = _mm_extract_si64 (v1, v2);
+ return (v_out.i[0]);
+}
+
+static long long
+sse4a_test_extrqi (long long in)
+{
+ __m128i v1;
+ long long pad =0x0;
+ LI v_out;
+ v1 = _mm_set_epi64x (pad, in);
+ v_out.vec = _mm_extracti_si64 (v1, (unsigned int) 0x10,(unsigned int) 0x08);
+ return (v_out.i[0]);
+}
+
+static chk (long long i1, long long i2)
+{
+ int n_fails =0;
+ if (i1 != i2)
+ n_fails +=1;
+ return n_fails;
+}
+
+long long vals_in[5] =
+ {
+ 0x1234567887654321LL,
+ 0x1456782093002490LL,
+ 0x2340909123990390LL,
+ 0x9595959599595999LL,
+ 0x9099038798000029LL
+ };
+
+long long vals_out[5] =
+ {
+ 0x0000000000006543LL,
+ 0x0000000000000024LL,
+ 0x0000000000009903LL,
+ 0x0000000000005959LL,
+ 0x0000000000000000LL
+ };
+
+static void
+sse4a_test (void)
+{
+ int i;
+ int fail = 0;
+ long long out;
+
+ for (i = 0; i < 5; i += 1)
+ {
+ out = sse4a_test_extrq (vals_in[i]);
+ fail += chk(out, vals_out[i]);
+
+ out = sse4a_test_extrqi (vals_in[i]);
+ fail += chk(out, vals_out[i]);
+ }
+
+ if (fail != 0)
+ abort ();
+}