1*f3087befSAndrew Turner /*
2*f3087befSAndrew Turner * Single-precision SVE modff(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 "sv_math.h"
9*f3087befSAndrew Turner #include "test_sig.h"
10*f3087befSAndrew Turner #include "test_defs.h"
11*f3087befSAndrew Turner
12*f3087befSAndrew Turner /* Modff algorithm. Produces exact values in all rounding modes. */
SV_NAME_F1_L1(modf)13*f3087befSAndrew Turner svfloat32_t SV_NAME_F1_L1 (modf) (svfloat32_t x, float *out_int,
14*f3087befSAndrew Turner const svbool_t pg)
15*f3087befSAndrew Turner {
16*f3087befSAndrew Turner /* Get integer component of x. */
17*f3087befSAndrew Turner svfloat32_t fint_comp = svrintz_x (pg, x);
18*f3087befSAndrew Turner
19*f3087befSAndrew Turner svst1_f32 (pg, out_int, fint_comp);
20*f3087befSAndrew Turner
21*f3087befSAndrew Turner /* Subtract integer component from input. */
22*f3087befSAndrew Turner svfloat32_t remaining = svsub_f32_x (svptrue_b32 (), x, fint_comp);
23*f3087befSAndrew Turner
24*f3087befSAndrew Turner /* Return +0 for integer x. */
25*f3087befSAndrew Turner svbool_t is_integer = svcmpeq (pg, x, fint_comp);
26*f3087befSAndrew Turner return svsel (is_integer, sv_f32 (0), remaining);
27*f3087befSAndrew Turner }
28*f3087befSAndrew Turner
29*f3087befSAndrew Turner TEST_ULP (_ZGVsMxvl4_modff_frac, 0.0)
30*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVsMxvl4_modff_frac, 0, 1, 20000)
31*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVsMxvl4_modff_frac, 1, inf, 20000)
32*f3087befSAndrew Turner
33*f3087befSAndrew Turner TEST_ULP (_ZGVsMxvl4_modff_int, 0.0)
34*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVsMxvl4_modff_int, 0, 1, 20000)
35*f3087befSAndrew Turner TEST_SYM_INTERVAL (_ZGVsMxvl4_modff_int, 1, inf, 20000)
36*f3087befSAndrew Turner CLOSE_SVE_ATTR
37