public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/107713] Wrong implementation atomic_exchange<short> on LoongArch
Date: Fri, 18 Nov 2022 07:05:20 +0000	[thread overview]
Message-ID: <bug-107713-4-QPsIQp3cjF@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107713-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107713

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by LuluCheng <chenglulu@gcc.gnu.org>:

https://gcc.gnu.org/g:f0024bfb228f94e60e06dc32a4983e40a9b90be5

commit r13-4136-gf0024bfb228f94e60e06dc32a4983e40a9b90be5
Author: Jinyang He <hejinyang@loongson.cn>
Date:   Thu Nov 17 14:38:52 2022 +0800

    LoongArch: Fix atomic_exchange expanding [PR107713]

    We used to expand atomic_exchange_n(ptr, new, mem_order) for subword types
    into something like:

        {
          __typeof__(*ptr) t = atomic_load_n(ptr, mem_order);
          atomic_compare_exchange_n(ptr, &t, new, true, mem_order, mem_order);
          return t;
        }

    It's incorrect because another thread may store a different value into *ptr
    after atomic_load_n.  Then atomic_compare_exchange_n will not store into
    *ptr, but atomic_exchange_n should always perform the store.

    gcc/ChangeLog:

            PR target/107713
            * config/loongarch/sync.md
            (atomic_cas_value_exchange_7_<mode>): New define_insn.
            (atomic_exchange): Use atomic_cas_value_exchange_7_si instead of
            atomic_cas_value_cmp_and_7_si.

    gcc/testsuite/ChangeLog:

            PR target/107713
            * gcc.target/loongarch/pr107713-1.c: New test.
            * gcc.target/loongarch/pr107713-2.c: New test.

  parent reply	other threads:[~2022-11-18  7:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16  3:07 [Bug target/107713] New: " hejinyang at loongson dot cn
2022-11-16  7:14 ` [Bug target/107713] " hejinyang at loongson dot cn
2022-11-16 11:27 ` xry111 at gcc dot gnu.org
2022-11-16 11:31 ` xry111 at gcc dot gnu.org
2022-11-16 11:48 ` xry111 at gcc dot gnu.org
2022-11-18  7:05 ` cvs-commit at gcc dot gnu.org [this message]
2022-11-18  9:01 ` xry111 at gcc dot gnu.org
2022-11-18  9:13 ` chenglulu at loongson dot cn
2022-11-19 12:37 ` cvs-commit at gcc dot gnu.org
2022-11-19 12:38 ` xry111 at gcc dot gnu.org
2022-11-19 12:39 ` xry111 at gcc dot gnu.org
2022-11-20  3:56 ` chenglulu at loongson dot cn

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=bug-107713-4-QPsIQp3cjF@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).