1 /* Test fminf4 and fmaxf4 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.
36 #include "common-test.h"
37 #include "testutils.h"
42 TEST_SET_START("20040928184342EJL","EJL", "fminf4_fmaxf4");
44 float x0min = hide_float(1760.135f);
45 float x0max = hide_float(19355.03f);
47 float x1min = hide_float(-12351.9f);
48 float x1max = hide_float(-139.035f);
50 float x2min = hide_float(-1.0);
51 float x2max = hide_float(0.0);
53 vec_float4 x0min_v = spu_splats(x0min);
54 vec_float4 x0max_v = spu_splats(x0max);
56 vec_float4 x1min_v = spu_splats(x1min);
57 vec_float4 x1max_v = spu_splats(x1max);
59 vec_float4 x2min_v = spu_splats(x2min);
60 vec_float4 x2max_v = spu_splats(x2max);
66 res_v = fminf4(x0min_v, x0max_v);
67 TEST_CHECK("20040928184345EJL", allequal_float4( res_v, x0min_v ), 0);
68 res_v = fminf4(x0max_v, x0min_v);
69 TEST_CHECK("20040928184349EJL", allequal_float4( res_v, x0min_v ), 0);
70 res_v = fminf4(x1min_v, x1max_v);
71 TEST_CHECK("20040928184351EJL", allequal_float4( res_v, x1min_v ), 0);
72 res_v = fminf4(x1max_v, x1min_v);
73 TEST_CHECK("20040928184353EJL", allequal_float4( res_v, x1min_v ), 0);
74 res_v = fminf4(x2min_v, x2max_v);
75 TEST_CHECK("20040928184354EJL", allequal_float4( res_v, x2min_v ), 0);
76 res_v = fminf4(x2max_v, x2min_v);
77 TEST_CHECK("20040928184356EJL", allequal_float4( res_v, x2min_v ), 0);
80 res = fminf(x0min, x0max);
81 TEST_CHECK("20040928184358EJL", res == x0min, 0);
82 res = fminf(x0max, x0min);
83 TEST_CHECK("20040928184400EJL", res == x0min, 0);
84 res = fminf(x1min, x1max);
85 TEST_CHECK("20040928184401EJL", res == x1min, 0);
86 res = fminf(x1max, x1min);
87 TEST_CHECK("20040928184403EJL", res == x1min, 0);
88 res = fminf(x2min, x2max);
89 TEST_CHECK("20040928184405EJL", res == x2min, 0);
90 res = fminf(x2max, x2min);
91 TEST_CHECK("20040928184406EJL", res == x2min, 0);
94 res_v = fmaxf4(x0min_v, x0max_v);
95 TEST_CHECK("20040928184411EJL", allequal_float4( res_v, x0max_v ), 0);
96 res_v = fmaxf4(x0max_v, x0min_v);
97 TEST_CHECK("20040928184413EJL", allequal_float4( res_v, x0max_v ), 0);
98 res_v = fmaxf4(x1min_v, x1max_v);
99 TEST_CHECK("20040928184415EJL", allequal_float4( res_v, x1max_v ), 0);
100 res_v = fmaxf4(x1max_v, x1min_v);
101 TEST_CHECK("20040928184416EJL", allequal_float4( res_v, x1max_v ), 0);
102 res_v = fmaxf4(x2min_v, x2max_v);
103 TEST_CHECK("20040928184417EJL", allequal_float4( res_v, x2max_v ), 0);
104 res_v = fmaxf4(x2max_v, x2min_v);
105 TEST_CHECK("20040928184419EJL", allequal_float4( res_v, x2max_v ), 0);
108 res = fmaxf(x0min, x0max);
109 TEST_CHECK("20040928184420EJL", res == x0max, 0);
110 res = fmaxf(x0max, x0min);
111 TEST_CHECK("20040928184422EJL", res == x0max, 0);
112 res = fmaxf(x1min, x1max);
113 TEST_CHECK("20040928184423EJL", res == x1max, 0);
114 res = fmaxf(x1max, x1min);
115 TEST_CHECK("20040928184424EJL", res == x1max, 0);
116 res = fmaxf(x2min, x2max);
117 TEST_CHECK("20040928184426EJL", res == x2max, 0);
118 res = fmaxf(x2max, x2min);
119 TEST_CHECK("20040928184428EJL", res == x2max, 0);