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