Re: [RFC PATCH v3 29/37] kvx: Add some library functions

Arnd Bergmann
2024-07-23T09:27:20Z

> +static inline uint64x4_t uint64x2_divmod(uint64x2_t a, uint64x2_t b)
> +{
> + float64x2_t double1 = 1.0 - (float64x2_t){};
> + int64x2_t bbig = (int64x2_t)b < 0;
> + int64x2_t bin01 = (uint64x2_t)b <= 1;
> + int64x2_t special = bbig | bin01;
> + // uint64x2_t q = bbig ? a >= b : a;
> + uint64x2_t q = __builtin_kvx_selectdp(-(a >= b), a, bbig, ".nez");
> + // uint64x2_t r = bbig ? a - (b&-q) : 0;
> + uint64x2_t r = __builtin_kvx_selectdp(a - (b & -q), 0 -
> (uint64x2_t){}, bbig, ".nez");
> + float64x2_t doublea = __builtin_kvx_floatudp(a, 0, ".rn.s");
> + float64x2_t doubleb = __builtin_kvx_floatudp(b, 0, ".rn.s");

How does this work with the use of floating point registers?
On most architectures, this is not allowed in the kernel in
order to avoid having to save/restore them on each context
switch. Does kvx use the same registers for integer and float
operations, or do you always save them?

Arnd