public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/96176] Failure to omit extraneous movzx in atomic compare exchange with unsigned char
Date: Mon, 13 Jul 2020 10:48:05 +0000	[thread overview]
Message-ID: <bug-96176-4-wxrFchJ4YP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96176-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The zero extension is initially there because the builtin has the arguments
promoted.  Normally combine would fix this up:
(insn 10 7 11 2 (set (reg:SI 88 [ new_val ])
        (zero_extend:SI (subreg:QI (reg:SI 93) 0))) "pr96176.c":3:5 143
{*zero_extendqisi2}
     (expr_list:REG_DEAD (reg:SI 93)
        (nil)))
(insn 11 10 0 2 (parallel [
            (set (reg:QI 89)
                (unspec_volatile:QI [
                        (mem/v:QI (reg/v/f:DI 83 [ addr ]) [-1  S1 A8])
                        (reg/v:QI 84 [ old_val ])
                        (subreg:QI (reg:SI 88 [ new_val ]) 0)
                        (const_int 0 [0])
                    ] UNSPECV_CMPXCHG))
            (set (mem/v:QI (reg/v/f:DI 83 [ addr ]) [-1  S1 A8])
                (unspec_volatile:QI [
                        (const_int 0 [0])
                    ] UNSPECV_CMPXCHG))
            (set (reg:CCZ 17 flags)
                (unspec_volatile:CCZ [
                        (const_int 0 [0])
                    ] UNSPECV_CMPXCHG))
        ]) "pr96176.c":3:5 6114 {atomic_compare_and_swapqi_1}
     (expr_list:REG_DEAD (reg:SI 88 [ new_val ])
        (expr_list:REG_DEAD (reg/v:QI 84 [ old_val ])
            (expr_list:REG_DEAD (reg/v/f:DI 83 [ addr ])
                (expr_list:REG_UNUSED (reg:QI 89)
                    (expr_list:REG_UNUSED (reg:CCZ 17 flags)
                        (nil)))))))

but it fails:
Trying 10 -> 11:
   10: r88:SI=zero_extend(r93:SI#0)
      REG_DEAD r93:SI
   11: {r89:QI=unspec/v[[r83:DI],r84:QI,r88:SI#0,0] 90;[r83:DI]=unspec/v[0]
90;flags:CCZ=unspec/v[0] 90;}
      REG_DEAD r88:SI
      REG_DEAD r84:QI
      REG_DEAD r83:DI
      REG_UNUSED r89:QI
      REG_UNUSED flags:CCZ
Failed to match this instruction:
(parallel [
        (set (reg:QI 89)
            (unspec_volatile:QI [
                    (mem/v:QI (reg/v/f:DI 83 [ addr ]) [-1  S1 A8])
                    (reg/v:QI 84 [ old_val ])
                    (subreg:QI (reg:SI 93) 0)
                    (const_int 0 [0])
                ] UNSPECV_CMPXCHG))
        (set (mem/v:QI (reg/v/f:DI 83 [ addr ]) [-1  S1 A8])
            (unspec_volatile:QI [
                    (const_int 0 [0])
                ] UNSPECV_CMPXCHG))
        (set (reg:CCZ 17 flags)
            (unspec_volatile:CCZ [
                    (const_int 0 [0])
                ] UNSPECV_CMPXCHG))
    ])
due to the MEM_VOLATILE_P and volatile_ok not being true during combine.
But we can do something about it during expansion.

  reply	other threads:[~2020-07-13 10:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-12 23:49 [Bug target/96176] New: " gabravier at gmail dot com
2020-07-13 10:48 ` jakub at gcc dot gnu.org [this message]
2020-07-13 10:48 ` [Bug target/96176] " jakub at gcc dot gnu.org
2020-07-15  9:29 ` cvs-commit at gcc dot gnu.org
2020-07-15 10:00 ` jakub at gcc dot gnu.org
2024-01-20 17:16 ` pinskia 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-96176-4-wxrFchJ4YP@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).