On Tue, Sep 15, 2026 at 02:59:53PM +0200, Richard Biener wrote:
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/vect-bitint-1.c
> @@ -0,0 +1,36 @@
> +#include <stdint.h>
> +#include "tree-vect.h"
Again, needs bitint effective target.
> +#pragma GCC novector
> + for (int i = 0; i < 32; ++i)
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> + *((char *)&b[i] + 3) = 0x80;
> +#else
> + ;
I think it would be cleaner to do what I did in gcc.dg/bitint-142.c
testcase,
z = ~0;
__builtin_clear_padding (&z);
for (unsigned i = 0; i < 16; ++i)
((unsigned char *) &x[0])[i] |= ~*(unsigned char *) &z;
there. The first stmt sets z to all ones, the second one clears
all padding bits. So, accessing it now through unsigned char (note,
in bitint-142.c it was _BitInt(7) and so fit into one byte, for
arbitrary bitints you'd need to add a nested loop to go from
0 to sizeof (_BitInt(N)) - 1 and update from the ~((unsigned char *) &z)[j]
bytes. Anyway, in z the value bits will be 1s and padding bits will be 0s,
so with ~ the other way around and so this sets all the padding bits to 1.
> --- a/gcc/tree-vect-stmts.cc
> +++ b/gcc/tree-vect-stmts.cc
> @@ -5413,6 +5413,17 @@ vectorizable_conversion (vec_info *vinfo,
> "type conversion to bit-precision unsupported\n");
> return false;
> }
> + /* _BitInt values are not sign-/zero-extended to mode precision. */
> + if (!VECTOR_BOOLEAN_TYPE_P (vectype_out)
> + && TREE_CODE (rhs_type) == BITINT_TYPE
> + && !type_has_mode_precision_p (rhs_type))
> + {
If you'd want to go further and make it target dependent, you can also
struct bitint_info info;
bool ok = targetm.c.bitint_type_info (TYPE_PRECISION (rhs_type), &info);
gcc_assert (ok);
if (info.extended != bitint_ext_full)
When it is bitint_ext_full (arm, riscv, s390x), all the bits are already
extended.
> + if (dump_enabled_p ())
> + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> + "type conversion from _BitInt unsupported\n");
> + return false;
> + }
> +
Jakub