Re: [PATCH] riscv/futex: sign extend compare value in atomic cmpxchg

Andreas Schwab
2025-02-04T08:28:21Z

On Feb 03 2025, Jessica Clarke wrote:

> On 3 Feb 2025, at 10:06, Andreas Schwab <schwab@suse.de> wrote:
>>
>> Make sure the compare value in the lr/sc loop is sign extended to match
>> what lr.w does. Fortunately, due to the compiler keeping the register
>> contents sign extended anyway the lack of the explicit extension didn't
>> result in wrong code so far, but this cannot be relied upon.
>
> GCC may guarantee this today,

It doesn't, that's the point!

--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."