public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "z.zhanghaijian at huawei dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94274] fold phi whose incoming args are defined from binary operations
Date: Tue, 24 Mar 2020 13:42:36 +0000 [thread overview]
Message-ID: <bug-94274-4-mlnlEMeQgf@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94274-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94274
--- Comment #3 from z.zhanghaijian at huawei dot com <z.zhanghaijian at huawei dot com> ---
(In reply to Marc Glisse from comment #1)
> Detecting common beginnings / endings in branches is something gcc does very
> seldom. Even at -Os, for if(cond)f(b);else f(c); we need to wait until
> rtl-optimizations to get a single call to f. (of course the reverse
> transformation of duplicating a statement that was after the branches into
> them, if it simplifies, is nice as well, and they can conflict)
> I don't know if handling one such very specific case (binary operations with
> a common argument) separately is a good idea when we don't even handle unary
> operations.
I tried to test this fold on specint2017 and found some performance gains on
500.perlbench_r. Then compared the assemble and found some improvements.
For example:
S_invlist_max, which is inlined by many functions, such as
S__append_range_to_invlist, S_ssc_anything, Perl__invlist_invert ...
invlist_inline.h:
#define FROM_INTERNAL_SIZE(x) ((x)/ sizeof(UV))
S_invlist_max(inlined by S__append_range_to_invlist, S_ssc_anything,
Perl__invlist_invert, ....):
return SvLEN(invlist) == 0 /* This happens under _new_invlist_C_array */
? FROM_INTERNAL_SIZE(SvCUR(invlist)) - 1
: FROM_INTERNAL_SIZE(SvLEN(invlist)) - 1;
Dump tree phiopt:
<bb 3> [local count: 536870911]:
_46 = pretmp_112 >> 3;
iftmp.1123_47 = _46 + 18446744073709551615;
goto <bb 5>; [100.00%]
<bb 4> [local count: 536870911]:
_48 = _44 >> 3;
iftmp.1123_49 = _48 + 18446744073709551615;
<bb 5> [local count: 1073741823]:
# iftmp.1123_50 = PHI <iftmp.1123_47(3), iftmp.1123_49(4)>
Which can replaces with:
<bb 3> [local count: 536870912]:
<bb 4> [local count: 1073741823]:
# _48 = PHI <_44(2), pretmp_112(3)>
_49 = _48 >> 3;
iftmp.1123_50 = _49 + 18446744073709551615;
Assemble:
lsr x5, x6, #3
lsr x3, x3, #3
sub x20, x5, #0x1
sub x3, x3, #0x1
csel x20, x3, x20, ne
Replaces with:
csel x3, x3, x4, ne
lsr x3, x3, #3
sub x20, x3, #0x1
This can eliminate two instruction.
next prev parent reply other threads:[~2020-03-24 13:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-23 11:42 [Bug tree-optimization/94274] New: " z.zhanghaijian at huawei dot com
2020-03-23 12:59 ` [Bug tree-optimization/94274] " glisse at gcc dot gnu.org
2020-03-23 14:04 ` rguenth at gcc dot gnu.org
2020-03-24 13:42 ` z.zhanghaijian at huawei dot com [this message]
2020-03-25 9:40 ` z.zhanghaijian at huawei dot com
2020-06-02 7:43 ` z.zhanghaijian at huawei dot com
2021-08-03 23:33 ` 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-94274-4-mlnlEMeQgf@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).