target/arm: Split out saturating/rounding shifts from neon
commit8b3f15b0a3b6d6ffbe7dfcb8dfbceb6d8da7ee6a
authorRichard Henderson <richard.henderson@linaro.org>
Tue, 25 May 2021 01:02:31 +0000 (24 18:02 -0700)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 25 May 2021 15:01:43 +0000 (25 16:01 +0100)
tree270d5ebbdd7b231ab39ac14eb46c43e50f89e2ce
parentdb366da809bf18749e43f6cbd947ffc596500675
target/arm: Split out saturating/rounding shifts from neon

Split these operations out into a header that can be shared
between neon and sve.  The "sat" pointer acts both as a boolean
for control of saturating behavior and controls the difference
in behavior between neon and sve -- QC bit or no QC bit.

Widen the shift operand in the new helpers, as the SVE2 insns treat
the whole input element as significant.  For the neon uses, truncate
the shift to int8_t while passing the parameter.

Implement right-shift rounding as

    tmp = src >> (shift - 1);
    dst = (tmp >> 1) + (tmp & 1);

This is the same number of instructions as the current

    tmp = 1 << (shift - 1);
    dst = (src + tmp) >> shift;

without any possibility of intermediate overflow.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210525010358.152808-6-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target/arm/neon_helper.c
target/arm/vec_internal.h