public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/105136] [11/12 regression] Missed optimization regression with 32-bit adds and shifts
Date: Mon, 04 Apr 2022 08:53:44 +0000	[thread overview]
Message-ID: <bug-105136-4-GPHVlmWmVd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105136-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Uroš Bizjak <ubizjak at gmail dot com> ---
The regression in bar: is due to RA regression for:

(insn 28 27 29 2 (parallel [
            (set (reg:SI 89)
                (plus:SI (reg:SI 92)
                    (subreg:SI (reg:DI 87) 0)))
            (clobber (reg:CC 17 flags))
        ]) "pr105136.c":4:11 229 {*addsi_1}
     (expr_list:REG_DEAD (reg:SI 92)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))

gcc-10.3 allocates:

(insn 28 27 29 2 (parallel [
            (set (reg:SI 0 ax [89])
                (plus:SI (reg:SI 4 si [92])
                    (reg:SI 5 di [87])))
            (clobber (reg:CC 17 flags))
        ]) "pr105136.c":4:11 185 {*addsi_1}
     (nil))

while gcc-12 allocates:

(insn 28 27 29 2 (parallel [
            (set (reg:SI 4 si [89])
                (plus:SI (reg:SI 4 si [92])
                    (reg:SI 5 di [87])))
            (clobber (reg:CC 17 flags))
        ]) "pr105136.c":4:11 229 {*addsi_1}
     (nil))

(...)

and reloads the output to ax:

(insn 35 29 30 2 (set (reg:SI 0 ax [89])
        (reg:SI 4 si [89])) "pr105136.c":4:11 81 {*movsi_internal}
     (nil))
(insn 30 35 20 2 (set (reg:SI 0 ax [89])
        (if_then_else:SI (eq (reg:CCZ 17 flags)
                (const_int 0 [0]))
            (reg:SI 5 di [87])
            (reg:SI 0 ax [89]))) "pr105136.c":4:11 1201 {*movsicc_noc}
     (nil))

The pattern allows r/r/r in alternative 3, so the question is why RA doesn't
consider it:

(define_insn "*add<mode>_1"
  [(set (match_operand:SWI48 0 "nonimmediate_operand" "=rm,r,r,r")
        (plus:SWI48
          (match_operand:SWI48 1 "nonimmediate_operand" "%0,0,r,r")
          (match_operand:SWI48 2 "x86_64_general_operand" "re,BM,0,le")))
   (clobber (reg:CC FLAGS_REG))]

The "l" constraint is user defined register constraint:

(define_register_constraint "l" "INDEX_REGS"
 "@internal Any register that can be used as the index in a base+index
  memory access: that is, any general register except the stack pointer.")

so perhaps user defined constraint deters RA from using this alternative.

  parent reply	other threads:[~2022-04-04  8:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-02 13:55 [Bug middle-end/105136] New: [11/12] " andre.schackier at gmail dot com
2022-04-04  7:19 ` [Bug target/105136] [11/12 regression] " rguenth at gcc dot gnu.org
2022-04-04  8:53 ` ubizjak at gmail dot com [this message]
2022-04-19 18:08 ` jakub at gcc dot gnu.org
2022-04-20 15:48 ` vmakarov at gcc dot gnu.org
2022-04-21  7:51 ` rguenth at gcc dot gnu.org
2023-05-29 10:06 ` [Bug target/105136] [11/12/13/14 " jakub 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-105136-4-GPHVlmWmVd@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).