1*f3087befSAndrew Turner /*
2*f3087befSAndrew Turner * Double-precision vector modf(x, *y) function.
3*f3087befSAndrew Turner *
4*f3087befSAndrew Turner * Copyright (c) 2024, Arm Limited.
5*f3087befSAndrew Turner * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
6*f3087befSAndrew Turner */
7*f3087befSAndrew Turner
8*f3087befSAndrew Turner #include "v_math.h"
9*f3087befSAndrew Turner #include "test_sig.h"
10*f3087befSAndrew Turner #include "test_defs.h"
11*f3087befSAndrew Turner
12*f3087befSAndrew Turner /* Modf algorithm. Produces exact values in all rounding modes. */
V_NAME_D1_L1(modf)13*f3087befSAndrew Turner float64x2_t VPCS_ATTR V_NAME_D1_L1 (modf) (float64x2_t x, double *out_int)
14*f3087befSAndrew Turner {
15*f3087befSAndrew Turner /* Get integer component of x. */
16*f3087befSAndrew Turner float64x2_t rounded = vrndq_f64 (x);
17*f3087befSAndrew Turner vst1q_f64 (out_int, rounded);
18*f3087befSAndrew Turner
19*f3087befSAndrew Turner /* Subtract integer component from input. */
20*f3087befSAndrew Turner uint64x2_t remaining = vreinterpretq_u64_f64 (vsubq_f64 (x, rounded));
21*f3087befSAndrew Turner
22*f3087befSAndrew Turner /* Return +0 for integer x. */
23*f3087befSAndrew Turner uint64x2_t is_integer = vceqq_f64 (x, rounded);
24*f3087befSAndrew Turner return vreinterpretq_f64_u64 (vbicq_u64 (remaining, is_integer));
25*f3087befSAndrew Turner }
26*f3087befSAndrew Turner
27*f3087befSAndrew Turner TEST_ULP (_ZGVnN2vl8_modf_frac, 0.0)
28*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVnN2vl8_modf_frac, 0, 1, 20000)
29*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVnN2vl8_modf_frac, 1, inf, 20000)
30*f3087befSAndrew Turner
31*f3087befSAndrew Turner TEST_ULP (_ZGVnN2vl8_modf_int, 0.0)
32*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVnN2vl8_modf_int, 0, 1, 20000)
33*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVnN2vl8_modf_int, 1, inf, 20000)
34