public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hjl.tools at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/103069] cmpxchg isn't optimized
Date: Mon, 24 Jan 2022 23:49:39 +0000	[thread overview]
Message-ID: <bug-103069-4-eTZjL9J5Dh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103069-4@http.gcc.gnu.org/bugzilla/>

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
     Ever confirmed|0                           |1
         Resolution|FIXED                       |---
   Last reconfirmed|                            |2022-01-24

--- Comment #6 from H.J. Lu <hjl.tools at gmail dot com> ---
nptl/pthread_rwlock_common.c in glibc has:

  unsigned int r = atomic_load_relaxed (&rwlock->__data.__readers);
  /* Release MO so that subsequent readers or writers synchronize with us.  */
  while (!atomic_compare_exchange_weak_release
         (&rwlock->__data.__readers, &r,
          ((r ^ PTHREAD_RWLOCK_WRLOCKED)
           ^ ((r >> PTHREAD_RWLOCK_READER_SHIFT) == 0 ? 0
              : PTHREAD_RWLOCK_WRPHASE))))
    {
      /* TODO Back-off.  */
    }   

-mrelax-cmpxchg-loop -O2 generates:

         9240e: 89 c1                   mov    %eax,%ecx
         92410: 31 d2                   xor    %edx,%edx
         92412: c1 e9 03                shr    $0x3,%ecx
         92415: 0f 95 c2                setne  %dl
         92418: 31 c2                   xor    %eax,%edx
         9241a: 83 f2 02                xor    $0x2,%edx
         9241d: f0 41 0f b1 10          lock cmpxchg %edx,(%r8)       
         92422: 75 ea                   jne    9240e
<__pthread_rwlock_unlock@GL
IBC_2.2.5+0x10e>

  parent reply	other threads:[~2022-01-24 23:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 19:08 [Bug target/103069] New: " hjl.tools at gmail dot com
2021-11-03 20:53 ` [Bug target/103069] " thiago at kde dot org
2021-11-04 21:25 ` thiago at kde dot org
2021-11-15 11:10 ` cvs-commit at gcc dot gnu.org
2021-11-15 14:26 ` hjl.tools at gmail dot com
2021-11-18  8:31 ` cvs-commit at gcc dot gnu.org
2022-01-24 23:49 ` hjl.tools at gmail dot com [this message]
2022-01-24 23:52 ` hjl.tools at gmail dot com
2022-01-24 23:53 ` hjl.tools at gmail dot com
2022-01-24 23:55 ` hjl.tools at gmail dot com
2022-01-25  0:04 ` thiago at kde dot org
2022-02-15  8:59 ` wwwhhhyyy333 at gmail dot com
2022-02-22  3:36 ` cvs-commit at gcc dot gnu.org
2022-02-22  3:38 ` wwwhhhyyy333 at gmail dot com
2022-02-22  4:16 ` thiago at kde dot org
2022-02-22  8:21 ` wwwhhhyyy333 at gmail dot com
2022-02-22 18:05 ` thiago at kde dot org
2022-02-22 18:41 ` jakub at gcc dot gnu.org
2022-02-22 20:25 ` thiago at kde dot org
2022-02-23  3:35 ` wwwhhhyyy333 at gmail dot com
2022-02-23  4:06 ` thiago at kde dot org
2022-04-13  8:18 ` cvs-commit at gcc dot gnu.org
2022-05-06  8:31 ` jakub at gcc dot gnu.org
2023-05-08 12:23 ` rguenth at gcc dot gnu.org

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-103069-4-eTZjL9J5Dh@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).