[PATCH 3/5] libstdc++: Optimize simd conversions on x86-64

Matthias Kretz MatthiasKretz@gmx.net
Mon Mar 2 10:15:18 GMT 2026


Without SSSE3/SSE4, GCC falls back to converting scalars, which is not
efficient.

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

libstdc++-v3/ChangeLog:

	* include/bits/simd_vec.h (basic_vec::basic_vec): Improve
	code-gen of conversions from 4-Byte 2/3/4 register vec to
	single-register 1/2-Byte integer.
	* include/bits/vec_ops.h (__vec_interleave_lo)
	(__vec_interleave_hi): New.
	(__vec_cast): Improve code-gen of conversions without SSE4
	instructions.
	* testsuite/std/simd/sse2_efficient_cvt_x4.cc: New test.
---
 libstdc++-v3/include/bits/simd_vec.h          |  84 ++++++++++++++
 libstdc++-v3/include/bits/vec_ops.h           |  70 ++++++++++++
 .../std/simd/sse2_efficient_cvt_x4.cc         | 105 ++++++++++++++++++
 3 files changed, 259 insertions(+)
 create mode 100644 libstdc++-v3/testsuite/std/simd/sse2_efficient_cvt_x4.cc


--
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Center for Heavy Ion Research               https://gsi.de
 std::simd
──────────────────────────────────────────────────────────────────────────
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-libstdc-Optimize-simd-conversions-on-x86-64.patch
Type: text/x-patch
Size: 9226 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20260302/1107fb0f/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/libstdc++/attachments/20260302/1107fb0f/attachment-0001.sig>


More information about the Libstdc++ mailing list