diff options
author | wilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-02 19:14:57 +0000 |
---|---|---|
committer | wilson <wilson@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-02 19:14:57 +0000 |
commit | 0a18b2487befe394eea9c4acd8a4cc1214a15843 (patch) | |
tree | 97cd0fbe3364f74f8068866f56af35f579dae781 | |
parent | ea66a04812556c7906579dea8d9b6abe412b6199 (diff) | |
download | gcc-0a18b2487befe394eea9c4acd8a4cc1214a15843.tar.gz |
Add MIPS-3D and MIPS PS testcases from Chao-ying Fu.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86982 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/testsuite/ChangeLog | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-1.c | 127 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-2.c | 554 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-3.c | 1095 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-4.c | 590 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-5.c | 590 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-6.c | 284 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-7.c | 284 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-8.c | 630 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-3d-9.c | 158 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-ps-1.c | 271 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-ps-2.c | 134 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-ps-3.c | 737 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-ps-4.c | 583 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips-ps-type.c | 110 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/mips/mips.exp | 41 |
16 files changed, 6205 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d1915c175e7..011aeff3255 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,20 @@ +2004-09-02 Chao-ying Fu <fu@mips.com> + + * gcc.target/mips/mips-3d-1.c: New test. + * gcc.target/mips/mips-3d-2.c: New test. + * gcc.target/mips/mips-3d-3.c: New test. + * gcc.target/mips/mips-3d-4.c: New test. + * gcc.target/mips/mips-3d-5.c: New test. + * gcc.target/mips/mips-3d-6.c: New test. + * gcc.target/mips/mips-3d-7.c: New test. + * gcc.target/mips/mips-3d-8.c: New test. + * gcc.target/mips/mips-3d-9.c: New test. + * gcc.target/mips/mips-ps-1.c: New test. + * gcc.target/mips/mips-ps-2.c: New test. + * gcc.target/mips/mips-ps-3.c: New test. + * gcc.target/mips/mips-ps-4.c: New test. + * gcc.target/mips/mips-ps-type.c: New test. + 2004-09-02 Paul Brook <paul@codesourcery.com> * gfortran.dg/edit_real_1.f90: Add new tests. diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-1.c b/gcc/testsuite/gcc.target/mips/mips-3d-1.c new file mode 100644 index 00000000000..c351d8c63a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-1.c @@ -0,0 +1,127 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size(8))); + +int main () +{ + int little_endian; + v2sf a, b, c, d; + float f1, f2, f3, f4, f5, f6; + double d1, d2, d3, d4, d5, d6, d7, d8, d9; + v2sf ps1, ps2, ps3, ps4, ps5, ps6; + + union { long long ll; int i[2]; } endianness_test; + endianness_test.ll = 1; + little_endian = endianness_test.i[0]; + + /* addr.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {45, 67}; + c = __builtin_mips_addr_ps (a, b); + if (little_endian) + d = (v2sf) {112, 46}; + else + d = (v2sf) {46, 112}; + + if (!__builtin_mips_all_c_eq_ps(c, d)) + abort (); + + /* mulr.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {45, 67}; + c = __builtin_mips_mulr_ps (a, b); + if (little_endian) + d = (v2sf) {3015, 408}; + else + d = (v2sf) {408, 3015}; + + if (!__builtin_mips_all_c_eq_ps(c, d)) + abort (); + + /* cvt.pw.ps */ + a = (v2sf) {12345.34, 67890.45}; + b = __builtin_mips_cvt_pw_ps (a); + + /* cvt.ps.pw */ + c = __builtin_mips_cvt_ps_pw (b); + d = (v2sf) {12345.0, 67890.0}; + + if (!__builtin_mips_all_c_eq_ps(c, d)) + abort (); + + /* recip1.s recip2.s */ + f1 = 40; + f2 = __builtin_mips_recip1_s (f1); + f3 = __builtin_mips_recip2_s (f2, f1); + f4 = f2 + f2 * f3; + f5 = 0.025; + + if (f4 != f5) + abort (); + + /* recip1.d recip2.d */ + d1 = 80; + d2 = __builtin_mips_recip1_d (d1); + d3 = __builtin_mips_recip2_d (d2, d1); + d4 = d2 + d2 * d3; + d5 = __builtin_mips_recip2_d (d4, d1); + d6 = d4 + d4 * d5; + d7 = 0.0125; + + if (d6 != d7) + abort (); + + /* recip1.ps recip2.ps */ + ps1 = (v2sf) {100, 200}; + ps2 = __builtin_mips_recip1_ps (ps1); + ps3 = __builtin_mips_recip2_ps (ps2, ps1); + ps4 = ps2 + ps2 * ps3; + ps5 = (v2sf) {0.01, 0.005}; + + if (!__builtin_mips_all_c_eq_ps(ps4, ps5)) + abort (); + + /* rsqrt1.s rsqrt2.s */ + f1 = 400; + f2 = __builtin_mips_rsqrt1_s (f1); + f3 = f2 * f1; + f4 = __builtin_mips_rsqrt2_s (f3, f2); + f5 = f2 + f2 * f4; + f6 = 0.05; + + if (f5 != f6) + abort (); + + /* rsqrt1.d rsqrt2.d */ + d1 = 1600; + d2 = __builtin_mips_rsqrt1_d (d1); + d3 = d2 * d1; + d4 = __builtin_mips_rsqrt2_d (d3, d2); + d5 = d2 + d2 * d4; + d6 = d1 * d5; + d7 = __builtin_mips_rsqrt2_d (d6, d5); + d8 = d5 + d5 * d7; + d9 = 0.025; + + if (d8 != d9) + abort (); + + /* rsqrt1.ps rsqrt2.ps */ + ps1 = (v2sf) {400, 100}; + ps2 = __builtin_mips_rsqrt1_ps (ps1); + ps3 = ps2 * ps1; + ps4 = __builtin_mips_rsqrt2_ps (ps3, ps2); + ps5 = ps2 + ps2 * ps4; + ps6 = (v2sf) {0.05, 0.1}; + + if (!__builtin_mips_all_c_eq_ps(ps5, ps6)) + abort (); + + printf ("Test Passes\n"); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-2.c b/gcc/testsuite/gcc.target/mips/mips-3d-2.c new file mode 100644 index 00000000000..e34022c7a49 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-2.c @@ -0,0 +1,554 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D branch-if-any-two builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size(8))); + +int test0 (v2sf a, v2sf b); +int test1 (v2sf a, v2sf b); +int test2 (v2sf a, v2sf b); +int test3 (v2sf a, v2sf b); +int test4 (v2sf a, v2sf b); +int test5 (v2sf a, v2sf b); +int test6 (v2sf a, v2sf b); +int test7 (v2sf a, v2sf b); +int test8 (v2sf a, v2sf b); +int test9 (v2sf a, v2sf b); +int test10 (v2sf a, v2sf b); +int test11 (v2sf a, v2sf b); +int test12 (v2sf a, v2sf b); +int test13 (v2sf a, v2sf b); +int test14 (v2sf a, v2sf b); +int test15 (v2sf a, v2sf b); +int test16 (v2sf a, v2sf b); +int test17 (v2sf a, v2sf b); +int test18 (v2sf a, v2sf b); +int test19 (v2sf a, v2sf b); +int test20 (v2sf a, v2sf b); +int test21 (v2sf a, v2sf b); +int test22 (v2sf a, v2sf b); +int test23 (v2sf a, v2sf b); +int test24 (v2sf a, v2sf b); +int test25 (v2sf a, v2sf b); +int test26 (v2sf a, v2sf b); +int test27 (v2sf a, v2sf b); +int test28 (v2sf a, v2sf b); +int test29 (v2sf a, v2sf b); +int test30 (v2sf a, v2sf b); +int test31 (v2sf a, v2sf b); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main () +{ + v2sf a, b, c, d; + int i, j; + + /* c.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {56, 78}; + i = 0; + j = 0; + if (__builtin_mips_any_c_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_all_c_eq_ps(a, b) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {12, 78}; + i = 1; + j = 0; + if (__builtin_mips_any_c_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_all_c_eq_ps(a, b) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {56, 34}; + i = 1; + j = 0; + if (__builtin_mips_any_c_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_all_c_eq_ps(a, b) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {12, 34}; + i = 1; + j = 1; + if (__builtin_mips_any_c_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_all_c_eq_ps(a, b) != j) + abort (); + + /* Test with 16 operators */ + a = (v2sf) {10.58, 1984.0}; + b = (v2sf) {567.345, 1984.0}; + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 0) + abort (); + i = test4 (a, b); + if (i != 1) + abort (); + i = test5 (a, b); + if (i != 0) + abort (); + i = test6 (a, b); + if (i != 1) + abort (); + i = test7 (a, b); + if (i != 0) + abort (); + i = test8 (a, b); + if (i != 1) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 1) + abort (); + i = test11 (a, b); + if (i != 0) + abort (); + i = test12 (a, b); + if (i != 1) + abort (); + i = test13 (a, b); + if (i != 1) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + i = test16 (a, b); + if (i != 0) + abort (); + i = test17 (a, b); + if (i != 0) + abort (); + i = test18 (a, b); + if (i != 0) + abort (); + i = test19 (a, b); + if (i != 0) + abort (); + i = test20 (a, b); + if (i != 1) + abort (); + i = test21 (a, b); + if (i != 0) + abort (); + i = test22 (a, b); + if (i != 1) + abort (); + i = test23 (a, b); + if (i != 0) + abort (); + i = test24 (a, b); + if (i != 1) + abort (); + i = test25 (a, b); + if (i != 0) + abort (); + i = test26 (a, b); + if (i != 1) + abort (); + i = test27 (a, b); + if (i != 0) + abort (); + i = test28 (a, b); + if (i != 1) + abort (); + i = test29 (a, b); + if (i != 1) + abort (); + i = test30 (a, b); + if (i != 1) + abort (); + i = test31 (a, b); + if (i != 1) + abort (); + + /* Reverse arguments */ + i = test0 (b, a); + if (i != 0) + abort (); + i = test1 (b, a); + if (i != 0) + abort (); + i = test2 (b, a); + if (i != 0) + abort (); + i = test3 (b, a); + if (i != 0) + abort (); + i = test4 (b, a); + if (i != 1) + abort (); + i = test5 (b, a); + if (i != 0) + abort (); + i = test6 (b, a); + if (i != 1) + abort (); + i = test7 (b, a); + if (i != 0) + abort (); + i = test8 (b, a); + if (i != 0) + abort (); + i = test9 (b, a); + if (i != 0) + abort (); + i = test10 (b, a); + if (i != 0) + abort (); + i = test11 (b, a); + if (i != 0) + abort (); + i = test12 (b, a); + if (i != 1) + abort (); + i = test13 (b, a); + if (i != 0) + abort (); + i = test14 (b, a); + if (i != 1) + abort (); + i = test15 (b, a); + if (i != 0) + abort (); + i = test16 (b, a); + if (i != 0) + abort (); + i = test17 (b, a); + if (i != 0) + abort (); + i = test18 (b, a); + if (i != 0) + abort (); + i = test19 (b, a); + if (i != 0) + abort (); + i = test20 (b, a); + if (i != 1) + abort (); + i = test21 (b, a); + if (i != 0) + abort (); + i = test22 (b, a); + if (i != 1) + abort (); + i = test23 (b, a); + if (i != 0) + abort (); + i = test24 (b, a); + if (i != 0) + abort (); + i = test25 (b, a); + if (i != 0) + abort (); + i = test26 (b, a); + if (i != 0) + abort (); + i = test27 (b, a); + if (i != 0) + abort (); + i = test28 (b, a); + if (i != 1) + abort (); + i = test29 (b, a); + if (i != 0) + abort (); + i = test30 (b, a); + if (i != 1) + abort (); + i = test31 (b, a); + if (i != 0) + abort (); + +#ifndef __FAST_MATH__ + /* Test with 16 operators */ + a = (v2sf) {qnan, qnan}; + b = (v2sf) {567.345, 1984.0}; + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 1) + abort (); + i = test3 (a, b); + if (i != 1) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 0) + abort (); + i = test6 (a, b); + if (i != 1) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 1) + abort (); + i = test11 (a, b); + if (i != 1) + abort (); + i = test12 (a, b); + if (i != 0) + abort (); + i = test13 (a, b); + if (i != 0) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + i = test16 (a, b); + if (i != 0) + abort (); + i = test17 (a, b); + if (i != 0) + abort (); + i = test18 (a, b); + if (i != 1) + abort (); + i = test19 (a, b); + if (i != 1) + abort (); + i = test20 (a, b); + if (i != 0) + abort (); + i = test21 (a, b); + if (i != 0) + abort (); + i = test22 (a, b); + if (i != 1) + abort (); + i = test23 (a, b); + if (i != 1) + abort (); + i = test24 (a, b); + if (i != 0) + abort (); + i = test25 (a, b); + if (i != 0) + abort (); + i = test26 (a, b); + if (i != 1) + abort (); + i = test27 (a, b); + if (i != 1) + abort (); + i = test28 (a, b); + if (i != 0) + abort (); + i = test29 (a, b); + if (i != 0) + abort (); + i = test30 (a, b); + if (i != 1) + abort (); + i = test31 (a, b); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_f_ps (a, b); +} + +int test1 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_f_ps (a, b); +} + +int test2 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_un_ps (a, b); +} + +int test3 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_un_ps (a, b); +} + +int test4 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_eq_ps (a, b); +} + +int test5 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_eq_ps (a, b); +} + +int test6 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ueq_ps (a, b); +} + +int test7 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ueq_ps (a, b); +} + +int test8 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_olt_ps (a, b); +} + +int test9 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_olt_ps (a, b); +} + +int test10 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ult_ps (a, b); +} + +int test11 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ult_ps (a, b); +} + +int test12 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ole_ps (a, b); +} + +int test13 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ole_ps (a, b); +} + +int test14 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ule_ps (a, b); +} + +int test15 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ule_ps (a, b); +} + +int test16 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_sf_ps (a, b); +} + +int test17 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_sf_ps (a, b); +} + +int test18 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ngle_ps (a, b); +} + +int test19 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ngle_ps (a, b); +} + +int test20 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_seq_ps (a, b); +} + +int test21 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_seq_ps (a, b); +} + +int test22 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ngl_ps (a, b); +} + +int test23 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ngl_ps (a, b); +} + +int test24 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_lt_ps (a, b); +} + +int test25 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_lt_ps (a, b); +} + +int test26 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_nge_ps (a, b); +} + +int test27 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_nge_ps (a, b); +} + +int test28 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_le_ps (a, b); +} + +int test29 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_le_ps (a, b); +} + +int test30 (v2sf a, v2sf b) +{ + return __builtin_mips_any_c_ngt_ps (a, b); +} + +int test31 (v2sf a, v2sf b) +{ + return __builtin_mips_all_c_ngt_ps (a, b); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-3.c b/gcc/testsuite/gcc.target/mips/mips-3d-3.c new file mode 100644 index 00000000000..7044fc952f0 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-3.c @@ -0,0 +1,1095 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D absolute compare builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size(8))); + +int test0 (v2sf a, v2sf b); +int test1 (v2sf a, v2sf b); +int test2 (v2sf a, v2sf b); +int test3 (v2sf a, v2sf b); +int test4 (v2sf a, v2sf b); +int test5 (v2sf a, v2sf b); +int test6 (v2sf a, v2sf b); +int test7 (v2sf a, v2sf b); +int test8 (v2sf a, v2sf b); +int test9 (v2sf a, v2sf b); +int test10 (v2sf a, v2sf b); +int test11 (v2sf a, v2sf b); +int test12 (v2sf a, v2sf b); +int test13 (v2sf a, v2sf b); +int test14 (v2sf a, v2sf b); +int test15 (v2sf a, v2sf b); +int test16 (v2sf a, v2sf b); +int test17 (v2sf a, v2sf b); +int test18 (v2sf a, v2sf b); +int test19 (v2sf a, v2sf b); +int test20 (v2sf a, v2sf b); +int test21 (v2sf a, v2sf b); +int test22 (v2sf a, v2sf b); +int test23 (v2sf a, v2sf b); +int test24 (v2sf a, v2sf b); +int test25 (v2sf a, v2sf b); +int test26 (v2sf a, v2sf b); +int test27 (v2sf a, v2sf b); +int test28 (v2sf a, v2sf b); +int test29 (v2sf a, v2sf b); +int test30 (v2sf a, v2sf b); +int test31 (v2sf a, v2sf b); +int test32 (v2sf a, v2sf b); +int test33 (v2sf a, v2sf b); +int test34 (v2sf a, v2sf b); +int test35 (v2sf a, v2sf b); +int test36 (v2sf a, v2sf b); +int test37 (v2sf a, v2sf b); +int test38 (v2sf a, v2sf b); +int test39 (v2sf a, v2sf b); +int test40 (v2sf a, v2sf b); +int test41 (v2sf a, v2sf b); +int test42 (v2sf a, v2sf b); +int test43 (v2sf a, v2sf b); +int test44 (v2sf a, v2sf b); +int test45 (v2sf a, v2sf b); +int test46 (v2sf a, v2sf b); +int test47 (v2sf a, v2sf b); +int test48 (v2sf a, v2sf b); +int test49 (v2sf a, v2sf b); +int test50 (v2sf a, v2sf b); +int test51 (v2sf a, v2sf b); +int test52 (v2sf a, v2sf b); +int test53 (v2sf a, v2sf b); +int test54 (v2sf a, v2sf b); +int test55 (v2sf a, v2sf b); +int test56 (v2sf a, v2sf b); +int test57 (v2sf a, v2sf b); +int test58 (v2sf a, v2sf b); +int test59 (v2sf a, v2sf b); +int test60 (v2sf a, v2sf b); +int test61 (v2sf a, v2sf b); +int test62 (v2sf a, v2sf b); +int test63 (v2sf a, v2sf b); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main () +{ + int little_endian; + v2sf a, b, c, d; + int i, j, k, l; + + union { long long ll; int i[2]; } endianness_test; + endianness_test.ll = 1; + little_endian = endianness_test.i[0]; + + /* cabs.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {-56, -78}; + i = 0; + j = 0; + k = 0; + l = 0; + if (__builtin_mips_any_cabs_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_upper_cabs_eq_ps(a, b) != j) + abort (); + if (__builtin_mips_lower_cabs_eq_ps(a, b) != k) + abort (); + if (__builtin_mips_all_cabs_eq_ps(a, b) != l) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {-12, -78}; + i = 1; + if (little_endian) + { + j = 0; + k = 1; + } + else + { + j = 1; + k = 0; + } + l = 0; + if (__builtin_mips_any_cabs_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_upper_cabs_eq_ps(a, b) != j) + abort (); + if (__builtin_mips_lower_cabs_eq_ps(a, b) != k) + abort (); + if (__builtin_mips_all_cabs_eq_ps(a, b) != l) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {-56, -34}; + i = 1; + if (little_endian) + { + j = 1; + k = 0; + } + else + { + j = 0; + k = 1; + } + l = 0; + if (__builtin_mips_any_cabs_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_upper_cabs_eq_ps(a, b) != j) + abort (); + if (__builtin_mips_lower_cabs_eq_ps(a, b) != k) + abort (); + if (__builtin_mips_all_cabs_eq_ps(a, b) != l) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {12, 34}; + b = (v2sf) {-12, -34}; + i = 1; + j = 1; + k = 1; + l = 1; + if (__builtin_mips_any_cabs_eq_ps(a, b) != i) + abort (); + if (__builtin_mips_upper_cabs_eq_ps(a, b) != j) + abort (); + if (__builtin_mips_lower_cabs_eq_ps(a, b) != k) + abort (); + if (__builtin_mips_all_cabs_eq_ps(a, b) != l) + abort (); + + /* Test all comparisons */ + if (little_endian) + { + a = (v2sf) {1984.0, 10.58}; + b = (v2sf) {-1984.0, -567.345}; + } + else + { + a = (v2sf) {10.58, 1984.0}; + b = (v2sf) {-567.345, -1984.0}; + } + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 0) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 0) + abort (); + i = test6 (a, b); + if (i != 0) + abort (); + i = test7 (a, b); + if (i != 0) + abort (); + i = test8 (a, b); + if (i != 1) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 1) + abort (); + i = test11 (a, b); + if (i != 0) + abort (); + i = test12 (a, b); + if (i != 1) + abort (); + i = test13 (a, b); + if (i != 0) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 0) + abort (); + i = test16 (a, b); + if (i != 1) + abort (); + i = test17 (a, b); + if (i != 1) + abort (); + i = test18 (a, b); + if (i != 0) + abort (); + i = test19 (a, b); + if (i != 0) + abort (); + i = test20 (a, b); + if (i != 1) + abort (); + i = test21 (a, b); + if (i != 1) + abort (); + i = test22 (a, b); + if (i != 0) + abort (); + i = test23 (a, b); + if (i != 0) + abort (); + i = test24 (a, b); + if (i != 1) + abort (); + i = test25 (a, b); + if (i != 1) + abort (); + i = test26 (a, b); + if (i != 1) + abort (); + i = test27 (a, b); + if (i != 1) + abort (); + i = test28 (a, b); + if (i != 1) + abort (); + i = test29 (a, b); + if (i != 1) + abort (); + i = test30 (a, b); + if (i != 1) + abort (); + i = test31 (a, b); + if (i != 1) + abort (); + i = test32 (a, b); + if (i != 0) + abort (); + i = test33 (a, b); + if (i != 0) + abort (); + i = test34 (a, b); + if (i != 0) + abort (); + i = test35 (a, b); + if (i != 0) + abort (); + i = test36 (a, b); + if (i != 0) + abort (); + i = test37 (a, b); + if (i != 0) + abort (); + i = test38 (a, b); + if (i != 0) + abort (); + i = test39 (a, b); + if (i != 0) + abort (); + i = test40 (a, b); + if (i != 1) + abort (); + i = test41 (a, b); + if (i != 0) + abort (); + i = test42 (a, b); + if (i != 1) + abort (); + i = test43 (a, b); + if (i != 0) + abort (); + i = test44 (a, b); + if (i != 1) + abort (); + i = test45 (a, b); + if (i != 0) + abort (); + i = test46 (a, b); + if (i != 1) + abort (); + i = test47 (a, b); + if (i != 0) + abort (); + i = test48 (a, b); + if (i != 1) + abort (); + i = test49 (a, b); + if (i != 1) + abort (); + i = test50 (a, b); + if (i != 0) + abort (); + i = test51 (a, b); + if (i != 0) + abort (); + i = test52 (a, b); + if (i != 1) + abort (); + i = test53 (a, b); + if (i != 1) + abort (); + i = test54 (a, b); + if (i != 0) + abort (); + i = test55 (a, b); + if (i != 0) + abort (); + i = test56 (a, b); + if (i != 1) + abort (); + i = test57 (a, b); + if (i != 1) + abort (); + i = test58 (a, b); + if (i != 1) + abort (); + i = test59 (a, b); + if (i != 1) + abort (); + i = test60 (a, b); + if (i != 1) + abort (); + i = test61 (a, b); + if (i != 1) + abort (); + i = test62 (a, b); + if (i != 1) + abort (); + i = test63 (a, b); + if (i != 1) + abort (); + + /* Reverse arguments */ + i = test0 (b, a); + if (i != 0) + abort (); + i = test1 (b, a); + if (i != 0) + abort (); + i = test2 (b, a); + if (i != 0) + abort (); + i = test3 (b, a); + if (i != 0) + abort (); + i = test4 (b, a); + if (i != 0) + abort (); + i = test5 (b, a); + if (i != 0) + abort (); + i = test6 (b, a); + if (i != 0) + abort (); + i = test7 (b, a); + if (i != 0) + abort (); + i = test8 (b, a); + if (i != 1) + abort (); + i = test9 (b, a); + if (i != 0) + abort (); + i = test10 (b, a); + if (i != 1) + abort (); + i = test11 (b, a); + if (i != 0) + abort (); + i = test12 (b, a); + if (i != 1) + abort (); + i = test13 (b, a); + if (i != 0) + abort (); + i = test14 (b, a); + if (i != 1) + abort (); + i = test15 (b, a); + if (i != 0) + abort (); + i = test16 (b, a); + if (i != 0) + abort (); + i = test17 (b, a); + if (i != 0) + abort (); + i = test18 (b, a); + if (i != 0) + abort (); + i = test19 (b, a); + if (i != 0) + abort (); + i = test20 (b, a); + if (i != 0) + abort (); + i = test21 (b, a); + if (i != 0) + abort (); + i = test22 (b, a); + if (i != 0) + abort (); + i = test23 (b, a); + if (i != 0) + abort (); + i = test24 (b, a); + if (i != 1) + abort (); + i = test25 (b, a); + if (i != 0) + abort (); + i = test26 (b, a); + if (i != 1) + abort (); + i = test27 (b, a); + if (i != 0) + abort (); + i = test28 (b, a); + if (i != 1) + abort (); + i = test29 (b, a); + if (i != 0) + abort (); + i = test30 (b, a); + if (i != 1) + abort (); + i = test31 (b, a); + if (i != 0) + abort (); + i = test32 (b, a); + if (i != 0) + abort (); + i = test33 (b, a); + if (i != 0) + abort (); + i = test34 (b, a); + if (i != 0) + abort (); + i = test35 (b, a); + if (i != 0) + abort (); + i = test36 (b, a); + if (i != 0) + abort (); + i = test37 (b, a); + if (i != 0) + abort (); + i = test38 (b, a); + if (i != 0) + abort (); + i = test39 (b, a); + if (i != 0) + abort (); + i = test40 (b, a); + if (i != 1) + abort (); + i = test41 (b, a); + if (i != 0) + abort (); + i = test42 (b, a); + if (i != 1) + abort (); + i = test43 (b, a); + if (i != 0) + abort (); + i = test44 (b, a); + if (i != 1) + abort (); + i = test45 (b, a); + if (i != 0) + abort (); + i = test46 (b, a); + if (i != 1) + abort (); + i = test47 (b, a); + if (i != 0) + abort (); + i = test48 (b, a); + if (i != 0) + abort (); + i = test49 (b, a); + if (i != 0) + abort (); + i = test50 (b, a); + if (i != 0) + abort (); + i = test51 (b, a); + if (i != 0) + abort (); + i = test52 (b, a); + if (i != 0) + abort (); + i = test53 (b, a); + if (i != 0) + abort (); + i = test54 (b, a); + if (i != 0) + abort (); + i = test55 (b, a); + if (i != 0) + abort (); + i = test56 (b, a); + if (i != 1) + abort (); + i = test57 (b, a); + if (i != 0) + abort (); + i = test58 (b, a); + if (i != 1) + abort (); + i = test59 (b, a); + if (i != 0) + abort (); + i = test60 (b, a); + if (i != 1) + abort (); + i = test61 (b, a); + if (i != 0) + abort (); + i = test62 (b, a); + if (i != 1) + abort (); + i = test63 (b, a); + if (i != 0) + abort (); + +#ifndef __FAST_MATH__ + /* Test all comparisons */ + if (little_endian) + { + a = (v2sf) {qnan, qnan}; + b = (v2sf) {-1984.0, -567.345}; + } + else + { + a = (v2sf) {qnan, qnan}; + b = (v2sf) {-567.345, -1984.0}; + } + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 0) + abort (); + i = test4 (a, b); + if (i != 1) + abort (); + i = test5 (a, b); + if (i != 1) + abort (); + i = test6 (a, b); + if (i != 1) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 0) + abort (); + i = test11 (a, b); + if (i != 0) + abort (); + i = test12 (a, b); + if (i != 1) + abort (); + i = test13 (a, b); + if (i != 1) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + i = test16 (a, b); + if (i != 0) + abort (); + i = test17 (a, b); + if (i != 0) + abort (); + i = test18 (a, b); + if (i != 0) + abort (); + i = test19 (a, b); + if (i != 0) + abort (); + i = test20 (a, b); + if (i != 1) + abort (); + i = test21 (a, b); + if (i != 1) + abort (); + i = test22 (a, b); + if (i != 1) + abort (); + i = test23 (a, b); + if (i != 1) + abort (); + i = test24 (a, b); + if (i != 0) + abort (); + i = test25 (a, b); + if (i != 0) + abort (); + i = test26 (a, b); + if (i != 0) + abort (); + i = test27 (a, b); + if (i != 0) + abort (); + i = test28 (a, b); + if (i != 1) + abort (); + i = test29 (a, b); + if (i != 1) + abort (); + i = test30 (a, b); + if (i != 1) + abort (); + i = test31 (a, b); + if (i != 1) + abort (); + i = test32 (a, b); + if (i != 0) + abort (); + i = test33 (a, b); + if (i != 0) + abort (); + i = test34 (a, b); + if (i != 0) + abort (); + i = test35 (a, b); + if (i != 0) + abort (); + i = test36 (a, b); + if (i != 1) + abort (); + i = test37 (a, b); + if (i != 1) + abort (); + i = test38 (a, b); + if (i != 1) + abort (); + i = test39 (a, b); + if (i != 1) + abort (); + i = test40 (a, b); + if (i != 0) + abort (); + i = test41 (a, b); + if (i != 0) + abort (); + i = test42 (a, b); + if (i != 0) + abort (); + i = test43 (a, b); + if (i != 0) + abort (); + i = test44 (a, b); + if (i != 1) + abort (); + i = test45 (a, b); + if (i != 1) + abort (); + i = test46 (a, b); + if (i != 1) + abort (); + i = test47 (a, b); + if (i != 1) + abort (); + i = test48 (a, b); + if (i != 0) + abort (); + i = test49 (a, b); + if (i != 0) + abort (); + i = test50 (a, b); + if (i != 0) + abort (); + i = test51 (a, b); + if (i != 0) + abort (); + i = test52 (a, b); + if (i != 1) + abort (); + i = test53 (a, b); + if (i != 1) + abort (); + i = test54 (a, b); + if (i != 1) + abort (); + i = test55 (a, b); + if (i != 1) + abort (); + i = test56 (a, b); + if (i != 0) + abort (); + i = test57 (a, b); + if (i != 0) + abort (); + i = test58 (a, b); + if (i != 0) + abort (); + i = test59 (a, b); + if (i != 0) + abort (); + i = test60 (a, b); + if (i != 1) + abort (); + i = test61 (a, b); + if (i != 1) + abort (); + i = test62 (a, b); + if (i != 1) + abort (); + i = test63 (a, b); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_f_ps (a, b); +} + +int test1 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_f_ps (a, b); +} + +int test2 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_f_ps (a, b); +} + +int test3 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_f_ps (a, b); +} + +int test4 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_un_ps (a, b); +} + +int test5 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_un_ps (a, b); +} + +int test6 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_un_ps (a, b); +} + +int test7 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_un_ps (a, b); +} + +int test8 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_eq_ps (a, b); +} + +int test9 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_eq_ps (a, b); +} + +int test10 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_eq_ps (a, b); +} + +int test11 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_eq_ps (a, b); +} + +int test12 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ueq_ps (a, b); +} + +int test13 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ueq_ps (a, b); +} + +int test14 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ueq_ps (a, b); +} + +int test15 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ueq_ps (a, b); +} + +int test16 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_olt_ps (a, b); +} + +int test17 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_olt_ps (a, b); +} + +int test18 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_olt_ps (a, b); +} + +int test19 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_olt_ps (a, b); +} + +int test20 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ult_ps (a, b); +} + +int test21 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ult_ps (a, b); +} + +int test22 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ult_ps (a, b); +} + +int test23 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ult_ps (a, b); +} + +int test24 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ole_ps (a, b); +} + +int test25 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ole_ps (a, b); +} + +int test26 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ole_ps (a, b); +} + +int test27 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ole_ps (a, b); +} + +int test28 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ule_ps (a, b); +} + +int test29 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ule_ps (a, b); +} + +int test30 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ule_ps (a, b); +} + +int test31 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ule_ps (a, b); +} + +int test32 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_sf_ps (a, b); +} + +int test33 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_sf_ps (a, b); +} + +int test34 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_sf_ps (a, b); +} + +int test35 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_sf_ps (a, b); +} + +int test36 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ngle_ps (a, b); +} + +int test37 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ngle_ps (a, b); +} + +int test38 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ngle_ps (a, b); +} + +int test39 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ngle_ps (a, b); +} + +int test40 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_seq_ps (a, b); +} + +int test41 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_seq_ps (a, b); +} + +int test42 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_seq_ps (a, b); +} + +int test43 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_seq_ps (a, b); +} + +int test44 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ngl_ps (a, b); +} + +int test45 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ngl_ps (a, b); +} + +int test46 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ngl_ps (a, b); +} + +int test47 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ngl_ps (a, b); +} + +int test48 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_lt_ps (a, b); +} + +int test49 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_lt_ps (a, b); +} + +int test50 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_lt_ps (a, b); +} + +int test51 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_lt_ps (a, b); +} + +int test52 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_nge_ps (a, b); +} + +int test53 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_nge_ps (a, b); +} + +int test54 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_nge_ps (a, b); +} + +int test55 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_nge_ps (a, b); +} + +int test56 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_le_ps (a, b); +} + +int test57 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_le_ps (a, b); +} + +int test58 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_le_ps (a, b); +} + +int test59 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_le_ps (a, b); +} + +int test60 (v2sf a, v2sf b) +{ + return __builtin_mips_any_cabs_ngt_ps (a, b); +} + +int test61 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_cabs_ngt_ps (a, b); +} + +int test62 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_cabs_ngt_ps (a, b); +} + +int test63 (v2sf a, v2sf b) +{ + return __builtin_mips_all_cabs_ngt_ps (a, b); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-4.c b/gcc/testsuite/gcc.target/mips/mips-3d-4.c new file mode 100644 index 00000000000..9723047ff83 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-4.c @@ -0,0 +1,590 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D branch-if-any-four builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size(8))); + +int test0 (v2sf a, v2sf b, v2sf c, v2sf d); +int test1 (v2sf a, v2sf b, v2sf c, v2sf d); +int test2 (v2sf a, v2sf b, v2sf c, v2sf d); +int test3 (v2sf a, v2sf b, v2sf c, v2sf d); +int test4 (v2sf a, v2sf b, v2sf c, v2sf d); +int test5 (v2sf a, v2sf b, v2sf c, v2sf d); +int test6 (v2sf a, v2sf b, v2sf c, v2sf d); +int test7 (v2sf a, v2sf b, v2sf c, v2sf d); +int test8 (v2sf a, v2sf b, v2sf c, v2sf d); +int test9 (v2sf a, v2sf b, v2sf c, v2sf d); +int test10 (v2sf a, v2sf b, v2sf c, v2sf d); +int test11 (v2sf a, v2sf b, v2sf c, v2sf d); +int test12 (v2sf a, v2sf b, v2sf c, v2sf d); +int test13 (v2sf a, v2sf b, v2sf c, v2sf d); +int test14 (v2sf a, v2sf b, v2sf c, v2sf d); +int test15 (v2sf a, v2sf b, v2sf c, v2sf d); +int test16 (v2sf a, v2sf b, v2sf c, v2sf d); +int test17 (v2sf a, v2sf b, v2sf c, v2sf d); +int test18 (v2sf a, v2sf b, v2sf c, v2sf d); +int test19 (v2sf a, v2sf b, v2sf c, v2sf d); +int test20 (v2sf a, v2sf b, v2sf c, v2sf d); +int test21 (v2sf a, v2sf b, v2sf c, v2sf d); +int test22 (v2sf a, v2sf b, v2sf c, v2sf d); +int test23 (v2sf a, v2sf b, v2sf c, v2sf d); +int test24 (v2sf a, v2sf b, v2sf c, v2sf d); +int test25 (v2sf a, v2sf b, v2sf c, v2sf d); +int test26 (v2sf a, v2sf b, v2sf c, v2sf d); +int test27 (v2sf a, v2sf b, v2sf c, v2sf d); +int test28 (v2sf a, v2sf b, v2sf c, v2sf d); +int test29 (v2sf a, v2sf b, v2sf c, v2sf d); +int test30 (v2sf a, v2sf b, v2sf c, v2sf d); +int test31 (v2sf a, v2sf b, v2sf c, v2sf d); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main () +{ + v2sf a, b, c, d; + int i, j; + + /* c.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {33, 44}; + c = (v2sf) {55, 66}; + d = (v2sf) {77, 88}; + i = 0; + j = 0; + if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {11, 44}; + c = (v2sf) {55, 66}; + d = (v2sf) {77, 88}; + i = 1; + j = 0; + if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {33, 22}; + c = (v2sf) {55, 66}; + d = (v2sf) {77, 88}; + i = 1; + j = 0; + if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {33, 44}; + c = (v2sf) {55, 66}; + d = (v2sf) {55, 88}; + i = 1; + j = 0; + if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {33, 44}; + c = (v2sf) {55, 66}; + d = (v2sf) {77, 66}; + i = 1; + j = 0; + if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) + abort (); + + /* c.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {11, 22}; + c = (v2sf) {55, 66}; + d = (v2sf) {55, 66}; + i = 1; + j = 1; + if (__builtin_mips_any_c_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_c_eq_4s(a, b, c, d) != j) + abort (); + + /* Test all comparisons */ + a = (v2sf) {11, 33}; + b = (v2sf) {33, 11}; + c = (v2sf) {55, 66}; + d = (v2sf) {55, 88}; + + i = test0 (a, b, c, d); + if (i != 0) + abort (); + i = test1 (a, b, c, d); + if (i != 0) + abort (); + i = test2 (a, b, c, d); + if (i != 0) + abort (); + i = test3 (a, b, c, d); + if (i != 0) + abort (); + i = test4 (a, b, c, d); + if (i != 1) + abort (); + i = test5 (a, b, c, d); + if (i != 0) + abort (); + i = test6 (a, b, c, d); + if (i != 1) + abort (); + i = test7 (a, b, c, d); + if (i != 0) + abort (); + i = test8 (a, b, c, d); + if (i != 1) + abort (); + i = test9 (a, b, c, d); + if (i != 0) + abort (); + i = test10 (a, b, c, d); + if (i != 1) + abort (); + i = test11 (a, b, c, d); + if (i != 0) + abort (); + i = test12 (a, b, c, d); + if (i != 1) + abort (); + i = test13 (a, b, c, d); + if (i != 0) + abort (); + i = test14 (a, b, c, d); + if (i != 1) + abort (); + i = test15 (a, b, c, d); + if (i != 0) + abort (); + i = test16 (a, b, c, d); + if (i != 0) + abort (); + i = test17 (a, b, c, d); + if (i != 0) + abort (); + i = test18 (a, b, c, d); + if (i != 0) + abort (); + i = test19 (a, b, c, d); + if (i != 0) + abort (); + i = test20 (a, b, c, d); + if (i != 1) + abort (); + i = test21 (a, b, c, d); + if (i != 0) + abort (); + i = test22 (a, b, c, d); + if (i != 1) + abort (); + i = test23 (a, b, c, d); + if (i != 0) + abort (); + i = test24 (a, b, c, d); + if (i != 1) + abort (); + i = test25 (a, b, c, d); + if (i != 0) + abort (); + i = test26 (a, b, c, d); + if (i != 1) + abort (); + i = test27 (a, b, c, d); + if (i != 0) + abort (); + i = test28 (a, b, c, d); + if (i != 1) + abort (); + i = test29 (a, b, c, d); + if (i != 0) + abort (); + i = test30 (a, b, c, d); + if (i != 1) + abort (); + i = test31 (a, b, c, d); + if (i != 0) + abort (); + + /* Reversed arguments */ + i = test0 (b, a, d, c); + if (i != 0) + abort (); + i = test1 (b, a, d, c); + if (i != 0) + abort (); + i = test2 (b, a, d, c); + if (i != 0) + abort (); + i = test3 (b, a, d, c); + if (i != 0) + abort (); + i = test4 (b, a, d, c); + if (i != 1) + abort (); + i = test5 (b, a, d, c); + if (i != 0) + abort (); + i = test6 (b, a, d, c); + if (i != 1) + abort (); + i = test7 (b, a, d, c); + if (i != 0) + abort (); + i = test8 (b, a, d, c); + if (i != 1) + abort (); + i = test9 (b, a, d, c); + if (i != 0) + abort (); + i = test10 (b, a, d, c); + if (i != 1) + abort (); + i = test11 (b, a, d, c); + if (i != 0) + abort (); + i = test12 (b, a, d, c); + if (i != 1) + abort (); + i = test13 (b, a, d, c); + if (i != 0) + abort (); + i = test14 (b, a, d, c); + if (i != 1) + abort (); + i = test15 (b, a, d, c); + if (i != 0) + abort (); + i = test16 (b, a, d, c); + if (i != 0) + abort (); + i = test17 (b, a, d, c); + if (i != 0) + abort (); + i = test18 (b, a, d, c); + if (i != 0) + abort (); + i = test19 (b, a, d, c); + if (i != 0) + abort (); + i = test20 (b, a, d, c); + if (i != 1) + abort (); + i = test21 (b, a, d, c); + if (i != 0) + abort (); + i = test22 (b, a, d, c); + if (i != 1) + abort (); + i = test23 (b, a, d, c); + if (i != 0) + abort (); + i = test24 (b, a, d, c); + if (i != 1) + abort (); + i = test25 (b, a, d, c); + if (i != 0) + abort (); + i = test26 (b, a, d, c); + if (i != 1) + abort (); + i = test27 (b, a, d, c); + if (i != 0) + abort (); + i = test28 (b, a, d, c); + if (i != 1) + abort (); + i = test29 (b, a, d, c); + if (i != 0) + abort (); + i = test30 (b, a, d, c); + if (i != 1) + abort (); + i = test31 (b, a, d, c); + if (i != 0) + abort (); + +#ifndef __FAST_MATH__ + /* Test all comparisons */ + a = (v2sf) {qnan, qnan}; + b = (v2sf) {33, 11}; + c = (v2sf) {qnan, qnan}; + d = (v2sf) {55, 88}; + + i = test0 (a, b, c, d); + if (i != 0) + abort (); + i = test1 (a, b, c, d); + if (i != 0) + abort (); + i = test2 (a, b, c, d); + if (i != 1) + abort (); + i = test3 (a, b, c, d); + if (i != 1) + abort (); + i = test4 (a, b, c, d); + if (i != 0) + abort (); + i = test5 (a, b, c, d); + if (i != 0) + abort (); + i = test6 (a, b, c, d); + if (i != 1) + abort (); + i = test7 (a, b, c, d); + if (i != 1) + abort (); + i = test8 (a, b, c, d); + if (i != 0) + abort (); + i = test9 (a, b, c, d); + if (i != 0) + abort (); + i = test10 (a, b, c, d); + if (i != 1) + abort (); + i = test11 (a, b, c, d); + if (i != 1) + abort (); + i = test12 (a, b, c, d); + if (i != 0) + abort (); + i = test13 (a, b, c, d); + if (i != 0) + abort (); + i = test14 (a, b, c, d); + if (i != 1) + abort (); + i = test15 (a, b, c, d); + if (i != 1) + abort (); + i = test16 (a, b, c, d); + if (i != 0) + abort (); + i = test17 (a, b, c, d); + if (i != 0) + abort (); + i = test18 (a, b, c, d); + if (i != 1) + abort (); + i = test19 (a, b, c, d); + if (i != 1) + abort (); + i = test20 (a, b, c, d); + if (i != 0) + abort (); + i = test21 (a, b, c, d); + if (i != 0) + abort (); + i = test22 (a, b, c, d); + if (i != 1) + abort (); + i = test23 (a, b, c, d); + if (i != 1) + abort (); + i = test24 (a, b, c, d); + if (i != 0) + abort (); + i = test25 (a, b, c, d); + if (i != 0) + abort (); + i = test26 (a, b, c, d); + if (i != 1) + abort (); + i = test27 (a, b, c, d); + if (i != 1) + abort (); + i = test28 (a, b, c, d); + if (i != 0) + abort (); + i = test29 (a, b, c, d); + if (i != 0) + abort (); + i = test30 (a, b, c, d); + if (i != 1) + abort (); + i = test31 (a, b, c, d); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_f_4s (a, b, c, d); +} + +int test1 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_f_4s (a, b, c, d); +} + +int test2 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_un_4s (a, b, c, d); +} + +int test3 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_un_4s (a, b, c, d); +} + +int test4 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_eq_4s (a, b, c, d); +} + +int test5 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_eq_4s (a, b, c, d); +} + +int test6 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ueq_4s (a, b, c, d); +} + +int test7 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ueq_4s (a, b, c, d); +} + +int test8 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_olt_4s (a, b, c, d); +} + +int test9 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_olt_4s (a, b, c, d); +} + +int test10 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ult_4s (a, b, c, d); +} + +int test11 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ult_4s (a, b, c, d); +} + +int test12 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ole_4s (a, b, c, d); +} + +int test13 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ole_4s (a, b, c, d); +} + +int test14 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ule_4s (a, b, c, d); +} + +int test15 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ule_4s (a, b, c, d); +} + +int test16 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_sf_4s (a, b, c, d); +} + +int test17 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_sf_4s (a, b, c, d); +} + +int test18 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ngle_4s (a, b, c, d); +} + +int test19 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ngle_4s (a, b, c, d); +} + +int test20 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_seq_4s (a, b, c, d); +} + +int test21 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_seq_4s (a, b, c, d); +} + +int test22 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ngl_4s (a, b, c, d); +} + +int test23 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ngl_4s (a, b, c, d); +} + +int test24 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_lt_4s (a, b, c, d); +} + +int test25 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_lt_4s (a, b, c, d); +} + +int test26 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_nge_4s (a, b, c, d); +} + +int test27 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_nge_4s (a, b, c, d); +} + +int test28 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_le_4s (a, b, c, d); +} + +int test29 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_le_4s (a, b, c, d); +} + +int test30 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_c_ngt_4s (a, b, c, d); +} + +int test31 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_c_ngt_4s (a, b, c, d); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-5.c b/gcc/testsuite/gcc.target/mips/mips-3d-5.c new file mode 100644 index 00000000000..bd4c857037d --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-5.c @@ -0,0 +1,590 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D absolute-compare & branch-if-any-four builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size(8))); + +int test0 (v2sf a, v2sf b, v2sf c, v2sf d); +int test1 (v2sf a, v2sf b, v2sf c, v2sf d); +int test2 (v2sf a, v2sf b, v2sf c, v2sf d); +int test3 (v2sf a, v2sf b, v2sf c, v2sf d); +int test4 (v2sf a, v2sf b, v2sf c, v2sf d); +int test5 (v2sf a, v2sf b, v2sf c, v2sf d); +int test6 (v2sf a, v2sf b, v2sf c, v2sf d); +int test7 (v2sf a, v2sf b, v2sf c, v2sf d); +int test8 (v2sf a, v2sf b, v2sf c, v2sf d); +int test9 (v2sf a, v2sf b, v2sf c, v2sf d); +int test10 (v2sf a, v2sf b, v2sf c, v2sf d); +int test11 (v2sf a, v2sf b, v2sf c, v2sf d); +int test12 (v2sf a, v2sf b, v2sf c, v2sf d); +int test13 (v2sf a, v2sf b, v2sf c, v2sf d); +int test14 (v2sf a, v2sf b, v2sf c, v2sf d); +int test15 (v2sf a, v2sf b, v2sf c, v2sf d); +int test16 (v2sf a, v2sf b, v2sf c, v2sf d); +int test17 (v2sf a, v2sf b, v2sf c, v2sf d); +int test18 (v2sf a, v2sf b, v2sf c, v2sf d); +int test19 (v2sf a, v2sf b, v2sf c, v2sf d); +int test20 (v2sf a, v2sf b, v2sf c, v2sf d); +int test21 (v2sf a, v2sf b, v2sf c, v2sf d); +int test22 (v2sf a, v2sf b, v2sf c, v2sf d); +int test23 (v2sf a, v2sf b, v2sf c, v2sf d); +int test24 (v2sf a, v2sf b, v2sf c, v2sf d); +int test25 (v2sf a, v2sf b, v2sf c, v2sf d); +int test26 (v2sf a, v2sf b, v2sf c, v2sf d); +int test27 (v2sf a, v2sf b, v2sf c, v2sf d); +int test28 (v2sf a, v2sf b, v2sf c, v2sf d); +int test29 (v2sf a, v2sf b, v2sf c, v2sf d); +int test30 (v2sf a, v2sf b, v2sf c, v2sf d); +int test31 (v2sf a, v2sf b, v2sf c, v2sf d); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main () +{ + v2sf a, b, c, d; + int i, j; + + /* cabs.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {-33, -44}; + c = (v2sf) {55, 66}; + d = (v2sf) {-77, -88}; + i = 0; + j = 0; + if (__builtin_mips_any_cabs_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_cabs_eq_4s(a, b, c, d) != j) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {-11, -44}; + c = (v2sf) {55, 66}; + d = (v2sf) {-77, -88}; + i = 1; + j = 0; + if (__builtin_mips_any_cabs_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_cabs_eq_4s(a, b, c, d) != j) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {-33, -22}; + c = (v2sf) {55, 66}; + d = (v2sf) {-77, -88}; + i = 1; + j = 0; + if (__builtin_mips_any_cabs_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_cabs_eq_4s(a, b, c, d) != j) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {-33, -44}; + c = (v2sf) {55, 66}; + d = (v2sf) {-55, -88}; + i = 1; + j = 0; + if (__builtin_mips_any_cabs_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_cabs_eq_4s(a, b, c, d) != j) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {-33, -44}; + c = (v2sf) {55, 66}; + d = (v2sf) {-77, -66}; + i = 1; + j = 0; + if (__builtin_mips_any_cabs_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_cabs_eq_4s(a, b, c, d) != j) + abort (); + + /* cabs.eq.ps */ + a = (v2sf) {11, 22}; + b = (v2sf) {-11, -22}; + c = (v2sf) {55, 66}; + d = (v2sf) {-55, -66}; + i = 1; + j = 1; + if (__builtin_mips_any_cabs_eq_4s(a, b, c, d) != i) + abort (); + if (__builtin_mips_all_cabs_eq_4s(a, b, c, d) != j) + abort (); + + /* Test all comparisons */ + a = (v2sf) {11, 33}; + b = (v2sf) {-33, -11}; + c = (v2sf) {55, 66}; + d = (v2sf) {-55, -88}; + + i = test0 (a, b, c, d); + if (i != 0) + abort (); + i = test1 (a, b, c, d); + if (i != 0) + abort (); + i = test2 (a, b, c, d); + if (i != 0) + abort (); + i = test3 (a, b, c, d); + if (i != 0) + abort (); + i = test4 (a, b, c, d); + if (i != 1) + abort (); + i = test5 (a, b, c, d); + if (i != 0) + abort (); + i = test6 (a, b, c, d); + if (i != 1) + abort (); + i = test7 (a, b, c, d); + if (i != 0) + abort (); + i = test8 (a, b, c, d); + if (i != 1) + abort (); + i = test9 (a, b, c, d); + if (i != 0) + abort (); + i = test10 (a, b, c, d); + if (i != 1) + abort (); + i = test11 (a, b, c, d); + if (i != 0) + abort (); + i = test12 (a, b, c, d); + if (i != 1) + abort (); + i = test13 (a, b, c, d); + if (i != 0) + abort (); + i = test14 (a, b, c, d); + if (i != 1) + abort (); + i = test15 (a, b, c, d); + if (i != 0) + abort (); + i = test16 (a, b, c, d); + if (i != 0) + abort (); + i = test17 (a, b, c, d); + if (i != 0) + abort (); + i = test18 (a, b, c, d); + if (i != 0) + abort (); + i = test19 (a, b, c, d); + if (i != 0) + abort (); + i = test20 (a, b, c, d); + if (i != 1) + abort (); + i = test21 (a, b, c, d); + if (i != 0) + abort (); + i = test22 (a, b, c, d); + if (i != 1) + abort (); + i = test23 (a, b, c, d); + if (i != 0) + abort (); + i = test24 (a, b, c, d); + if (i != 1) + abort (); + i = test25 (a, b, c, d); + if (i != 0) + abort (); + i = test26 (a, b, c, d); + if (i != 1) + abort (); + i = test27 (a, b, c, d); + if (i != 0) + abort (); + i = test28 (a, b, c, d); + if (i != 1) + abort (); + i = test29 (a, b, c, d); + if (i != 0) + abort (); + i = test30 (a, b, c, d); + if (i != 1) + abort (); + i = test31 (a, b, c, d); + if (i != 0) + abort (); + + /* Reversed arguments */ + i = test0 (b, a, d, c); + if (i != 0) + abort (); + i = test1 (b, a, d, c); + if (i != 0) + abort (); + i = test2 (b, a, d, c); + if (i != 0) + abort (); + i = test3 (b, a, d, c); + if (i != 0) + abort (); + i = test4 (b, a, d, c); + if (i != 1) + abort (); + i = test5 (b, a, d, c); + if (i != 0) + abort (); + i = test6 (b, a, d, c); + if (i != 1) + abort (); + i = test7 (b, a, d, c); + if (i != 0) + abort (); + i = test8 (b, a, d, c); + if (i != 1) + abort (); + i = test9 (b, a, d, c); + if (i != 0) + abort (); + i = test10 (b, a, d, c); + if (i != 1) + abort (); + i = test11 (b, a, d, c); + if (i != 0) + abort (); + i = test12 (b, a, d, c); + if (i != 1) + abort (); + i = test13 (b, a, d, c); + if (i != 0) + abort (); + i = test14 (b, a, d, c); + if (i != 1) + abort (); + i = test15 (b, a, d, c); + if (i != 0) + abort (); + i = test16 (b, a, d, c); + if (i != 0) + abort (); + i = test17 (b, a, d, c); + if (i != 0) + abort (); + i = test18 (b, a, d, c); + if (i != 0) + abort (); + i = test19 (b, a, d, c); + if (i != 0) + abort (); + i = test20 (b, a, d, c); + if (i != 1) + abort (); + i = test21 (b, a, d, c); + if (i != 0) + abort (); + i = test22 (b, a, d, c); + if (i != 1) + abort (); + i = test23 (b, a, d, c); + if (i != 0) + abort (); + i = test24 (b, a, d, c); + if (i != 1) + abort (); + i = test25 (b, a, d, c); + if (i != 0) + abort (); + i = test26 (b, a, d, c); + if (i != 1) + abort (); + i = test27 (b, a, d, c); + if (i != 0) + abort (); + i = test28 (b, a, d, c); + if (i != 1) + abort (); + i = test29 (b, a, d, c); + if (i != 0) + abort (); + i = test30 (b, a, d, c); + if (i != 1) + abort (); + i = test31 (b, a, d, c); + if (i != 0) + abort (); + +#ifndef __FAST_MATH__ + /* Test all comparisons */ + a = (v2sf) {qnan, qnan}; + b = (v2sf) {-33, -11}; + c = (v2sf) {qnan, qnan}; + d = (v2sf) {-55, -88}; + + i = test0 (a, b, c, d); + if (i != 0) + abort (); + i = test1 (a, b, c, d); + if (i != 0) + abort (); + i = test2 (a, b, c, d); + if (i != 1) + abort (); + i = test3 (a, b, c, d); + if (i != 1) + abort (); + i = test4 (a, b, c, d); + if (i != 0) + abort (); + i = test5 (a, b, c, d); + if (i != 0) + abort (); + i = test6 (a, b, c, d); + if (i != 1) + abort (); + i = test7 (a, b, c, d); + if (i != 1) + abort (); + i = test8 (a, b, c, d); + if (i != 0) + abort (); + i = test9 (a, b, c, d); + if (i != 0) + abort (); + i = test10 (a, b, c, d); + if (i != 1) + abort (); + i = test11 (a, b, c, d); + if (i != 1) + abort (); + i = test12 (a, b, c, d); + if (i != 0) + abort (); + i = test13 (a, b, c, d); + if (i != 0) + abort (); + i = test14 (a, b, c, d); + if (i != 1) + abort (); + i = test15 (a, b, c, d); + if (i != 1) + abort (); + i = test16 (a, b, c, d); + if (i != 0) + abort (); + i = test17 (a, b, c, d); + if (i != 0) + abort (); + i = test18 (a, b, c, d); + if (i != 1) + abort (); + i = test19 (a, b, c, d); + if (i != 1) + abort (); + i = test20 (a, b, c, d); + if (i != 0) + abort (); + i = test21 (a, b, c, d); + if (i != 0) + abort (); + i = test22 (a, b, c, d); + if (i != 1) + abort (); + i = test23 (a, b, c, d); + if (i != 1) + abort (); + i = test24 (a, b, c, d); + if (i != 0) + abort (); + i = test25 (a, b, c, d); + if (i != 0) + abort (); + i = test26 (a, b, c, d); + if (i != 1) + abort (); + i = test27 (a, b, c, d); + if (i != 1) + abort (); + i = test28 (a, b, c, d); + if (i != 0) + abort (); + i = test29 (a, b, c, d); + if (i != 0) + abort (); + i = test30 (a, b, c, d); + if (i != 1) + abort (); + i = test31 (a, b, c, d); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_f_4s (a, b, c, d); +} + +int test1 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_f_4s (a, b, c, d); +} + +int test2 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_un_4s (a, b, c, d); +} + +int test3 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_un_4s (a, b, c, d); +} + +int test4 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_eq_4s (a, b, c, d); +} + +int test5 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_eq_4s (a, b, c, d); +} + +int test6 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ueq_4s (a, b, c, d); +} + +int test7 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ueq_4s (a, b, c, d); +} + +int test8 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_olt_4s (a, b, c, d); +} + +int test9 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_olt_4s (a, b, c, d); +} + +int test10 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ult_4s (a, b, c, d); +} + +int test11 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ult_4s (a, b, c, d); +} + +int test12 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ole_4s (a, b, c, d); +} + +int test13 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ole_4s (a, b, c, d); +} + +int test14 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ule_4s (a, b, c, d); +} + +int test15 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ule_4s (a, b, c, d); +} + +int test16 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_sf_4s (a, b, c, d); +} + +int test17 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_sf_4s (a, b, c, d); +} + +int test18 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ngle_4s (a, b, c, d); +} + +int test19 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ngle_4s (a, b, c, d); +} + +int test20 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_seq_4s (a, b, c, d); +} + +int test21 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_seq_4s (a, b, c, d); +} + +int test22 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ngl_4s (a, b, c, d); +} + +int test23 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ngl_4s (a, b, c, d); +} + +int test24 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_lt_4s (a, b, c, d); +} + +int test25 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_lt_4s (a, b, c, d); +} + +int test26 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_nge_4s (a, b, c, d); +} + +int test27 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_nge_4s (a, b, c, d); +} + +int test28 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_le_4s (a, b, c, d); +} + +int test29 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_le_4s (a, b, c, d); +} + +int test30 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_any_cabs_ngt_4s (a, b, c, d); +} + +int test31 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_all_cabs_ngt_4s (a, b, c, d); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-6.c b/gcc/testsuite/gcc.target/mips/mips-3d-6.c new file mode 100644 index 00000000000..0b54ef1fecb --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-6.c @@ -0,0 +1,284 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D absolute compare (floats) builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +int test0 (float a, float b); +int test1 (float a, float b); +int test2 (float a, float b); +int test3 (float a, float b); +int test4 (float a, float b); +int test5 (float a, float b); +int test6 (float a, float b); +int test7 (float a, float b); +int test8 (float a, float b); +int test9 (float a, float b); +int test10 (float a, float b); +int test11 (float a, float b); +int test12 (float a, float b); +int test13 (float a, float b); +int test14 (float a, float b); +int test15 (float a, float b); + +int main () +{ + float a, b; + int i; + + /* cabs.eq.s */ + a = 12; + b = -56; + i = 0; + if (__builtin_mips_cabs_eq_s(a, b) != i) + abort (); + + /* cabs.eq.s */ + a = 12; + b = -12; + i = 1; + if (__builtin_mips_cabs_eq_s(a, b) != i) + abort (); + + /* Test all comparisons */ + a = 10.58; + b = 567.345; + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 0) + abort (); + i = test4 (a, b); + if (i != 1) + abort (); + i = test5 (a, b); + if (i != 1) + abort (); + i = test6 (a, b); + if (i != 1) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 0) + abort (); + i = test11 (a, b); + if (i != 0) + abort (); + i = test12 (a, b); + if (i != 1) + abort (); + i = test13 (a, b); + if (i != 1) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + + /* Reversed arguments */ + i = test0 (b, a); + if (i != 0) + abort (); + i = test1 (b, a); + if (i != 0) + abort (); + i = test2 (b, a); + if (i != 0) + abort (); + i = test3 (b, a); + if (i != 0) + abort (); + i = test4 (b, a); + if (i != 0) + abort (); + i = test5 (b, a); + if (i != 0) + abort (); + i = test6 (b, a); + if (i != 0) + abort (); + i = test7 (b, a); + if (i != 0) + abort (); + i = test8 (b, a); + if (i != 0) + abort (); + i = test9 (b, a); + if (i != 0) + abort (); + i = test10 (b, a); + if (i != 0) + abort (); + i = test11 (b, a); + if (i != 0) + abort (); + i = test12 (b, a); + if (i != 0) + abort (); + i = test13 (b, a); + if (i != 0) + abort (); + i = test14 (b, a); + if (i != 0) + abort (); + i = test15 (b, a); + if (i != 0) + abort (); + +#ifndef __FAST_MATH__ + /* Test all comparisons */ + a = 1.0f/0.0f - 1.0f/0.0f; // QNaN + b = 567.345; + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 1) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 1) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 1) + abort (); + i = test6 (a, b); + if (i != 0) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 1) + abort (); + i = test10 (a, b); + if (i != 0) + abort (); + i = test11 (a, b); + if (i != 1) + abort (); + i = test12 (a, b); + if (i != 0) + abort (); + i = test13 (a, b); + if (i != 1) + abort (); + i = test14 (a, b); + if (i != 0) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (float a, float b) +{ + return __builtin_mips_cabs_f_s (a, b); +} + +int test1 (float a, float b) +{ + return __builtin_mips_cabs_un_s (a, b); +} + +int test2 (float a, float b) +{ + return __builtin_mips_cabs_eq_s (a, b); +} + +int test3 (float a, float b) +{ + return __builtin_mips_cabs_ueq_s (a, b); +} + +int test4 (float a, float b) +{ + return __builtin_mips_cabs_olt_s (a, b); +} + +int test5 (float a, float b) +{ + return __builtin_mips_cabs_ult_s (a, b); +} + +int test6 (float a, float b) +{ + return __builtin_mips_cabs_ole_s (a, b); +} + +int test7 (float a, float b) +{ + return __builtin_mips_cabs_ule_s (a, b); +} + +int test8 (float a, float b) +{ + return __builtin_mips_cabs_sf_s (a, b); +} + +int test9 (float a, float b) +{ + return __builtin_mips_cabs_ngle_s (a, b); +} + +int test10 (float a, float b) +{ + return __builtin_mips_cabs_seq_s (a, b); +} + +int test11 (float a, float b) +{ + return __builtin_mips_cabs_ngl_s (a, b); +} + +int test12 (float a, float b) +{ + return __builtin_mips_cabs_lt_s (a, b); +} + +int test13 (float a, float b) +{ + return __builtin_mips_cabs_nge_s (a, b); +} + +int test14 (float a, float b) +{ + return __builtin_mips_cabs_le_s (a, b); +} + +int test15 (float a, float b) +{ + return __builtin_mips_cabs_ngt_s (a, b); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-7.c b/gcc/testsuite/gcc.target/mips/mips-3d-7.c new file mode 100644 index 00000000000..1d9a481ef65 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-7.c @@ -0,0 +1,284 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D absolute compare (doubles) builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +int test0 (double a, double b); +int test1 (double a, double b); +int test2 (double a, double b); +int test3 (double a, double b); +int test4 (double a, double b); +int test5 (double a, double b); +int test6 (double a, double b); +int test7 (double a, double b); +int test8 (double a, double b); +int test9 (double a, double b); +int test10 (double a, double b); +int test11 (double a, double b); +int test12 (double a, double b); +int test13 (double a, double b); +int test14 (double a, double b); +int test15 (double a, double b); + +int main () +{ + double a, b; + int i; + + /* cabs.eq.d */ + a = 12; + b = -56; + i = 0; + if (__builtin_mips_cabs_eq_d(a, b) != i) + abort (); + + /* cabs.eq.d */ + a = 12; + b = -12; + i = 1; + if (__builtin_mips_cabs_eq_d(a, b) != i) + abort (); + + /* Test all operators */ + a = 1984.0; + b = 1984.0; + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 1) + abort (); + i = test3 (a, b); + if (i != 1) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 0) + abort (); + i = test6 (a, b); + if (i != 1) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 1) + abort (); + i = test11 (a, b); + if (i != 1) + abort (); + i = test12 (a, b); + if (i != 0) + abort (); + i = test13 (a, b); + if (i != 0) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + + /* Reverse arguments */ + i = test0 (b, a); + if (i != 0) + abort (); + i = test1 (b, a); + if (i != 0) + abort (); + i = test2 (b, a); + if (i != 1) + abort (); + i = test3 (b, a); + if (i != 1) + abort (); + i = test4 (b, a); + if (i != 0) + abort (); + i = test5 (b, a); + if (i != 0) + abort (); + i = test6 (b, a); + if (i != 1) + abort (); + i = test7 (b, a); + if (i != 1) + abort (); + i = test8 (b, a); + if (i != 0) + abort (); + i = test9 (b, a); + if (i != 0) + abort (); + i = test10 (b, a); + if (i != 1) + abort (); + i = test11 (b, a); + if (i != 1) + abort (); + i = test12 (b, a); + if (i != 0) + abort (); + i = test13 (b, a); + if (i != 0) + abort (); + i = test14 (b, a); + if (i != 1) + abort (); + i = test15 (b, a); + if (i != 1) + abort (); + +#ifndef __FAST_MATH__ + /* Test all operators */ + a = 1.0/0.0 - 1.0/0.0; // QNaN + b = 1.0/0.0 - 1.0/0.0; // QNaN + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 1) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 1) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 1) + abort (); + i = test6 (a, b); + if (i != 0) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 1) + abort (); + i = test10 (a, b); + if (i != 0) + abort (); + i = test11 (a, b); + if (i != 1) + abort (); + i = test12 (a, b); + if (i != 0) + abort (); + i = test13 (a, b); + if (i != 1) + abort (); + i = test14 (a, b); + if (i != 0) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (double a, double b) +{ + return __builtin_mips_cabs_f_d (a, b); +} + +int test1 (double a, double b) +{ + return __builtin_mips_cabs_un_d (a, b); +} + +int test2 (double a, double b) +{ + return __builtin_mips_cabs_eq_d (a, b); +} + +int test3 (double a, double b) +{ + return __builtin_mips_cabs_ueq_d (a, b); +} + +int test4 (double a, double b) +{ + return __builtin_mips_cabs_olt_d (a, b); +} + +int test5 (double a, double b) +{ + return __builtin_mips_cabs_ult_d (a, b); +} + +int test6 (double a, double b) +{ + return __builtin_mips_cabs_ole_d (a, b); +} + +int test7 (double a, double b) +{ + return __builtin_mips_cabs_ule_d (a, b); +} + +int test8 (double a, double b) +{ + return __builtin_mips_cabs_sf_d (a, b); +} + +int test9 (double a, double b) +{ + return __builtin_mips_cabs_ngle_d (a, b); +} + +int test10 (double a, double b) +{ + return __builtin_mips_cabs_seq_d (a, b); +} + +int test11 (double a, double b) +{ + return __builtin_mips_cabs_ngl_d (a, b); +} + +int test12 (double a, double b) +{ + return __builtin_mips_cabs_lt_d (a, b); +} + +int test13 (double a, double b) +{ + return __builtin_mips_cabs_nge_d (a, b); +} + +int test14 (double a, double b) +{ + return __builtin_mips_cabs_le_d (a, b); +} + +int test15 (double a, double b) +{ + return __builtin_mips_cabs_ngt_d (a, b); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-8.c b/gcc/testsuite/gcc.target/mips/mips-3d-8.c new file mode 100644 index 00000000000..955c2664f90 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-8.c @@ -0,0 +1,630 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Test MIPS-3D absolute compare and conditional move builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__((vector_size(8))); + +v2sf test0 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test1 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test2 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test3 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test4 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test5 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test6 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test7 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test8 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test9 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test10 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test11 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test12 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test13 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test14 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test15 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test16 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test17 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test18 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test19 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test20 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test21 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test22 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test23 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test24 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test25 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test26 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test27 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test28 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test29 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test30 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test31 (v2sf a, v2sf b, v2sf c, v2sf d); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main () +{ + v2sf a, b, c, d, e, f; + + /* Case 1 {diff, diff} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {-7, -6}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_cabs_eq_ps (a, b, c, d); + f = (v2sf) {33, 123}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_cabs_eq_ps (a, b, c, d); + f = (v2sf) {8, 78}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* Case 2 {same, diff} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {-5, -6}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_cabs_eq_ps (a, b, c, d); + f = (v2sf) {8, 123}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_cabs_eq_ps (a, b, c, d); + f = (v2sf) {33, 78}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* Case 3 {diff, same} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {-9, -12}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_cabs_eq_ps (a, b, c, d); + f = (v2sf) {33, 78}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_cabs_eq_ps (a, b, c, d); + f = (v2sf) {8, 123}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* Case 4 {same, same} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {-5, -12}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_cabs_eq_ps (a, b, c, d); + f = (v2sf) {8, 78}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_cabs_eq_ps (a, b, c, d); + f = (v2sf) {33, 123}; + if (!__builtin_mips_all_c_eq_ps (e, f)) + abort (); + + /* Test all 16 operators */ + a = (v2sf) {-123, 123}; + b = (v2sf) {1000, -1000}; + c = (v2sf) {-33, 123}; + d = (v2sf) {8, -78}; + + e = test0 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test1 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test2 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test3 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test4 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test5 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test6 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test7 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test8 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test9 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test10 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test11 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test12 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test13 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test14 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test15 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test16 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test17 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test18 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test19 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test20 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test21 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test22 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test23 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test24 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test25 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test26 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test27 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test28 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test29 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test30 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test31 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + /* Reversed arguments */ + e = test0 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test1 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test2 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test3 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test4 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test5 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test6 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test7 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test8 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test9 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test10 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test11 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test12 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test13 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test14 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test15 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test16 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test17 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test18 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test19 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test20 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test21 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test22 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test23 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test24 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test25 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test26 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test27 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test28 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test29 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test30 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test31 (b, a, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + +#ifndef __FAST_MATH__ + /* Test all 16 operators */ + a = (v2sf) {qnan, qnan}; + b = (v2sf) {1000, -1000}; + c = (v2sf) {8, -78}; + d = (v2sf) {-33, 123}; + + e = test0 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test1 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test2 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test3 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test4 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test5 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test6 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test7 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test8 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test9 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test10 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test11 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test12 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test13 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test14 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test15 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test16 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test17 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test18 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test19 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test20 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test21 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test22 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test23 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test24 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test25 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test26 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test27 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + + e = test28 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); + e = test29 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + + e = test30 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, d)) + abort (); + e = test31 (a, b, c, d); + if (!__builtin_mips_all_c_eq_ps (e, c)) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +v2sf test0 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_f_ps (a, b, c, d); +} + +v2sf test1 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_f_ps (a, b, c, d); +} + +v2sf test2 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_un_ps (a, b, c, d); +} + +v2sf test3 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_un_ps (a, b, c, d); +} + +v2sf test4 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_eq_ps (a, b, c, d); +} + +v2sf test5 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_eq_ps (a, b, c, d); +} + +v2sf test6 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ueq_ps (a, b, c, d); +} + +v2sf test7 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ueq_ps (a, b, c, d); +} + +v2sf test8 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_olt_ps (a, b, c, d); +} + +v2sf test9 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_olt_ps (a, b, c, d); +} + +v2sf test10 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ult_ps (a, b, c, d); +} + +v2sf test11 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ult_ps (a, b, c, d); +} + +v2sf test12 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ole_ps (a, b, c, d); +} + +v2sf test13 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ole_ps (a, b, c, d); +} + +v2sf test14 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ule_ps (a, b, c, d); +} + +v2sf test15 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ule_ps (a, b, c, d); +} + +v2sf test16 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_sf_ps (a, b, c, d); +} + +v2sf test17 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_sf_ps (a, b, c, d); +} + +v2sf test18 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ngle_ps (a, b, c, d); +} + +v2sf test19 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ngle_ps (a, b, c, d); +} + +v2sf test20 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_seq_ps (a, b, c, d); +} + +v2sf test21 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_seq_ps (a, b, c, d); +} + +v2sf test22 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ngl_ps (a, b, c, d); +} + +v2sf test23 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ngl_ps (a, b, c, d); +} + +v2sf test24 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_lt_ps (a, b, c, d); +} + +v2sf test25 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_lt_ps (a, b, c, d); +} + +v2sf test26 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_nge_ps (a, b, c, d); +} + +v2sf test27 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_nge_ps (a, b, c, d); +} + +v2sf test28 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_le_ps (a, b, c, d); +} + +v2sf test29 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_le_ps (a, b, c, d); +} + +v2sf test30 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_cabs_ngt_ps (a, b, c, d); +} + +v2sf test31 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_cabs_ngt_ps (a, b, c, d); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-3d-9.c b/gcc/testsuite/gcc.target/mips/mips-3d-9.c new file mode 100644 index 00000000000..23a1f48f0fb --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-3d-9.c @@ -0,0 +1,158 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mips3d -mhard-float -mfp64" } */ + +/* Matrix Multiplications */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__((vector_size(8))); + +float a[4] = {1.1, 2.2, 3.3, 4.4}; +float b[4][4] = {{1, 2, 3, 4}, + {5, 6, 7, 8}, + {9, 10, 11, 12}, + {13, 14, 15, 16}}; + +float c[4]; /* Result for matrix_multiply1() */ +float d[4]; /* Result for matrix_multiply2() */ +float e[4]; /* Result for matrix_multiply3() */ +float f[4]; /* Result for matrix_multiply4() */ + +void matrix_multiply1(); +void matrix_multiply2(); +void matrix_multiply3(); +void matrix_multiply4(); + +int main () +{ + int i; + + /* Version 1. Use float calculations */ + matrix_multiply1(); + + /* Version 2. Use paired-single instructions inside the inner loop*/ + matrix_multiply2(); + for (i = 0; i < 4; i++) + if (d[i] != c[i]) + abort(); + + /* Version 3. Use paired-single instructions and unroll the inner loop */ + matrix_multiply3(); + for (i = 0; i < 4; i++) + if (e[i] != c[i]) + abort(); + + /* Version 4. Use paired-single instructions and unroll all loops */ + matrix_multiply4(); + for (i = 0; i < 4; i++) + if (f[i] != c[i]) + abort(); + + printf ("Test Passes\n"); + exit (0); +} + +void matrix_multiply1() +{ + int i, j; + + for (i = 0; i < 4; i++) + { + c[i] = 0.0; + + for (j = 0; j < 4; j ++) + c[i] += a[j] * b[j][i]; + } +} + +void matrix_multiply2() +{ + int i, j; + v2sf m1, m2; + v2sf result, temp; + + for (i = 0; i < 4; i++) + { + result = (v2sf) {0.0, 0.0}; + + for (j = 0; j < 4; j+=2) + { + /* Load two float values into m1 */ + m1 = (v2sf) {a[j], a[j+1]}; + m2 = (v2sf) {b[j][i], b[j+1][i]}; + + /* Multiply and add */ + result += m1 * m2; + } + + /* Reduction add at the end */ + temp = __builtin_mips_addr_ps (result, result); + d[i] = __builtin_mips_cvt_s_pl (temp); + } +} + +void matrix_multiply3() +{ + int i; + v2sf m1, m2, n1, n2; + v2sf result, temp; + + m1 = (v2sf) {a[0], a[1]}; + m2 = (v2sf) {a[2], a[3]}; + + for (i = 0; i < 4; i++) + { + n1 = (v2sf) {b[0][i], b[1][i]}; + n2 = (v2sf) {b[2][i], b[3][i]}; + + /* Multiply and add */ + result = m1 * n1 + m2 * n2; + + /* Reduction add at the end */ + temp = __builtin_mips_addr_ps (result, result); + e[i] = __builtin_mips_cvt_s_pl (temp); + } +} + +void matrix_multiply4() +{ + v2sf m1, m2; + v2sf n1, n2, n3, n4, n5, n6, n7, n8; + v2sf temp1, temp2, temp3, temp4; + v2sf result1, result2; + + /* Load a[0] a[1] values into m1 + Load a[2] a[3] values into m2 */ + m1 = (v2sf) {a[0], a[1]}; + m2 = (v2sf) {a[2], a[3]}; + + /* Load b[0][0] b[1][0] values into n1 + Load b[2][0] b[3][0] values into n2 + Load b[0][1] b[1][1] values into n3 + Load b[2][1] b[3][1] values into n4 + Load b[0][2] b[1][2] values into n5 + Load b[2][2] b[3][2] values into n6 + Load b[0][3] b[1][3] values into n7 + Load b[2][3] b[3][3] values into n8 */ + n1 = (v2sf) {b[0][0], b[1][0]}; + n2 = (v2sf) {b[2][0], b[3][0]}; + n3 = (v2sf) {b[0][1], b[1][1]}; + n4 = (v2sf) {b[2][1], b[3][1]}; + n5 = (v2sf) {b[0][2], b[1][2]}; + n6 = (v2sf) {b[2][2], b[3][2]}; + n7 = (v2sf) {b[0][3], b[1][3]}; + n8 = (v2sf) {b[2][3], b[3][3]}; + + temp1 = m1 * n1 + m2 * n2; + temp2 = m1 * n3 + m2 * n4; + temp3 = m1 * n5 + m2 * n6; + temp4 = m1 * n7 + m2 * n8; + + result1 = __builtin_mips_addr_ps (temp1, temp2); + result2 = __builtin_mips_addr_ps (temp3, temp4); + + f[0] = __builtin_mips_cvt_s_pu (result1); + f[1] = __builtin_mips_cvt_s_pl (result1); + f[2] = __builtin_mips_cvt_s_pu (result2); + f[3] = __builtin_mips_cvt_s_pl (result2); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-1.c b/gcc/testsuite/gcc.target/mips/mips-ps-1.c new file mode 100644 index 00000000000..78f5384aeff --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-ps-1.c @@ -0,0 +1,271 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mpaired-single -mhard-float -mfp64" } */ + +/* Test v2sf calculations */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size (8))); + +v2sf A = {100, 200}; + +/* Init from float */ +v2sf init (float a, float b) +{ + return (v2sf) {a, b}; +} + +/* Move between registers */ +v2sf move (v2sf a) +{ + return a; +} + +/* Load from memory */ +v2sf load () +{ + return A; +} + +/* Store to memory */ +void store (v2sf a) +{ + A = a; +} + +/* Add */ +v2sf add (v2sf a, v2sf b) +{ + return a + b; +} + +/* Subtract */ +v2sf sub (v2sf a, v2sf b) +{ + return a - b; +} + +/* Negate */ +v2sf neg (v2sf a) +{ + return - a; +} + +/* Multiply */ +v2sf mul (v2sf a, v2sf b) +{ + return a * b; +} + +/* Multiply and add */ +v2sf madd (v2sf a, v2sf b, v2sf c) +{ + return a * b + c; +} + +/* Multiply and subtract */ +v2sf msub (v2sf a, v2sf b, v2sf c) +{ + return a * b - c; +} + +/* Negate Multiply and add */ +v2sf nmadd (v2sf a, v2sf b, v2sf c) +{ + return - (a * b + c); +} + +/* Negate Multiply and subtract */ +v2sf nmsub (v2sf a, v2sf b, v2sf c) +{ + return - (a * b - c); +} + +/* Conditional Move */ +v2sf cond_move1 (v2sf a, v2sf b, long i) +{ + if (i > 0) + return a; + else + return b; +} + +/* Conditional Move */ +v2sf cond_move2 (v2sf a, v2sf b, int i) +{ + if (i > 0) + return a; + else + return b; +} + +/* Conditional Move */ +v2sf cond_move3 (v2sf a, v2sf b, float i) +{ + if (i > 0.0) + return a; + else + return b; +} + +/* Conditional Move */ +v2sf cond_move4 (v2sf a, v2sf b, double i) +{ + if (i > 0.0) + return a; + else + return b; +} + +int main() +{ + v2sf a, b, c, d, e, f; + float f1, f2; + + f1 = 1.2; + f2 = 3.4; + a = init (f1, f2); + b = (v2sf) {1.2, 3.4}; + if (!__builtin_mips_upper_c_eq_ps (a, b) || + !__builtin_mips_lower_c_eq_ps (a, b)) + abort (); + + a = (v2sf) {1.2, 2.3}; + b = (v2sf) {5.3, 6.1}; + b = move (a); + + if (!__builtin_mips_upper_c_eq_ps (a, b) || + !__builtin_mips_lower_c_eq_ps (a, b)) + abort (); + + a = (v2sf) {1.2, 2.3}; + b = (v2sf) {5.3, 6.1}; + c = add (a, b); + d = (v2sf) {6.5, 8.4}; + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = sub (a, b); + d = (v2sf) {-4, 6}; + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = mul (a, b); + d = (v2sf) {5, 72}; + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {5, 6}; + d = madd (a, b, c); + e = (v2sf) {10, 78}; + if (!__builtin_mips_upper_c_eq_ps (d, e) || + !__builtin_mips_lower_c_eq_ps (d, e)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {5, 6}; + d = msub (a, b, c); + e = (v2sf) {0, 66}; + if (!__builtin_mips_upper_c_eq_ps (d, e) || + !__builtin_mips_lower_c_eq_ps (d, e)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {5, 6}; + d = nmadd (a, b, c); + e = (v2sf) {-10, -78}; + if (!__builtin_mips_upper_c_eq_ps (d, e) || + !__builtin_mips_lower_c_eq_ps (d, e)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {5, 6}; + d = nmsub (a, b, c); + e = (v2sf) {0, -66}; + if (!__builtin_mips_upper_c_eq_ps (d, e) || + !__builtin_mips_lower_c_eq_ps (d, e)) + abort (); + + a = (v2sf) {98, 12}; + b = neg (a); + c = (v2sf) {-98, -12}; + if (!__builtin_mips_upper_c_eq_ps (b, c) || + !__builtin_mips_lower_c_eq_ps (b, c)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = cond_move1 (a, b, 1000); + if (!__builtin_mips_upper_c_eq_ps (c, a) || + !__builtin_mips_lower_c_eq_ps (c, a)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = cond_move2 (a, b, -1000); + if (!__builtin_mips_upper_c_eq_ps (c, b) || + !__builtin_mips_lower_c_eq_ps (c, b)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = cond_move3 (a, b, 9.0); + if (!__builtin_mips_upper_c_eq_ps (c, a) || + !__builtin_mips_lower_c_eq_ps (c, a)) + abort (); + + a = (v2sf) {1, 12}; + b = (v2sf) {5, 6}; + c = cond_move4 (a, b, -10.0); + if (!__builtin_mips_upper_c_eq_ps (c, b) || + !__builtin_mips_lower_c_eq_ps (c, b)) + abort (); + + a = (v2sf) {5, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_c_eq_ps (a, b, c, d); + f = (v2sf) {8, 123}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + a = (v2sf) {5, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movf_c_eq_ps (a, b, c, d); + f = (v2sf) {33, 78}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + a = load(); + b = (v2sf) {100, 200}; + if (!__builtin_mips_upper_c_eq_ps (a, b) || + !__builtin_mips_lower_c_eq_ps (a, b)) + abort (); + + a = (v2sf) {123, 321}; + store (a); + b = load(); + if (!__builtin_mips_upper_c_eq_ps (a, b) || + !__builtin_mips_lower_c_eq_ps (a, b)) + abort (); + + printf ("Test Passes\n"); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-2.c b/gcc/testsuite/gcc.target/mips/mips-ps-2.c new file mode 100644 index 00000000000..ef639e61203 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-ps-2.c @@ -0,0 +1,134 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mpaired-single -mhard-float -mfp64" } */ + +/* Test MIPS paired-single builtin functions */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__ ((vector_size(8))); + +int main () +{ + int little_endian; + v2sf a, b, c, d; + float e,f; + int i; + + union { long long ll; int i[2]; } endianness_test; + endianness_test.ll = 1; + little_endian = endianness_test.i[0]; + + /* pll.ps */ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 4}; + c = __builtin_mips_pll_ps (a, b); + if (little_endian) // little endian + d = (v2sf) {3, 1}; + else // big endian + d = (v2sf) {2, 4}; + + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + /* pul.ps */ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 4}; + c = __builtin_mips_pul_ps (a, b); + if (little_endian) // little endian + d = (v2sf) {3, 2}; + else // big endian + d = (v2sf) {1, 4}; + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + /* plu.ps */ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 4}; + c = __builtin_mips_plu_ps (a, b); + if (little_endian) // little endian + d = (v2sf) {4, 1}; + else // big endian + d = (v2sf) {2, 3}; + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + /* puu.ps */ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 4}; + c = __builtin_mips_puu_ps (a, b); + if (little_endian) // little endian + d = (v2sf) {4, 2}; + else // big endian + d = (v2sf) {1, 3}; + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + /* cvt.ps.s */ + e = 3.4; + f = 4.5; + a = __builtin_mips_cvt_ps_s (e, f); + if (little_endian) // little endian + b = (v2sf) {4.5, 3.4}; + else // big endian + b = (v2sf) {3.4, 4.5}; + if (!__builtin_mips_upper_c_eq_ps (a, b) || + !__builtin_mips_lower_c_eq_ps (a, b)) + abort (); + + /* cvt.s.pl */ + a = (v2sf) {35.1, 120.2}; + e = __builtin_mips_cvt_s_pl (a); + if (little_endian) // little endian + f = 35.1; + else // big endian + f = 120.2; + if (e != f) + abort (); + + /* cvt.s.pu */ + a = (v2sf) {30.0, 100.0}; + e = __builtin_mips_cvt_s_pu (a); + if (little_endian) // little endian + f = 100.0; + else // big endian + f = 30.0; + if (e != f) + abort (); + + /* abs.ps */ + a = (v2sf) {-3.4, -5.8}; + b = __builtin_mips_abs_ps (a); + c = (v2sf) {3.4, 5.8}; + if (!__builtin_mips_upper_c_eq_ps (b, c) || + !__builtin_mips_lower_c_eq_ps (b, c)) + abort (); + + /* alnv.ps with rs = 4*/ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 4}; + i = 4; + c = __builtin_mips_alnv_ps (a, b, i); + d = (v2sf) {2, 3}; + + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + /* alnv.ps with rs = 0 */ + a = (v2sf) {5, 6}; + b = (v2sf) {7, 8}; + i = 0; + c = __builtin_mips_alnv_ps (a, b, i); + d = (v2sf) {5, 6}; + + if (!__builtin_mips_upper_c_eq_ps (c, d) || + !__builtin_mips_lower_c_eq_ps (c, d)) + abort (); + + printf ("Test Passes\n"); + exit (0); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-3.c b/gcc/testsuite/gcc.target/mips/mips-ps-3.c new file mode 100644 index 00000000000..e4f4db2bdd7 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-ps-3.c @@ -0,0 +1,737 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mpaired-single -mhard-float -mfp64" } */ + +/* Test MIPS paired-single conditional move */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__((vector_size(8))); + +v2sf test0 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test1 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test2 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test3 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test4 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test5 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test6 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test7 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test8 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test9 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test10 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test11 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test12 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test13 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test14 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test15 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test16 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test17 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test18 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test19 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test20 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test21 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test22 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test23 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test24 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test25 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test26 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test27 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test28 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test29 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test30 (v2sf a, v2sf b, v2sf c, v2sf d); +v2sf test31 (v2sf a, v2sf b, v2sf c, v2sf d); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main () +{ + float f1; + v2sf a, b, c, d, e, f; + + /* Case 1 {diff, diff} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {9, 6}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_c_eq_ps (a, b, c, d); + f = (v2sf) {33, 123}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_c_eq_ps (a, b, c, d); + f = (v2sf) {8, 78}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* Case 2 {same, diff} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {5, 6}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_c_eq_ps (a, b, c, d); + f = (v2sf) {8, 123}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_c_eq_ps (a, b, c, d); + f = (v2sf) {33, 78}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* Case 3 {diff, same} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {9, 12}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_c_eq_ps (a, b, c, d); + f = (v2sf) {33, 78}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_c_eq_ps (a, b, c, d); + f = (v2sf) {8, 123}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* Case 4 {same, same} */ + /* movt.ps */ + a = (v2sf) {5, 12}; + b = (v2sf) {5, 12}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = __builtin_mips_movt_c_eq_ps (a, b, c, d); + f = (v2sf) {8, 78}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* movf.ps */ + e = __builtin_mips_movf_c_eq_ps (a, b, c, d); + f = (v2sf) {33, 123}; + if (!__builtin_mips_upper_c_eq_ps (e, f) || + !__builtin_mips_lower_c_eq_ps (e, f)) + abort (); + + /* Test all 16 operators */ + a = (v2sf) {123, 123}; + b = (v2sf) {1000, 1000}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = test0 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test1 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test2 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test3 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test4 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test5 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test6 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test7 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test8 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test9 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test10 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test11 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test12 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test13 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test14 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test15 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test16 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test17 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test18 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test19 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test20 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test21 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test22 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test23 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test24 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test25 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test26 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test27 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test28 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test29 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test30 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test31 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + /* Test all 16 operators with (b, a) */ + a = (v2sf) {123, 123}; + b = (v2sf) {1000, 1000}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = test0 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test1 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test2 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test3 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test4 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test5 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test6 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test7 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test8 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test9 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test10 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test11 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test12 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test13 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test14 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test15 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test16 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test17 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test18 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test19 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test20 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test21 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test22 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test23 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test24 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test25 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test26 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test27 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test28 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test29 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test30 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test31 (b, a, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + +#ifndef __FAST_MATH__ + /* Test with NaN */ + a = (v2sf) {qnan, qnan}; + b = (v2sf) {1000, 1000}; + c = (v2sf) {33, 123}; + d = (v2sf) {8, 78}; + e = test0 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test1 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test2 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test3 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test4 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test5 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test6 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test7 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test8 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test9 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test10 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test11 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test12 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test13 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test14 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test15 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test16 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test17 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test18 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test19 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test20 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test21 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test22 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test23 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test24 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test25 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test26 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test27 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + + e = test28 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); + e = test29 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + + e = test30 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, d) || + !__builtin_mips_lower_c_eq_ps (e, d)) + abort (); + e = test31 (a, b, c, d); + if (!__builtin_mips_upper_c_eq_ps (e, c) || + !__builtin_mips_lower_c_eq_ps (e, c)) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +v2sf test0 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_f_ps (a, b, c, d); +} + +v2sf test1 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_f_ps (a, b, c, d); +} + +v2sf test2 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_un_ps (a, b, c, d); +} + +v2sf test3 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_un_ps (a, b, c, d); +} + +v2sf test4 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_eq_ps (a, b, c, d); +} + +v2sf test5 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_eq_ps (a, b, c, d); +} + +v2sf test6 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ueq_ps (a, b, c, d); +} + +v2sf test7 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ueq_ps (a, b, c, d); +} + +v2sf test8 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_olt_ps (a, b, c, d); +} + +v2sf test9 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_olt_ps (a, b, c, d); +} + +v2sf test10 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ult_ps (a, b, c, d); +} + +v2sf test11 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ult_ps (a, b, c, d); +} + +v2sf test12 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ole_ps (a, b, c, d); +} + +v2sf test13 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ole_ps (a, b, c, d); +} + +v2sf test14 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ule_ps (a, b, c, d); +} + +v2sf test15 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ule_ps (a, b, c, d); +} + +v2sf test16 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_sf_ps (a, b, c, d); +} + +v2sf test17 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_sf_ps (a, b, c, d); +} + +v2sf test18 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ngle_ps (a, b, c, d); +} + +v2sf test19 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ngle_ps (a, b, c, d); +} + +v2sf test20 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_seq_ps (a, b, c, d); +} + +v2sf test21 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_seq_ps (a, b, c, d); +} + +v2sf test22 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ngl_ps (a, b, c, d); +} + +v2sf test23 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ngl_ps (a, b, c, d); +} + +v2sf test24 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_lt_ps (a, b, c, d); +} + +v2sf test25 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_lt_ps (a, b, c, d); +} + +v2sf test26 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_nge_ps (a, b, c, d); +} + +v2sf test27 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_nge_ps (a, b, c, d); +} + +v2sf test28 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_le_ps (a, b, c, d); +} + +v2sf test29 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_le_ps (a, b, c, d); +} + +v2sf test30 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movt_c_ngt_ps (a, b, c, d); +} + +v2sf test31 (v2sf a, v2sf b, v2sf c, v2sf d) +{ + return __builtin_mips_movf_c_ngt_ps (a, b, c, d); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-4.c b/gcc/testsuite/gcc.target/mips/mips-ps-4.c new file mode 100644 index 00000000000..9e0677e7dfa --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-ps-4.c @@ -0,0 +1,583 @@ +/* { dg-do run { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mpaired-single -mhard-float -mfp64" } */ + +/* Test MIPS paired-single comparisons */ +#include <stdlib.h> +#include <stdio.h> + +typedef float v2sf __attribute__((vector_size(8))); + +int test0 (v2sf a, v2sf b); +int test1 (v2sf a, v2sf b); +int test2 (v2sf a, v2sf b); +int test3 (v2sf a, v2sf b); +int test4 (v2sf a, v2sf b); +int test5 (v2sf a, v2sf b); +int test6 (v2sf a, v2sf b); +int test7 (v2sf a, v2sf b); +int test8 (v2sf a, v2sf b); +int test9 (v2sf a, v2sf b); +int test10 (v2sf a, v2sf b); +int test11 (v2sf a, v2sf b); +int test12 (v2sf a, v2sf b); +int test13 (v2sf a, v2sf b); +int test14 (v2sf a, v2sf b); +int test15 (v2sf a, v2sf b); +int test16 (v2sf a, v2sf b); +int test17 (v2sf a, v2sf b); +int test18 (v2sf a, v2sf b); +int test19 (v2sf a, v2sf b); +int test20 (v2sf a, v2sf b); +int test21 (v2sf a, v2sf b); +int test22 (v2sf a, v2sf b); +int test23 (v2sf a, v2sf b); +int test24 (v2sf a, v2sf b); +int test25 (v2sf a, v2sf b); +int test26 (v2sf a, v2sf b); +int test27 (v2sf a, v2sf b); +int test28 (v2sf a, v2sf b); +int test29 (v2sf a, v2sf b); +int test30 (v2sf a, v2sf b); +int test31 (v2sf a, v2sf b); + +float qnan = 1.0f/0.0f - 1.0f/0.0f; + +int main() +{ + union { long long ll; int i[2]; } endianness_test; + int little_endian; + v2sf a, b; + int i, j; + + endianness_test.ll = 1; + little_endian = endianness_test.i[0]; + + /* Case 1 {diff, diff} */ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 4}; + i = __builtin_mips_upper_c_eq_ps (a, b); + j = __builtin_mips_lower_c_eq_ps (a, b); + if (i != 0 || j != 0) + abort (); + + /* Case 2 {same, diff} */ + a = (v2sf) {1.0, 2.0}; + b = (v2sf) {1.0, 4.0}; + i = __builtin_mips_upper_c_eq_ps (a, b); + j = __builtin_mips_lower_c_eq_ps (a, b); + if (little_endian) + { + if (i != 0 || j != 1) + abort (); + } + else + { + if (i != 1 || j != 0) + abort (); + } + + /* Case 3 {diff, same} */ + a = (v2sf) {1, 2}; + b = (v2sf) {3, 2}; + i = __builtin_mips_upper_c_eq_ps (a, b); + j = __builtin_mips_lower_c_eq_ps (a, b); + if (little_endian) + { + if (i != 1 || j != 0) + abort (); + } + else + { + if (i != 0 || j != 1) + abort (); + } + + /* Case 4 {same, same} */ + a = (v2sf) {1, 2}; + b = (v2sf) {1, 2}; + i = __builtin_mips_upper_c_eq_ps (a, b); + j = __builtin_mips_lower_c_eq_ps (a, b); + if (i != 1 || j != 1) + abort (); + + /* Test upper/lower with 16 operators */ + if (little_endian) + { + a = (v2sf) {1984.0, 10.58}; + b = (v2sf) {1984.0, 567.345}; + } + else + { + a = (v2sf) {10.58, 1984.0}; + b = (v2sf) {567.345, 1984.0}; + } + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 0) + abort (); + i = test3 (a, b); + if (i != 0) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 1) + abort (); + i = test6 (a, b); + if (i != 0) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 1) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 1) + abort (); + i = test11 (a, b); + if (i != 0) + abort (); + i = test12 (a, b); + if (i != 1) + abort (); + i = test13 (a, b); + if (i != 1) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + i = test16 (a, b); + if (i != 0) + abort (); + i = test17 (a, b); + if (i != 0) + abort (); + i = test18 (a, b); + if (i != 0) + abort (); + i = test19 (a, b); + if (i != 0) + abort (); + i = test20 (a, b); + if (i != 0) + abort (); + i = test21 (a, b); + if (i != 1) + abort (); + i = test22 (a, b); + if (i != 0) + abort (); + i = test23 (a, b); + if (i != 1) + abort (); + i = test24 (a, b); + if (i != 1) + abort (); + i = test25 (a, b); + if (i != 0) + abort (); + i = test26 (a, b); + if (i != 1) + abort (); + i = test27 (a, b); + if (i != 0) + abort (); + i = test28 (a, b); + if (i != 1) + abort (); + i = test29 (a, b); + if (i != 1) + abort (); + i = test30 (a, b); + if (i != 1) + abort (); + i = test31 (a, b); + if (i != 1) + abort (); + + /* Reverse arguments */ + i = test0 (b, a); + if (i != 0) + abort (); + i = test1 (b, a); + if (i != 0) + abort (); + i = test2 (b, a); + if (i != 0) + abort (); + i = test3 (b, a); + if (i != 0) + abort (); + i = test4 (b, a); + if (i != 0) + abort (); + i = test5 (b, a); + if (i != 1) + abort (); + i = test6 (b, a); + if (i != 0) + abort (); + i = test7 (b, a); + if (i != 1) + abort (); + i = test8 (b, a); + if (i != 0) + abort (); + i = test9 (b, a); + if (i != 0) + abort (); + i = test10 (b, a); + if (i != 0) + abort (); + i = test11 (b, a); + if (i != 0) + abort (); + i = test12 (b, a); + if (i != 0) + abort (); + i = test13 (b, a); + if (i != 1) + abort (); + i = test14 (b, a); + if (i != 0) + abort (); + i = test15 (b, a); + if (i != 1) + abort (); + i = test16 (b, a); + if (i != 0) + abort (); + i = test17 (b, a); + if (i != 0) + abort (); + i = test18 (b, a); + if (i != 0) + abort (); + i = test19 (b, a); + if (i != 0) + abort (); + i = test20 (b, a); + if (i != 0) + abort (); + i = test21 (b, a); + if (i != 1) + abort (); + i = test22 (b, a); + if (i != 0) + abort (); + i = test23 (b, a); + if (i != 1) + abort (); + i = test24 (b, a); + if (i != 0) + abort (); + i = test25 (b, a); + if (i != 0) + abort (); + i = test26 (b, a); + if (i != 0) + abort (); + i = test27 (b, a); + if (i != 0) + abort (); + i = test28 (b, a); + if (i != 0) + abort (); + i = test29 (b, a); + if (i != 1) + abort (); + i = test30 (b, a); + if (i != 0) + abort (); + i = test31 (b, a); + if (i != 1) + abort (); + +#ifndef __FAST_MATH__ + /* Test upper/lower with 16 operators */ + if (little_endian) + { + a = (v2sf) {qnan, qnan}; + b = (v2sf) {1984.0, 567.345}; + } + else + { + a = (v2sf) {qnan, qnan}; + b = (v2sf) {567.345, 1984.0}; + } + + i = test0 (a, b); + if (i != 0) + abort (); + i = test1 (a, b); + if (i != 0) + abort (); + i = test2 (a, b); + if (i != 1) + abort (); + i = test3 (a, b); + if (i != 1) + abort (); + i = test4 (a, b); + if (i != 0) + abort (); + i = test5 (a, b); + if (i != 0) + abort (); + i = test6 (a, b); + if (i != 1) + abort (); + i = test7 (a, b); + if (i != 1) + abort (); + i = test8 (a, b); + if (i != 0) + abort (); + i = test9 (a, b); + if (i != 0) + abort (); + i = test10 (a, b); + if (i != 1) + abort (); + i = test11 (a, b); + if (i != 1) + abort (); + i = test12 (a, b); + if (i != 0) + abort (); + i = test13 (a, b); + if (i != 0) + abort (); + i = test14 (a, b); + if (i != 1) + abort (); + i = test15 (a, b); + if (i != 1) + abort (); + i = test16 (a, b); + if (i != 0) + abort (); + i = test17 (a, b); + if (i != 0) + abort (); + i = test18 (a, b); + if (i != 1) + abort (); + i = test19 (a, b); + if (i != 1) + abort (); + i = test20 (a, b); + if (i != 0) + abort (); + i = test21 (a, b); + if (i != 0) + abort (); + i = test22 (a, b); + if (i != 1) + abort (); + i = test23 (a, b); + if (i != 1) + abort (); + i = test24 (a, b); + if (i != 0) + abort (); + i = test25 (a, b); + if (i != 0) + abort (); + i = test26 (a, b); + if (i != 1) + abort (); + i = test27 (a, b); + if (i != 1) + abort (); + i = test28 (a, b); + if (i != 0) + abort (); + i = test29 (a, b); + if (i != 0) + abort (); + i = test30 (a, b); + if (i != 1) + abort (); + i = test31 (a, b); + if (i != 1) + abort (); +#endif + + printf ("Test Passes\n"); + exit (0); +} + +int test0 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_f_ps (a, b); +} + +int test1 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_f_ps (a, b); +} + +int test2 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_un_ps (a, b); +} + +int test3 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_un_ps (a, b); +} + +int test4 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_eq_ps (a, b); +} + +int test5 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_eq_ps (a, b); +} + +int test6 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ueq_ps (a, b); +} + +int test7 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ueq_ps (a, b); +} + +int test8 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_olt_ps (a, b); +} + +int test9 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_olt_ps (a, b); +} + +int test10 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ult_ps (a, b); +} + +int test11 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ult_ps (a, b); +} + +int test12 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ole_ps (a, b); +} + +int test13 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ole_ps (a, b); +} + +int test14 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ule_ps (a, b); +} + +int test15 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ule_ps (a, b); +} + +int test16 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_sf_ps (a, b); +} + +int test17 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_sf_ps (a, b); +} + +int test18 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ngle_ps (a, b); +} + +int test19 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ngle_ps (a, b); +} + +int test20 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_seq_ps (a, b); +} + +int test21 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_seq_ps (a, b); +} + +int test22 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ngl_ps (a, b); +} + +int test23 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ngl_ps (a, b); +} + +int test24 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_lt_ps (a, b); +} + +int test25 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_lt_ps (a, b); +} + +int test26 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_nge_ps (a, b); +} + +int test27 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_nge_ps (a, b); +} + +int test28 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_le_ps (a, b); +} + +int test29 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_le_ps (a, b); +} + +int test30 (v2sf a, v2sf b) +{ + return __builtin_mips_upper_c_ngt_ps (a, b); +} + +int test31 (v2sf a, v2sf b) +{ + return __builtin_mips_lower_c_ngt_ps (a, b); +} diff --git a/gcc/testsuite/gcc.target/mips/mips-ps-type.c b/gcc/testsuite/gcc.target/mips/mips-ps-type.c new file mode 100644 index 00000000000..b4d9a7b2085 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips-ps-type.c @@ -0,0 +1,110 @@ +/* Test v2sf calculations */ +/* { dg-do compile { target mipsisa64*-*-* } } */ +/* { dg-options "-mips64 -O2 -mpaired-single -mhard-float -mfp64" } */ +/* { dg-final { scan-assembler "cvt.ps.s" } } */ +/* { dg-final { scan-assembler "mov.ps" } } */ +/* { dg-final { scan-assembler "ldc1" } } */ +/* { dg-final { scan-assembler "sdc1" } } */ +/* { dg-final { scan-assembler "add.ps" } } */ +/* { dg-final { scan-assembler "sub.ps" } } */ +/* { dg-final { scan-assembler "neg.ps" } } */ +/* { dg-final { scan-assembler "mul.ps" } } */ +/* { dg-final { scan-assembler "madd.ps" } } */ +/* { dg-final { scan-assembler "msub.ps" } } */ +/* { dg-final { scan-assembler "nmadd.ps" } } */ +/* { dg-final { scan-assembler "nmsub.ps" } } */ +/* { dg-final { scan-assembler "mov(n|z).ps" } } */ + +typedef float v2sf __attribute__ ((vector_size(8))); + +v2sf A = {100, 200}; + +/* Init from floats */ +v2sf init (float a, float b) +{ + return (v2sf) {a, b}; +} + +/* Move between registers */ +v2sf move (v2sf a) +{ + return a; +} + +/* Load from memory */ +v2sf load () +{ + return A; +} + +/* Store to memory */ +void store (v2sf a) +{ + A = a; +} + +/* Add */ +v2sf add (v2sf a, v2sf b) +{ + return a + b; +} + +/* Subtract */ +v2sf sub (v2sf a, v2sf b) +{ + return a - b; +} + +/* Negate */ +v2sf neg (v2sf a) +{ + return - a; +} + +/* Multiply */ +v2sf mul (v2sf a, v2sf b) +{ + return a * b; +} + +/* Multiply and add */ +v2sf madd (v2sf a, v2sf b, v2sf c) +{ + return a * b + c; +} + +/* Multiply and subtract */ +v2sf msub (v2sf a, v2sf b, v2sf c) +{ + return a * b - c; +} + +/* Negate Multiply and add */ +v2sf nmadd (v2sf a, v2sf b, v2sf c) +{ + return - (a * b + c); +} + +/* Negate Multiply and subtract */ +v2sf nmsub (v2sf a, v2sf b, v2sf c) +{ + return - (a * b - c); +} + +/* Conditional Move */ +v2sf cond_move1 (v2sf a, v2sf b, long i) +{ + if (i > 0) + return a; + else + return b; +} + +/* Conditional Move */ +v2sf cond_move2 (v2sf a, v2sf b, int i) +{ + if (i > 0) + return a; + else + return b; +} diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp new file mode 100644 index 00000000000..56d1f4dbdb0 --- /dev/null +++ b/gcc/testsuite/gcc.target/mips/mips.exp @@ -0,0 +1,41 @@ +# Copyright (C) 1997 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# GCC testsuite that uses the `dg.exp' driver. + +# Exit immediately if this isn't a MIPS target. +if ![istarget mips*-*-*] then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \ + "" $DEFAULT_CFLAGS + +# All done. +dg-finish |