From: Andrew Hutchinson <andrewhutchinson@cox.net>
To: GCC Development <gcc@gcc.gnu.org>
Subject: Cannot get Bit test RTL to cooperate with Combine.
Date: Sun, 20 Sep 2009 17:49:00 -0000 [thread overview]
Message-ID: <4AB66B33.9010409@cox.net> (raw)
All,
I have been debugging AVR port to see why we fail to match so many bit
test opportunities.
When dealing with longer modes I have come across a problem I can not solve.
Expansion in RTL for a bit test can produce two styles.
STYLE 1 Bit to be tested is NOT LSB (e.g. if ( longthing & 0x10)), the
expanded code contains the test as:
(and:SI (reg:SI 45 [ lx.1 ])
(const_int 16 [0x10]))
Bit tests are matched by combine. Combine has no problems with this and
eventually creates a matching pattern based on the conversion of the AND
to a zero extraction
(set (pc)
(if_then_else (ne (zero_extract:SI (subreg:QI (reg:SI 45 [ lx.1 ]) 0)
(const_int 1 [0x1])
(const_int 4 [0x4]))
(const_int 0 [0x0]))
(label_ref:HI 133)
(pc)))
This will match Bit test patterns and produces optimal code. :-)
STYLE 2 Bit to be tested is LSB (e.g. if ( longthing & 1)), the expanded
RTL code uses SUBREG to lower width (apparently from SImode to word size).
(and:HI (subreg:HI (reg:SI 45 [ lx.1 ]) 0)
(const_int 1 [0x1]))
This seems to occur regardless of -f(no)split-wide-types for size >
HImode (which is integer mode). This RTL becomes a problem for combine
Combine uses subst(), combine_simplify_rtx() and eventually
simplify_comparison() where it attempts to WIDEN the AND and take the
lowpart.
ge_low_part(HImode,
(and:SI (reg:SI 45 [ lx.1 ])
(const_int 1 [0x1]))
)
However, gen_lowpart_for_combine() FAILS as it will reject taking
lowpart of SImode expression because size>UNITS_PER_WORD.
So no test pattern can be matched. :-(
Style 2 is hugely problematic. The substitution works fine, but the
simplification will always fail - making it apparently impossible to
create matching patterns for bit tests of the LSB of SImode or DImode
values.
Any clues how I might get around this?
Andy
next reply other threads:[~2009-09-20 17:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-20 17:49 Andrew Hutchinson [this message]
2009-09-22 0:49 ` Joern Rennecke
2009-09-22 1:20 ` Andrew Hutchinson
2009-09-22 1:43 ` Andrew Hutchinson
2009-09-22 6:57 ` Joern Rennecke
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=4AB66B33.9010409@cox.net \
--to=andrewhutchinson@cox.net \
--cc=gcc@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).