tests/hexagon: add tests for v68 HVX IEEE float min/max
Reviewed-by: Taylor Simpson <ltaylorsimpson@gmail.com> Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com> Reviewed-by: Brian Cain <brian.cain@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/7fdbc12ed4c62a16068c380a85ee2356051e61ea.1776339451.git.matheus.bernardino@oss.qualcomm.com Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
Matheus Tavares Bernardino committed
Apr 16, 2026 at 04:39 UTC
7f3a641101f683549e60de55d30c5006ee97d996
1 file changed
+30
tests/tcg/hexagon/fp_hvx.c
+30
@@ -73,6 +73,30 @@ DEF_TEST_OP_2(vsub, SUB_HF, hf, hf);
73
DEF_TEST_OP_2(vmpy, MULT_SF, sf, sf);
74
DEF_TEST_OP_2(vmpy, MULT_HF, hf, hf);
75
76
+#define signbit_fp(X) \
77
+ (sizeof(X) == bytes_hf ? ((raw_hf(X) & 0x8000) != 0) : \
78
+ ((raw_sf(X) & 0x80000000) != 0))
79
+
80
+#define STD_MIN(X, Y) ((X) < (Y) ? (X) : (Y))
81
+#define STD_MAX(X, Y) ((X) > (Y) ? (X) : (Y))
82
+
83
+#define MIN(X, Y, DEF_NAN) \
84
+ ((isnan(X) || isnan(Y)) ? DEF_NAN : \
85
+ ((X) != (Y)) ? STD_MIN(X, Y) : (signbit_fp(X) ? (X) : (Y))) /* -0 < +0 */
86
+#define MAX(X, Y, DEF_NAN) \
87
+ ((isnan(X) || isnan(Y)) ? DEF_NAN : \
88
+ ((X) != (Y)) ? STD_MAX(X, Y) : (signbit_fp(X) ? (Y) : (X))) /* -0 < +0 */
89
+
90
+#define MIN_HF(X, Y) MIN(X, Y, NAN_HF)
91
+#define MAX_HF(X, Y) MAX(X, Y, NAN_HF)
92
+#define MIN_SF(X, Y) MIN(X, Y, NAN_SF)
93
+#define MAX_SF(X, Y) MAX(X, Y, NAN_SF)
94
+
95
+DEF_TEST_OP_2(vfmin, MIN_SF, sf, sf);
96
+DEF_TEST_OP_2(vfmax, MAX_SF, sf, sf);
97
+DEF_TEST_OP_2(vfmin, MIN_HF, hf, hf);
98
+DEF_TEST_OP_2(vfmax, MAX_HF, hf, hf);
99
+
100
/******************************************************************************
101
* Other tests
102
*****************************************************************************/
@@ -150,6 +174,12 @@ int main(void)
174
175
test_new();
176
177
+ /* min/max */
178
+ test_vfmin_sf_sf();
179
+ test_vfmin_hf_hf();
180
+ test_vfmax_sf_sf();
181
+ test_vfmax_hf_hf();
182
+
183
puts(err ? "FAIL" : "PASS");
184
return err ? 1 : 0;
185
}