public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/53976] [SH] Unnecessary clrt after bt
Date: Sat, 03 Aug 2013 08:08:00 -0000 [thread overview]
Message-ID: <bug-53976-4-M2YrRcAFFI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53976-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53976
--- Comment #3 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Oleg Endo from comment #2)
> Interestingly, the following function shows some improved behavior (notice
> the removed volatile mem store):
>
> int test_2_1 (int* a, int b, int c)
> {
> a[1] = b != 0;
>
> if (b == 0)
> a[10] = c;
>
> return b == 0;
> }
>
> -O2 -m2a:
> tst r5,r5
> movrt r1
> mov.l r1,@(4,r4)
> bf .L4
> mov.l r6,@(40,r4)
> .L4:
> rts
> movt r0
>
>
> This is already minimal.
> However, for non-SH2A it's still the same:
> tst r5,r5
> mov #-1,r1
> negc r1,r1
> tst r5,r5
> bf/s .L4
> mov.l r1,@(4,r4)
> mov.l r6,@(40,r4)
> tst r5,r5
> .L4:
> rts
> movt r0
One of the problems in this case is that negc clobbers the T bit. Another
alternative
movt r0
xor #1,r0
should be selected here. This could be done by looking at the insns around the
negc-movrt and check whether some insn after negc-movrt sets the T bit in the
same way as it was set before the negc-movrt. In this case not clobbering the
T bit would eliminate the redundant test. However, if this pattern occurs in a
loop or pressure on R0 is high, using negc and the redundant test is probably
going to be better.
next prev parent reply other threads:[~2013-08-03 8:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-15 20:43 [Bug target/53976] New: " olegendo at gcc dot gnu.org
2012-09-23 20:50 ` [Bug target/53976] " olegendo at gcc dot gnu.org
2012-09-23 21:27 ` olegendo at gcc dot gnu.org
2013-08-03 8:08 ` olegendo at gcc dot gnu.org [this message]
2013-11-21 8:19 ` olegendo at gcc dot gnu.org
2013-11-21 9:03 ` olegendo at gcc dot gnu.org
2013-11-25 16:47 ` olegendo at gcc dot gnu.org
2014-08-13 22:02 ` [Bug target/53976] [SH] Unnecessary clrt/sett after bt/bf olegendo at gcc dot gnu.org
2014-11-23 17:37 ` olegendo at gcc dot gnu.org
2014-11-23 21:17 ` olegendo at gcc dot gnu.org
2014-11-23 21:45 ` olegendo 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-53976-4-M2YrRcAFFI@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).