[PATCH] libstdc++: Fix find_last_set(simd_mask) to ignore padding bits
Matthias Kretz
m.kretz@gsi.de
Tue Jun 18 06:22:13 GMT 2024
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?
----------------------- 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
──────────────────────────────────────────────────────────────────────────
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libstdc-Fix-find_last_set-simd_mask-to-ignore-paddin.patch
Type: text/x-patch
Size: 4574 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20240618/13336ecd/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20240618/13336ecd/attachment-0001.sig>
More information about the Gcc-patches
mailing list