https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119103
--- Comment #16 from Niklas Haas <gcc at haasn dot dev> --- (In reply to Alexander Monakov from comment #15) > (In reply to Niklas Haas from comment #12) > > Out of curiosity, is there a work-around that I could use to get current > > versions of GCC to compile the right thing, but without breaking > > cross-platform compatibility? > > > > I did try replacing the assertion by "x[i] << (amount & 0xF)" but the vector > > version of the code at least still compiles down to vpslld. > > This quote seems apropos: "autovectorization is not a programming model". This is true, but if I need to write portable C code I have no choice but to rely on auto-vectorization, unless I want to pepper my code with `#ifdef __GNUC__` and provide multiple implementations for everything. > > Not sure if you know that already, but with generic vectors you can write: > > typedef uint16_t u16v16 __attribute__((vector_size(32))); > typedef u16v16 u16v16_u __attribute__((aligned(2))); > > void lshift_register(u16v16_u *x, uint8_t amount) > { > *x <<= amount; > } Thanks, I'll use that as a GCC-specific work-around for now in this particular case.