From: Chao-ying Fu <[email protected]> Generate proper offset for operands in atomic_compare_and_swap on RISC-V big-endian targets.
Without these changes, inline-atomics-3.c execution test fails for: "-march=rv64imafdb -mabi=lp64d -mbig-endian -minline-atomics -Wno-address-of-packed-member -lm" The patch was tested using QEMU modified to run big-endian RISC-V executables [1]. [1] https://github.com/djtodoro/qemu/tree/riscvbe/current# Signed-off-by: Aleksa Paunovic <[email protected]> gcc/ChangeLog: * config/riscv/sync.md: Calculate proper offset for big-endian. --- gcc/config/riscv/sync.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/sync.md b/gcc/config/riscv/sync.md index 37f15d816595..8ccdbe8fb0ed 100644 --- a/gcc/config/riscv/sync.md +++ b/gcc/config/riscv/sync.md @@ -605,7 +605,8 @@ value is sign-extended. */ rtx tmp0 = gen_reg_rtx (word_mode); emit_insn (gen_extend_insn (tmp0, operands[3], word_mode, <MODE>mode, 0)); - operands[3] = gen_lowpart (<MODE>mode, tmp0); + poly_int64 offset = BYTES_BIG_ENDIAN ? GET_MODE_SIZE (<MODE>mode) : 0; + operands[3] = simplify_gen_subreg (<MODE>mode, tmp0, word_mode, offset); } if (TARGET_ZACAS) -- 2.43.0
