[PATCH] libstdc++: Fix find_last_set(simd_mask) to ignore padding bits
Jonathan Wakely
jwakely@redhat.com
Thu Jun 20 10:27:56 GMT 2024
On Tue, 18 Jun 2024 at 07:22, Matthias Kretz <m.kretz@gsi.de> wrote:
>
> Tested on x86_64-linux-gnu (also -m32 and -mx32), aarch64-linux-gnu, and arm-
> linux-gnueabi(hf).
>
> OK for trunk and backports? OK, to go for GCC 11.5 as early as possible?
OK for all branches, thanks.
>
> ----------------------- 8< -----------------------
>
> With the change to the AVX512 find_last_set implementation, the change
> to AVX512 operator!= is unnecessary. However, the latter was not
> producing optimal code and unnecessarily set the padding bits. In
> theory, the compiler could determine that with the new !=
> implementation, the bit operation for clearing the padding bits is a
> no-op and can be elided.
>
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/115454
> * include/experimental/bits/simd_x86.h (_S_not_equal_to): Use
> neq comparison instead of bitwise negation after eq.
> (_S_find_last_set): Clear unused high bits before computing
> bit_width.
> * testsuite/experimental/simd/pr115454_find_last_set.cc: New
> test.
> ---
> .../include/experimental/bits/simd_x86.h | 26 +++++-----
> .../simd/pr115454_find_last_set.cc | 49 +++++++++++++++++++
> 2 files changed, 62 insertions(+), 13 deletions(-)
> create mode 100644 libstdc++-v3/testsuite/experimental/simd/
> pr115454_find_last_set.cc
>
>
> --
> ──────────────────────────────────────────────────────────────────────────
> Dr. Matthias Kretz https://mattkretz.github.io
> GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
> stdₓ::simd
> ──────────────────────────────────────────────────────────────────────────
More information about the Libstdc++
mailing list