riscv: add mising masking in lrsc expander (PR118137)
Checks
Context |
Check |
Description |
rivoscibot/toolchain-ci-rivos-lint |
success
|
Lint passed
|
rivoscibot/toolchain-ci-rivos-apply-patch |
success
|
Patch applied
|
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-test |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 |
fail
|
Patch failed to apply
|
linaro-tcwg-bot/tcwg_gcc_check--master-arm |
fail
|
Patch failed to apply
|
Commit Message
gcc:
PR target/118137
* config/riscv/sync.md ("lrsc_atomic_exchange<mode>"): Apply mask
to shifted value.
gcc/testsuite:
PR target/118137
* gcc.dg/atomic/pr118137.c: New.
---
gcc/config/riscv/sync.md | 1 +
gcc/testsuite/gcc.dg/atomic/pr118137.c | 29 ++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/atomic/pr118137.c
Comments
On 1/7/25 07:37, Andreas Schwab wrote:
> gcc:
> PR target/118137
> * config/riscv/sync.md ("lrsc_atomic_exchange<mode>"): Apply mask
> to shifted value.
>
> gcc/testsuite:
> PR target/118137
> * gcc.dg/atomic/pr118137.c: New.
> ---
Thanks for fixing this - I can't give approvals but LGTM FWIW.
LGTM
Patrick O'Neill <patrick@rivosinc.com> 於 2025年1月8日 週三 00:12 寫道:
>
> On 1/7/25 07:37, Andreas Schwab wrote:
> > gcc:
> > PR target/118137
> > * config/riscv/sync.md ("lrsc_atomic_exchange<mode>"): Apply mask
> > to shifted value.
> >
> > gcc/testsuite:
> > PR target/118137
> > * gcc.dg/atomic/pr118137.c: New.
> > ---
> Thanks for fixing this - I can't give approvals but LGTM FWIW.
>
On 1/7/25 8:37 AM, Andreas Schwab wrote:
> gcc:
> PR target/118137
> * config/riscv/sync.md ("lrsc_atomic_exchange<mode>"): Apply mask
> to shifted value.
>
> gcc/testsuite:
> PR target/118137
> * gcc.dg/atomic/pr118137.c: New.
Thanks. I went ahead and pushed this to the trunk.
jeff
Please fix your git to strip the subject prefix.
@@ -467,6 +467,7 @@
rtx shifted_value = gen_reg_rtx (SImode);
riscv_lshift_subword (<MODE>mode, value, shift, &shifted_value);
+ emit_move_insn (shifted_value, gen_rtx_AND (SImode, shifted_value, mask));
emit_insn (gen_subword_atomic_exchange_strong (old, aligned_mem,
shifted_value, model,
new file mode 100644
@@ -0,0 +1,29 @@
+/* Test that subword atomic operations only affect the subword. */
+/* { dg-do run } */
+/* { dg-require-effective-target sync_char_short } */
+
+void
+foo (char *x)
+{
+ __sync_fetch_and_or (x, 0xff);
+}
+
+void
+bar (short *y)
+{
+ __atomic_fetch_or (y, 0xffff, 0);
+}
+
+
+int
+main ()
+{
+ char b[4] = {};
+ foo(b);
+
+ short h[2] = {};
+ bar(h);
+
+ if (b[1] || b[2] || b[3] || h[1])
+ __builtin_abort();
+}