summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.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/powerpc/altivec-cell-2.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/powerpc/altivec-cell-2.c')
-rw-r--r--gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c b/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c
new file mode 100644
index 000000000..fdb375c9e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/altivec-cell-2.c
@@ -0,0 +1,141 @@
+/* { dg-do run { target { powerpc*-*-* && vmx_hw } } } */
+/* { dg-do compile { target { powerpc*-*-* && { ! vmx_hw } } } } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec" } */
+/* Test the vec_extract VMX intrinsics. */
+#include <altivec.h>
+
+extern void abort (void);
+
+vector int a = {0, 1, 2, 3};
+vector short b = {0, 1, 2, 3, 4, 5, 6, 7};
+
+int f(vector int a, int b)
+{
+ return vec_extract (a, b);
+}
+
+int f0 (vector int a)
+{
+ return vec_extract (a, 0);
+}
+int f1 (vector int a)
+{
+ return vec_extract (a, 1);
+}
+int f2 (vector int a)
+{
+ return vec_extract (a, 2);
+}
+int f3 (vector int a)
+{
+ return vec_extract (a, 3);
+}
+int f4 (vector int a)
+{
+ return vec_extract (a, 4);
+}
+
+int g(vector short a, int b)
+{
+ return vec_extract (a, b);
+}
+
+int g0 (vector short a)
+{
+ return vec_extract (a, 0);
+}
+int g1 (vector short a)
+{
+ return vec_extract (a, 1);
+}
+int g2 (vector short a)
+{
+ return vec_extract (a, 2);
+}
+int g3 (vector short a)
+{
+ return vec_extract (a, 3);
+}
+
+int g4 (vector short a)
+{
+ return vec_extract (a, 4);
+}
+int g5 (vector short a)
+{
+ return vec_extract (a, 5);
+}
+int g6 (vector short a)
+{
+ return vec_extract (a, 6);
+}
+int g7 (vector short a)
+{
+ return vec_extract (a, 7);
+}
+int g8 (vector short a)
+{
+ return vec_extract (a, 8);
+}
+int main1(void) __attribute__((noinline));
+int main1(void)
+{
+ int i;
+ /* Check vec_extract with a non constant element numbering */
+ for(i=0;i<10;i++)
+ {
+ if (f(a, i) != (i&0x3))
+ abort ();
+ }
+
+ /* Check vec_extract with a constant element numbering */
+ if (f0(a) != 0)
+ abort ();
+ if (f1(a) != 1)
+ abort ();
+ if (f2(a) != 2)
+ abort ();
+ if (f3(a) != 3)
+ abort ();
+ /* Check that vec_extract works with a constant element higher than
+ the number of elements. */
+ if (f4(a) != 0)
+ abort ();
+
+ /* Check vec_extract with a non constant element numbering */
+ for(i=0;i<10;i++)
+ {
+ if (g(b, i) != (i&0x7))
+ abort ();
+ }
+
+ /* Check vec_extract with a constant element numbering */
+ if (g0(b) != 0)
+ abort ();
+ if (g1(b) != 1)
+ abort ();
+ if (g2(b) != 2)
+ abort ();
+ if (g3(b) != 3)
+ abort ();
+ if (g4(b) != 4)
+ abort ();
+ if (g5(b) != 5)
+ abort ();
+ if (g6(b) != 6)
+ abort ();
+ if (g7(b) != 7)
+ abort ();
+ /* Check that vec_extract works with a constant element higher than
+ the number of elements. */
+ if (g8(b) != 0)
+ abort ();
+
+ return 0;
+}
+
+int main(void)
+{
+ return main1 ();
+}