public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Patrick O'Neill <patrick@rivosinc.com>, gcc-patches@gcc.gnu.org
Cc: palmer@rivosinc.com, kito.cheng@gmail.com, david.abd@gmail.com
Subject: Re: [PATCH v5] RISCV: Inline subword atomic ops
Date: Tue, 18 Apr 2023 15:04:22 -0600	[thread overview]
Message-ID: <f965671f-5997-0220-8831-a94e8c68d060@gmail.com> (raw)
In-Reply-To: <c8ee3d1b-d511-8d12-6be2-39cfa44c7649@rivosinc.com>



On 4/18/23 14:48, Patrick O'Neill wrote:
> On 4/18/23 09:59, Jeff Law wrote:
>> On 4/18/23 08:28, Patrick O'Neill wrote:
>> ...
>>> +  rtx addr = force_reg (Pmode, XEXP (mem, 0));
>>> +
>>> +  rtx aligned_addr = gen_reg_rtx (Pmode);
>>> +  emit_move_insn (aligned_addr,  gen_rtx_AND (Pmode, addr,
>>> +                          gen_int_mode (-4, Pmode)));
>> So rather than -4 as a magic number, GET_MODE_MASK would be better. 
>> That may result in needing to rewrap this code.  I'd bring the 
>> gen_rtx_AND down on a new line, aligned with aligned_addr.
> IIUC GET_MODE_MASK generates masks like 0xFF for QI (for example). It 
> doesn't have the granularity to generate 0x3 (which we can NOT to get 
> -4). I searched the GCC internals docs but couldn't find a function that 
> does address alignment masks.
Yea, yea.  Big "duh" on my side.

>> Presumably using SImode is intentional here rather than wanting to use 
>> word_mode which would be SImode for rv32 and DImode for rv64?  I'm 
>> going to work based on that assumption, but if it isn't there's more 
>> work to do to generalize this code.
> It's been a year but IIRC it was just simpler to implement (and to me it 
> didn't make sense to use 64 bits for a subword op).
> Is there a benefit in using 64 bit instructions when computing subwords?
Given that rv64 should have 32bit load/stores, I don't offhand see any 
advantage.


>>> +
>>> +(define_expand "atomic_fetch_nand<mode>"
>>> +  [(set (match_operand:SHORT 0 "register_operand" "=&r")
>>> +    (match_operand:SHORT 1 "memory_operand" "+A"))
>>> +   (set (match_dup 1)
>>> +    (unspec_volatile:SHORT
>>> +      [(not:SHORT (and:SHORT (match_dup 1)
>>> +                 (match_operand:SHORT 2 "reg_or_0_operand" "rJ")))
>>> +       (match_operand:SI 3 "const_int_operand")] ;; model
>>> +     UNSPEC_SYNC_OLD_OP_SUBWORD))]
>>> +  "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC"
>> Just a note, constraints aren't necessary for a define_expand. They 
>> don't hurt anything though.  They do document expectations, but then 
>> you have to maintain them over time.  I'm OK leaving them, mostly 
>> wanted to make sure you're aware they aren't strictly necessary for a 
>> define_expand.
> I wasn't aware, thanks for pointing it out! - you're referring to the 
> "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC", (not the register 
> constraints) right?
I was referring to the register constraints like "=&r".  They're ignored 
on define_expand constructors.  A define_expand generates RTL that will 
be matched later by a define_insn.

The "TARGET_ATOMIC && TARGET_INLINE_SUBWORD_ATOMIC" is usually referred 
to as the insn condition.


> Thanks for reviewing!
NP.  Looking forward to V6 which I expect will be ready for inclusion.

jeff

      reply	other threads:[~2023-04-18 21:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-21 21:58 [PATCH v4] RISC-V: Add support for inlining subword atomic operations Palmer Dabbelt
2022-09-02 10:08 ` Kito Cheng
2022-10-28 16:55   ` David Abdurachmanov
2022-11-16  3:53     ` Jeff Law
2023-04-18 14:28 ` [PATCH v5] RISCV: Inline subword atomic ops Patrick O'Neill
2023-04-18 15:06   ` Andreas Schwab
2023-04-18 16:39   ` [PATCH v6] " Patrick O'Neill
2023-04-18 20:17     ` Palmer Dabbelt
2023-04-18 21:41     ` [PATCH v7] " Patrick O'Neill
2023-04-24 17:20       ` Patrick O'Neill
2023-04-25  5:52       ` Jeff Law
2023-04-25 15:20         ` Patrick O'Neill
2023-04-26  2:27           ` Jeff Law
2023-04-26 17:01             ` [committed] " Patrick O'Neill
2023-05-02 20:34               ` Patrick O'Neill
2023-05-03  6:32                 ` Jeff Law
2023-05-03  9:49                   ` Richard Biener
2023-05-03 14:14                     ` Palmer Dabbelt
2023-05-03 15:13                       ` Jeff Law
2023-05-03 15:33                         ` Palmer Dabbelt
2023-05-03 16:13                           ` Patrick O'Neill
2023-04-18 16:59   ` [PATCH v5] " Jeff Law
2023-04-18 20:48     ` Patrick O'Neill
2023-04-18 21:04       ` Jeff Law [this message]

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=f965671f-5997-0220-8831-a94e8c68d060@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=david.abd@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@rivosinc.com \
    --cc=patrick@rivosinc.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).