https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121906
Bug ID: 121906 Summary: [Trunk] Loongarch64: miscompile at -O2 Product: gcc Version: 16.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: xxs_chy at outlook dot com Target Milestone: --- Testcase: #include <stdint.h> #include <stdio.h> typedef uint16_t a; typedef uint64_t uint64; typedef a b __attribute__((vector_size(8))); typedef a c __attribute__((vector_size(16))); uint64 d[10]; int32_t e, s, r, i, g; int32_t f[6][3][8]; c m; uint32_t j(uint16_t, int32_t *, uint32_t, int32_t, uint16_t); int32_t k() { int32_t *l; j(f[3][2][6], l, 0, g, 0); } uint32_t j(uint16_t, int32_t *, uint32_t, int32_t, uint16_t) { b n = {1}; uint64 *o = &d[2]; p: asm goto("" : : : : q); n[3] = (-(c){ 0, 0, 0, 0, m[7]})[~(__attribute__((__vector_size__(sizeof(uint64)))) uint64){}[0] < 8 ?: 7]; for (; e >= 0; e--) { *o = n[0]; for (; i;) goto p; q: } } int main() { k(); printf("0x%016llx\n", d[2]); } Commands: > loongarch64-unknown-linux-gnu-gcc -static -O2 reduced.c && qemu-loongarch64 > 0x0000000000000000 > loongarch64-unknown-linux-gnu-gcc -static -O0/O1/O3 reduced.c && > qemu-loongarch64 > 0x0000000000000001