1 /*
2 * Double-precision SVE modf(x, *y) function.
3 *
4 * Copyright (c) 2024, Arm Limited.
5 * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6 */
7
8 #include "sv_math.h"
9 #include "test_sig.h"
10 #include "test_defs.h"
11
12 /* Modf algorithm. Produces exact values in all rounding modes. */
SV_NAME_D1_L1(modf)13 svfloat64_t SV_NAME_D1_L1 (modf) (svfloat64_t x, double *out_int,
14 const svbool_t pg)
15 {
16 /* Get integer component of x. */
17 svfloat64_t fint_comp = svrintz_x (pg, x);
18
19 svst1_f64 (pg, out_int, fint_comp);
20
21 /* Subtract integer component from input. */
22 svfloat64_t remaining = svsub_f64_x (svptrue_b64 (), x, fint_comp);
23
24 /* Return +0 for integer x. */
25 svbool_t is_integer = svcmpeq (pg, x, fint_comp);
26 return svsel (is_integer, sv_f64 (0), remaining);
27 }
28
29 TEST_ULP (_ZGVsMxvl8_modf_frac, 0.0)
30 TEST_SYM_INTERVAL (_ZGVsMxvl8_modf_frac, 0, 1, 20000)
31 TEST_SYM_INTERVAL (_ZGVsMxvl8_modf_frac, 1, inf, 20000)
32
33 TEST_ULP (_ZGVsMxvl8_modf_int, 0.0)
34 TEST_SYM_INTERVAL (_ZGVsMxvl8_modf_int, 0, 1, 20000)
35 TEST_SYM_INTERVAL (_ZGVsMxvl8_modf_int, 1, inf, 20000)
36 CLOSE_SVE_ATTR
37