[Bug target/123117] LoongArch: wrong code at -O1/O2/O3

xry111 at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Dec 15 03:49:41 GMT 2025


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123117

--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Reduced further and removed some obvious undefined behavior:

#include <stdio.h>
#include <lsxintrin.h>

#define BS_VEC(type, num) type __attribute__((vector_size(num * sizeof(type))))

int main ()
{
  BS_VEC(long int, 2) BS_VAR_0[1] = {};
  BS_VEC (unsigned int, 4) tt = (BS_VEC(unsigned int, 4))
    __lsx_vadd_w((__m128i){0x9e47d3d2, 0}, (__m128i){});
  BS_VEC(unsigned int, 2) SHUF =
    __builtin_shufflevector(tt, (BS_VEC(unsigned int, 4)){}, 0, 1);
  BS_VAR_0[0] = __builtin_convertvector(SHUF, BS_VEC(long int, 2));
  printf("0x%016lx\n", BS_VAR_0[0][0]);
}

Reproducible on r16-6111.


More information about the Gcc-bugs mailing list