public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "gjl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/109907] Missed optimization for bit extraction (uses shift instead of single bit-test)
Date: Sun, 21 May 2023 09:55:37 +0000 [thread overview]
Message-ID: <bug-109907-4-JCM20W5DUE@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109907-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109907
--- Comment #18 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #16)
> But that still fails because combine really does not like subregs:
> [...]
> Failed to match this instruction:
> (set (reg/i:QI 24 r24)
> (subreg:QI (lshiftrt:SI (reg:SI 48)
> (const_int 31 [0x1f])) 0))
Eons ago I solved the canonicalization problem during combine as follow:
Prior to recog_for_combine, there was a target hook that could canonicalize
combined rtx's to a canonical form. This was achieved by means of special
split patterns (wrapped in some unspec_canonicalize and insn condition). If
there was a match, combine would proceed with the canonicalized form.
IMO, trying to target-independent canonicalize in combine itself just works to
some degree, because combine is well in target-specigic land, and targets are
very different.
;; Combine's "smart" method to extract the MSB.
(define_insn_and_split "*extzv.neg.subreg-msb.<mode>"
[(set (match_operand:QI 0 "register_operand" "=r")
(neg:QI (subreg:QI
(ashiftrt:HISI (match_operand:HISI 1 "register_operand" "r")
(match_operand:QI 2 "const<MSB>_operand" "n"))
0)))]
""
"#"
"&& reload_completed"
[; "*extzv"
(parallel [(set (match_dup 0)
(zero_extract:QI (match_dup 1)
(const_int 1)
(match_dup 2)))
(clobber (reg:CC REG_CC))])]
{
...;
})
Such patterns work, bit the problem is that you are pushing combine away from a
(target-)canonical form.
Next best match would be a pre-reload matching split. If that works, it might
be superior to a post-reload split, but it happens at split1 which runs after
reload.
The closest match to canonicalization are the non-matching splits that will run
during combine. The problem with these is that such splits must have very
special for (like split 1 pattern into exactly 2, additional restrictios
apply), and in many cases non-matching splits will fail or are not possible.
Such a target-specific canonicalization would push combine towards a
target-canonical form, instead of encouraging it to go further astray and try
even more crazy, none-canonical combinations.
next prev parent reply other threads:[~2023-05-21 9:55 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 10:10 [Bug middle-end/109907] New: [avr] " gjl at gcc dot gnu.org
2023-05-19 14:14 ` [Bug middle-end/109907] " pinskia at gcc dot gnu.org
2023-05-19 15:42 ` [Bug middle-end/109907] " pinskia at gcc dot gnu.org
2023-05-19 15:45 ` pinskia at gcc dot gnu.org
2023-05-19 20:03 ` pinskia at gcc dot gnu.org
2023-05-19 20:12 ` pinskia at gcc dot gnu.org
2023-05-19 20:41 ` gjl at gcc dot gnu.org
2023-05-19 20:55 ` pinskia at gcc dot gnu.org
2023-05-19 20:59 ` gjl at gcc dot gnu.org
2023-05-20 0:46 ` pinskia at gcc dot gnu.org
2023-05-20 5:09 ` pinskia at gcc dot gnu.org
2023-05-20 7:36 ` gjl at gcc dot gnu.org
2023-05-20 7:50 ` gjl at gcc dot gnu.org
2023-05-20 22:23 ` pinskia at gcc dot gnu.org
2023-05-20 22:40 ` pinskia at gcc dot gnu.org
2023-05-21 5:15 ` pinskia at gcc dot gnu.org
2023-05-21 5:36 ` pinskia at gcc dot gnu.org
2023-05-21 9:09 ` gjl at gcc dot gnu.org
2023-05-21 9:55 ` gjl at gcc dot gnu.org [this message]
2023-05-23 9:58 ` gjl at gcc dot gnu.org
2023-05-26 8:49 ` gjl at gcc dot gnu.org
2023-05-26 11:14 ` gjl at gcc dot gnu.org
2023-05-26 15:21 ` pinskia at gcc dot gnu.org
2023-05-26 16:08 ` gjl at gcc dot gnu.org
2023-05-26 23:11 ` pinskia at gcc dot gnu.org
2023-05-26 23:34 ` pinskia at gcc dot gnu.org
2023-05-26 23:49 ` pinskia at gcc dot gnu.org
2023-05-27 0:36 ` pinskia at gcc dot gnu.org
2023-05-27 4:02 ` pinskia at gcc dot gnu.org
2023-05-27 20:09 ` pinskia at gcc dot gnu.org
2023-06-11 9:22 ` cvs-commit at gcc dot gnu.org
2023-06-11 9:26 ` gjl 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-109907-4-JCM20W5DUE@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).