1 /* Test llrintf4 for SPU
2 Copyright (C) 2006, 2007 Sony Computer Entertainment Inc.
5 Redistribution and use in source and binary forms,
6 with or without modification, are permitted provided that the
7 following conditions are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of the Sony Computer Entertainment Inc nor the names
14 of its contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 POSSIBILITY OF SUCH DAMAGE.
31 *@@ llrintf4 - rounds four floats in to four nearest 64bit integer.
34 * boundary test for llrintf4. On SPU the rounding mode for floats is always towards 0.
39 * Run this program and check no error will be occurred.
52 #include "common-test.h"
53 #include "testutils.h"
55 static inline llroundf4_t set_llrintf4_t(long long int in0, long long int in1, long long int in2, long long int in3)
59 res.vll[0] = ((vec_llong2){in0,in1});
60 res.vll[1] = ((vec_llong2){in2,in3});
66 TEST_SET_START("20060918101000NM","NM", "llrintf4");
68 // unsigned long i11 = 0x5efffffful; // 9223371487098961920
69 // unsigned long i12 = 0xdefffffful; //-9223371487098961920
70 // unsigned long i11 = 0x49fffffful; //2097151.875000
71 // unsigned long i12 = 0x4a7ffffful; //4194303.750000
73 // float x0 = hide_float(-FLT_MAX); // -Inf
74 // float x1 = hide_float(FLT_MAX); // Inf
75 float x2 = hide_float(0.0); // +0
76 float x3 = hide_float(-0.0); // -0
77 // float x4 = hide_float(NANF); // NaN -> NaN
78 float x5 = hide_float( 0.5);
79 float x6 = hide_float(-0.5);
80 float x7 = hide_float(-0.499999);
81 float x8 = hide_float( 0.499999);
82 float x9 = hide_float(-999999.5);
83 float x10 = hide_float( 999999.5);
84 // float x11 = hide_float(make_float(i11));
85 // float x12 = hide_float(make_float(i12));
86 float x11 = hide_float( 9223371487098961920.);
87 float x12 = hide_float(-9223371487098961920.);
88 float x13 = (0.0 - FLT_MIN);
90 float x15 = hide_float(-2097151.875000);
91 float x16 = hide_float(-4194303.750000);
92 float x17 = hide_float( 4194303.750000);
93 float x18 = hide_float( 2097151.875000);
95 vec_float4 x0_v = ((vec_float4){ x2, x3, x5, x6});
96 llroundf4_t r0_v = set_llrintf4_t(0, 0, 0, 0);
98 vec_float4 x1_v = ((vec_float4){ x7, x8, x9, x10});
99 llroundf4_t r1_v = set_llrintf4_t(0, 0, -999999, 999999);
101 vec_float4 x2_v = ((vec_float4){ x11, x12, x13, x14});
102 llroundf4_t r2_v = set_llrintf4_t(9223371487098961920ll, -9223371487098961920ll, 0, 0);
104 vec_float4 x3_v = ((vec_float4){ x15, x16, x17, x18});
105 llroundf4_t r3_v = set_llrintf4_t(-2097151, -4194303, 4194303, 2097151);
109 TEST_START("llrintf4");
110 res_v = llrintf4 (x0_v);
111 TEST_CHECK("20060918101001NM", allequal_llroundf4( res_v, r0_v ), 0);
112 res_v = llrintf4 (x1_v);
113 TEST_CHECK("20060918101002NM", allequal_llroundf4( res_v, r1_v ), 0);
114 res_v = llrintf4 (x2_v);
115 TEST_CHECK("20060918101003NM", allequal_llroundf4( res_v, r2_v ), 0);
116 res_v = llrintf4 (x3_v);
117 TEST_CHECK("20060918101004NM", allequal_llroundf4( res_v, r3_v ), 0);