https://gcc.gnu.org/g:5b3c70cdb8474a0a489ca7401a37ad18229eafda
commit r17-5575-g5b3c70cdb8474a0a489ca7401a37ad18229eafda Author: Richard Biener <[email protected]> Date: Mon Oct 26 11:41:22 2026 +0100 tree-optimization/128133 - wrong vectorized _BitInt load The following plugs the only halfway supported vectorization of _BitInt at the load side where we currently fail to handle padding bits correctly. PR tree-optimization/128133 * tree-vect-stmts.cc (vectorizable_load): Reject _BitInt loads of non-mode precision. * gcc.dg/vect/vect-pr128133.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/vect-pr128133.c | 24 ++++++++++++++++++++++++ gcc/tree-vect-stmts.cc | 9 +++++++++ 2 files changed, 33 insertions(+) diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr128133.c b/gcc/testsuite/gcc.dg/vect/vect-pr128133.c new file mode 100644 index 000000000000..933592384a4e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr128133.c @@ -0,0 +1,24 @@ +/* { dg-require-effective-target bitint } */ + +#include "tree-vect.h" + +__attribute__((noipa)) +void convert(unsigned *dst, unsigned _BitInt(17) *src) +{ + for (int i = 0; i < 4; ++i) + dst[i] = src[i]; +} + +int main() +{ + unsigned _BitInt(17) src[4]; + unsigned dst[4]; + + check_vect (); + + __builtin_memset(src, 0xff, sizeof src); + convert(dst, src); + if (dst[0] != 131071) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 6e7e948ff1e4..38f9ad01e87b 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9958,6 +9958,15 @@ vectorizable_load (vec_info *vinfo, bool type_mode_padding_p = TYPE_PRECISION (scalar_type) < GET_MODE_PRECISION (GET_MODE_INNER (mode)); + if (TREE_CODE (scalar_type) == BITINT_TYPE + && !type_has_mode_precision_p (scalar_type)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "_BitInt loads are not fully supported.\n"); + return false; + } + if (slp_node->ldst_lanes && memory_access_type != VMAT_LOAD_STORE_LANES) {
