| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-mpaired-single forbid_cpu=octeon.* (REQUIRES_STDLIB)" } */ |
| 3 |
|
| 4 |
/* Test MIPS paired-single builtin functions */ |
| 5 |
#include <stdlib.h> |
| 6 |
#include <stdio.h> |
| 7 |
|
| 8 |
typedef float v2sf __attribute__ ((vector_size(8))); |
| 9 |
|
| 10 |
NOMIPS16 int main () |
| 11 |
{ |
| 12 |
int little_endian; |
| 13 |
v2sf a, b, c, d; |
| 14 |
float e,f; |
| 15 |
int i; |
| 16 |
|
| 17 |
union { long long ll; int i[2]; } endianness_test; |
| 18 |
endianness_test.ll = 1; |
| 19 |
little_endian = endianness_test.i[0]; |
| 20 |
|
| 21 |
/* pll.ps */ |
| 22 |
a = (v2sf) {1, 2}; |
| 23 |
b = (v2sf) {3, 4}; |
| 24 |
c = __builtin_mips_pll_ps (a, b); |
| 25 |
if (little_endian) // little endian |
| 26 |
d = (v2sf) {3, 1}; |
| 27 |
else // big endian |
| 28 |
d = (v2sf) {2, 4}; |
| 29 |
|
| 30 |
if (!__builtin_mips_upper_c_eq_ps (c, d) || |
| 31 |
!__builtin_mips_lower_c_eq_ps (c, d)) |
| 32 |
abort (); |
| 33 |
|
| 34 |
/* pul.ps */ |
| 35 |
a = (v2sf) {1, 2}; |
| 36 |
b = (v2sf) {3, 4}; |
| 37 |
c = __builtin_mips_pul_ps (a, b); |
| 38 |
if (little_endian) // little endian |
| 39 |
d = (v2sf) {3, 2}; |
| 40 |
else // big endian |
| 41 |
d = (v2sf) {1, 4}; |
| 42 |
if (!__builtin_mips_upper_c_eq_ps (c, d) || |
| 43 |
!__builtin_mips_lower_c_eq_ps (c, d)) |
| 44 |
abort (); |
| 45 |
|
| 46 |
/* plu.ps */ |
| 47 |
a = (v2sf) {1, 2}; |
| 48 |
b = (v2sf) {3, 4}; |
| 49 |
c = __builtin_mips_plu_ps (a, b); |
| 50 |
if (little_endian) // little endian |
| 51 |
d = (v2sf) {4, 1}; |
| 52 |
else // big endian |
| 53 |
d = (v2sf) {2, 3}; |
| 54 |
if (!__builtin_mips_upper_c_eq_ps (c, d) || |
| 55 |
!__builtin_mips_lower_c_eq_ps (c, d)) |
| 56 |
abort (); |
| 57 |
|
| 58 |
/* puu.ps */ |
| 59 |
a = (v2sf) {1, 2}; |
| 60 |
b = (v2sf) {3, 4}; |
| 61 |
c = __builtin_mips_puu_ps (a, b); |
| 62 |
if (little_endian) // little endian |
| 63 |
d = (v2sf) {4, 2}; |
| 64 |
else // big endian |
| 65 |
d = (v2sf) {1, 3}; |
| 66 |
if (!__builtin_mips_upper_c_eq_ps (c, d) || |
| 67 |
!__builtin_mips_lower_c_eq_ps (c, d)) |
| 68 |
abort (); |
| 69 |
|
| 70 |
/* cvt.ps.s */ |
| 71 |
e = 3.4; |
| 72 |
f = 4.5; |
| 73 |
a = __builtin_mips_cvt_ps_s (e, f); |
| 74 |
if (little_endian) // little endian |
| 75 |
b = (v2sf) {4.5, 3.4}; |
| 76 |
else // big endian |
| 77 |
b = (v2sf) {3.4, 4.5}; |
| 78 |
if (!__builtin_mips_upper_c_eq_ps (a, b) || |
| 79 |
!__builtin_mips_lower_c_eq_ps (a, b)) |
| 80 |
abort (); |
| 81 |
|
| 82 |
/* cvt.s.pl */ |
| 83 |
a = (v2sf) {35.1, 120.2}; |
| 84 |
e = __builtin_mips_cvt_s_pl (a); |
| 85 |
if (little_endian) // little endian |
| 86 |
f = 35.1; |
| 87 |
else // big endian |
| 88 |
f = 120.2; |
| 89 |
if (e != f) |
| 90 |
abort (); |
| 91 |
|
| 92 |
/* cvt.s.pu */ |
| 93 |
a = (v2sf) {30.0, 100.0}; |
| 94 |
e = __builtin_mips_cvt_s_pu (a); |
| 95 |
if (little_endian) // little endian |
| 96 |
f = 100.0; |
| 97 |
else // big endian |
| 98 |
f = 30.0; |
| 99 |
if (e != f) |
| 100 |
abort (); |
| 101 |
|
| 102 |
/* abs.ps */ |
| 103 |
a = (v2sf) {-3.4, -5.8}; |
| 104 |
b = __builtin_mips_abs_ps (a); |
| 105 |
c = (v2sf) {3.4, 5.8}; |
| 106 |
if (!__builtin_mips_upper_c_eq_ps (b, c) || |
| 107 |
!__builtin_mips_lower_c_eq_ps (b, c)) |
| 108 |
abort (); |
| 109 |
|
| 110 |
/* alnv.ps with rs = 4*/ |
| 111 |
a = (v2sf) {1, 2}; |
| 112 |
b = (v2sf) {3, 4}; |
| 113 |
i = 4; |
| 114 |
c = __builtin_mips_alnv_ps (a, b, i); |
| 115 |
d = (v2sf) {2, 3}; |
| 116 |
|
| 117 |
if (!__builtin_mips_upper_c_eq_ps (c, d) || |
| 118 |
!__builtin_mips_lower_c_eq_ps (c, d)) |
| 119 |
abort (); |
| 120 |
|
| 121 |
/* alnv.ps with rs = 0 */ |
| 122 |
a = (v2sf) {5, 6}; |
| 123 |
b = (v2sf) {7, 8}; |
| 124 |
i = 0; |
| 125 |
c = __builtin_mips_alnv_ps (a, b, i); |
| 126 |
d = (v2sf) {5, 6}; |
| 127 |
|
| 128 |
if (!__builtin_mips_upper_c_eq_ps (c, d) || |
| 129 |
!__builtin_mips_lower_c_eq_ps (c, d)) |
| 130 |
abort (); |
| 131 |
|
| 132 |
printf ("Test Passes\n"); |
| 133 |
exit (0); |
| 134 |
} |