[Bug target/126411] New: RISC-V rv64gcv: wrong code at -O0 with simple shuffle

xxs_chy at outlook dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126411

            Bug ID: 126411
           Summary: RISC-V rv64gcv: wrong code at -O0 with simple shuffle
           Product: gcc
           Version: 17.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 int8_t v4i8 __attribute__((vector_size(4)));
v4i8 g2 = { 7, 0, 8, 70 }, g12;
int main()
{
    g12 = __builtin_shufflevector(g2, g2, 7, 0, 7, 0);
    uint64_t __chk = g12[2];
    printf("checksum=0x%016llx\n", (unsigned long long)__chk);
}

commands:
> $GCC_RISCV64 -march=rv64gcv -O0 -static reduced.c && qemu-riscv64 a.out
> checksum=0x0000000000000000


> $GCC_RISCV64 -march=rv64gcv -O1 -static reduced.c && qemu-riscv64 a.out
> checksum=0x0000000000000046

gcc version 17.0.0 20260725 (experimental) (GCC)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.