1 /* Helpers for SVE vector math functions.
3 Copyright (C) 2023 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <https://www.gnu.org/licenses/>. */
22 #define SV_NAME_F1(fun) _ZGVsMxv_##fun##f
23 #define SV_NAME_D1(fun) _ZGVsMxv_##fun
24 #define SV_NAME_F2(fun) _ZGVsMxvv_##fun##f
25 #define SV_NAME_D2(fun) _ZGVsMxvv_##fun
27 static __always_inline svfloat32_t
28 sv_call_f32 (float (*f) (float), svfloat32_t x, svfloat32_t y, svbool_t cmp)
30 svbool_t p = svpfirst (cmp, svpfalse ());
31 while (svptest_any (cmp, p))
33 float elem = svclastb_n_f32 (p, 0, x);
35 svfloat32_t y2 = svdup_n_f32 (elem);
36 y = svsel_f32 (p, y2, y);
37 p = svpnext_b32 (cmp, p);
42 static __always_inline svfloat64_t
43 sv_call_f64 (double (*f) (double), svfloat64_t x, svfloat64_t y, svbool_t cmp)
45 svbool_t p = svpfirst (cmp, svpfalse ());
46 while (svptest_any (cmp, p))
48 double elem = svclastb_n_f64 (p, 0, x);
50 svfloat64_t y2 = svdup_n_f64 (elem);
51 y = svsel_f64 (p, y2, y);
52 p = svpnext_b64 (cmp, p);