]> git.ipfire.org Git - thirdparty/gcc.git/commit
RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64
authorKito Cheng <kito.cheng@sifive.com>
Wed, 28 Feb 2024 08:01:52 +0000 (16:01 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Thu, 11 Apr 2024 01:20:58 +0000 (09:20 +0800)
commitfb6ec6df54317ed3f6e6f878b6ea29dbef6bfe2d
tree3267a0658ed8f6c10a38b3e236ac8226449a01b8
parente269c5e4d04a94ed0bfce800072b550c3246abbc
RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

atomic_compare_and_swapsi will use lr.w to do obtain the original value,
which sign extends to DI.  RV64 only has DI comparisons, so we also need
to sign extend the expected value to DI as otherwise the comparison will
fail when the expected value has the 32nd bit set.

gcc/ChangeLog:

PR target/114130
* config/riscv/sync.md (atomic_compare_and_swap<mode>): Sign
extend the expected value if needed.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr114130.c: New.

Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
(cherry picked from commit fd07a29e39f5347d6cef3e7042a32306f97a1719)
gcc/config/riscv/sync.md
gcc/testsuite/gcc.target/riscv/pr114130.c [new file with mode: 0644]