[PATCH] libstdc++: Fix simd<char> conversion for -fno-signed-char for Clang

Matthias Kretz m.kretz@gsi.de
Mon Jun 3 15:31:01 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?

----------------------- 8< -----------------------

The special case for Clang in the trait producing a signed integer type
lead to the trait returning 'char' where it should have been 'signed
char'. This workaround was introduced because on Clang the return type
of vector compares was not convertible to '_SimdWrapper<
__int_for_sizeof_t<...' unless '__int_for_sizeof_t<char>' was an alias
for 'char'. In order to not rewrite the complete mask type code (there
is code scattered around the implementation assuming signed integers),
this needs to be 'signed char'; so the special case for Clang needs to
be removed.
The conversion issue is now solved in _SimdWrapper, which now
additionally allows conversion from vector types with compatible
integral type.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/115308
	* include/experimental/bits/simd.h (__int_for_sizeof): Remove
	special cases for __clang__.
	(_SimdWrapper): Change constructor overload set to allow
	conversion from vector types with integral conversions via bit
	reinterpretation.
---
 libstdc++-v3/include/experimental/bits/simd.h | 45 +++++++++++--------
 1 file changed, 27 insertions(+), 18 deletions(-)


--
──────────────────────────────────────────────────────────────────────────
 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-simd-char-conversion-for-fno-signed-char.patch
Type: text/x-patch
Size: 3683 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20240603/e1b8c802/attachment-0001.bin>


More information about the Libstdc++ mailing list