From: Patrick O'Neill <patrick@rivosinc.com>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: kito.cheng@sifive.com, gcc-patches@gcc.gnu.org,
Kito Cheng <kito.cheng@gmail.com>,
pinskia@gmail.com, jeffreyalaw@gmail.com
Subject: Re: [PATCH] RISC-V: Fix __atomic_compare_exchange with 32 bit value on RV64
Date: Wed, 28 Feb 2024 09:36:38 -0800 [thread overview]
Message-ID: <0b01fcf9-8754-46af-b429-cf79442b0cf8@rivosinc.com> (raw)
In-Reply-To: <mhng-556d886b-b8b0-4cee-b07d-ef087fdca52b@palmer-ri-x1c9>
On 2/28/24 07:02, Palmer Dabbelt wrote:
> On Wed, 28 Feb 2024 06:57:53 PST (-0800), jeffreyalaw@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 expected value should be sign extend before
>>> compare as
>>> well, so that we can get right compare result.
>>>
>>> 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.
>> Nearly rejected this as I think the description was a bit ambiguous and
>> I thought you were extending the result of the lr.w. But it's actually
>> the other value you're ensuring gets properly extended.
>
> I had the same response, but after reading it I'm not quite sure how
> to say it better.
>
>> OK.
>
> I was looking at the code to try and ask if we have the same bug for
> the short inline CAS routines, but I've got to run to some meetings...
I don't think subword AMO CAS is impacted.
As part of the CAS we mask both the expected value [2] and the retrieved
value[1] before comparing.
- Patrick
[1]:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/riscv/sync.md;h=54bb0a66518ae353fa4ed640339213bf5da6682c;hb=refs/heads/master#l495
[2]:
https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/config/riscv/sync.md;h=54bb0a66518ae353fa4ed640339213bf5da6682c;hb=refs/heads/master#l459
>
>>
>> Jeff
next prev parent reply other threads:[~2024-02-28 17:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 12:23 Kito Cheng
2024-02-28 14:57 ` Jeff Law
2024-02-28 15:02 ` Palmer Dabbelt
2024-02-28 17:36 ` Patrick O'Neill [this message]
2024-02-28 20:27 ` Palmer Dabbelt
2024-02-29 3:07 ` Kito Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0b01fcf9-8754-46af-b429-cf79442b0cf8@rivosinc.com \
--to=patrick@rivosinc.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=kito.cheng@gmail.com \
--cc=kito.cheng@sifive.com \
--cc=palmer@dabbelt.com \
--cc=pinskia@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).