Re: [PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

2024-02-28 Thread Kito Cheng
Committed with Palmer's suggestions for the commit message, also I plan to back port that to 11, 12 and 13 release branches :) On Thu, Feb 29, 2024 at 4:27 AM Palmer Dabbelt wrote: > > On Wed, 28 Feb 2024 09:36:38 PST (-0800), Patrick O'Neill wrote: > > > > On 2/28/24 07:02, Palmer Dabbelt wrote:

Re: [PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

2024-02-28 Thread Palmer Dabbelt
On Wed, 28 Feb 2024 09:36:38 PST (-0800), Patrick O'Neill wrote: On 2/28/24 07:02, Palmer Dabbelt wrote: On Wed, 28 Feb 2024 06:57:53 PST (-0800), jeffreya...@gmail.com wrote: On 2/28/24 05:23, Kito Cheng wrote: atomic_compare_and_swapsi will use lr.w and sc.w to do the atomic operation on

Re: [PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

2024-02-28 Thread Patrick O'Neill
On 2/28/24 07:02, Palmer Dabbelt wrote: On Wed, 28 Feb 2024 06:57:53 PST (-0800), jeffreya...@gmail.com wrote: On 2/28/24 05:23, Kito Cheng wrote: atomic_compare_and_swapsi will use lr.w and sc.w to do the atomic operation on RV64, however lr.w is doing sign extend to DI and compare instru

Re: [PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

2024-02-28 Thread Palmer Dabbelt
On Wed, 28 Feb 2024 06:57:53 PST (-0800), jeffreya...@gmail.com wrote: On 2/28/24 05:23, Kito Cheng wrote: atomic_compare_and_swapsi will use lr.w and sc.w to do the atomic operation on RV64, however lr.w is doing sign extend to DI and compare instruction only have DI mode on RV64, so the expe

Re: [PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

2024-02-28 Thread Jeff Law
On 2/28/24 05:23, Kito Cheng wrote: atomic_compare_and_swapsi will use lr.w and sc.w to do the atomic operation on RV64, however lr.w is doing sign extend to DI and compare instruction only have DI mode on RV64, so the expected value should be sign extend before compare as well, so that we can

[PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64

2024-02-28 Thread Kito Cheng
atomic_compare_and_swapsi will use lr.w and sc.w to do the atomic operation on RV64, however lr.w is doing sign extend to DI and compare instruction only have DI mode on RV64, so the expected value should be sign extend before compare as well, so that we can get right compare result. gcc/ChangeLog