]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Fix program logic errors caused by data truncation on 32-bit host for zbs...
authorJin Ma <jinma@linux.alibaba.com>
Mon, 13 Jan 2025 17:10:22 +0000 (10:10 -0700)
committerJeff Law <jlaw@ventanamicro.com>
Mon, 13 Jan 2025 17:10:22 +0000 (10:10 -0700)
commitecf688edc217472774817cc1284e75a9f72fe1b4
tree0e7f507b784424eeca6f291508e338c776969368
parent655a8a024dd49ddf73e745f3c7486596d68ae3e8
RISC-V: Fix program logic errors caused by data truncation on 32-bit host for zbs, such as i386

Correct logic on 64-bit host:
        ...
        bseti   a5,zero,38
        bseti   a5,a5,63
        addi    a5,a5,-1
        and     a4,a4,a5
...

Wrong logic on 32-bit host:
...
        li      a5,64
        bseti   a5,a5,31
        addi    a5,a5,-1
        and     a4,a4,a5
...

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_build_integer_1): Change
1UL/1ULL to HOST_WIDE_INT_1U.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbs-bug.c: New test.
gcc/config/riscv/riscv.cc
gcc/testsuite/gcc.target/riscv/zbs-bug.c [new file with mode: 0644]