From: Andrew MacLeod <amacleod@redhat.com>
To: Richard Biener <richard.guenther@gmail.com>,
Di Zhao <dizhao@os.amperecomputing.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
Aldy Hernandez <aldyh@redhat.com>
Subject: Re: [PATCH] tree-optimization/101186 - extend FRE with "equivalence map" for condition prediction
Date: Thu, 24 Jun 2021 09:25:04 -0400 [thread overview]
Message-ID: <860299c5-8f2e-2d1f-c7bc-bab4eb25ec8a@redhat.com> (raw)
In-Reply-To: <CAFiYyc2a4iP6DfrdOs_rUzMrvCJ3uJPa1E87ghS-akzjFU+bkQ@mail.gmail.com>
On 6/24/21 8:29 AM, Richard Biener wrote:
> On Thu, Jun 24, 2021 at 11:55 AM Di Zhao via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>
> You quote opportunities that are catched with this like
>
> + if (a != 0)
> + {
> + c = b;
> + }
> + for (unsigned i = 0; i < c; i++)
> + {
> + if (a != 0)
> + {
> + if (i >= b)
> + /* Should be eliminated.
> + */
> + foo ();
>
> but say other "obvious" cases like
>
> + if (a != 0)
> + {
> + c = b;
> + }
> + for (unsigned i = 0; i < c; i++)
> + {
> + if (a != 0)
> + {
> + /* Should be zero. */
> return b - c;
>
> are not handled. That's in line with the current "value predication"
> which mainly aims at catching simple jump threading opportunities;
> you only simplify conditions with the recorded equivalences. But
> then the complexity of handling equivalences does probably not
> outweight the opportunities catched - can you share some numbers
> on how many branches are newly known taken during VN with
> this patch during say bootstrap or build of SPEC CPU?
>
> I've hoped to ditch the current "value predication" code by eventually
> using the relation oracle from ranger but did not yet have the chance
> to look into that. Now, the predicated equivalences are likely not
> something that infrastructure can handle?
>
> In the end I think we should research into maintaining an alternate
> expression table for conditions (those we like to simplify with
> equivalences) and use a data structure that more easily allows to
> introduce (temporary) equivalences. Like by maintaining
> back-references of values we've recorded a condition for and a way
> to quickly re-canonicalize conditions. Well - it requires some research,
> as said.
>
The idea would be to handle all this eventually if it doesnt now. It'll
certainly be capable of it. we havent looked into any missed cases yet.
early days :-)
The oracle handles predicated things just fine. We're missing
transitive relations, and any time an edge has multiple predecessors we
sort of bail on predicated things for now. I also haven't gotten to
producing a nice relation/equivlance map of what we actually know...
That might be worthwhile sooner than later.
THe original function in EVRP currently looks like:
=========== BB 2 ============
<bb 2> :
if (a_5(D) == b_6(D))
goto <bb 8>; [INV]
else
goto <bb 7>; [INV]
=========== BB 8 ============
Equivalence set : [a_5(D), b_6(D)] edge 2->8 provides
a_5 and b_6 as equivalences
<bb 8> :
goto <bb 6>; [100.00%]
=========== BB 6 ============
<bb 6> :
# i_1 = PHI <0(8), i_10(5)>
if (i_1 < a_5(D))
goto <bb 3>; [INV]
else
goto <bb 7>; [INV]
=========== BB 3 ============
Relational : (i_1 < a_5(D)) edge 6->3 provides
this relation
<bb 3> :
if (i_1 == b_6(D))
goto <bb 4>; [INV]
else
goto <bb 5>; [INV]
So It knows that a_5 and b_6 are equivalence, and it knows that i_1 <
a_5 in BB3 as well..
so we should be able to indicate that i_1 == b_6 as [0,0].. we
currently aren't. I think I had turned on equivalence mapping during
relational processing, so should be able to tag that without transitive
relations... I'll have a look at why.
And once we get a bit further along, you will be able to access this
without ranger.. if one wants to simply register the relations directly.
Anyway, I'll get back to you why its currently being missed.
Andrew
next prev parent reply other threads:[~2021-06-24 13:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-24 9:54 Di Zhao
2021-06-24 12:29 ` Richard Biener
2021-06-24 13:25 ` Andrew MacLeod [this message]
2021-06-24 15:01 ` Andrew MacLeod
2021-06-25 7:38 ` Richard Biener
2021-06-27 15:46 ` Aldy Hernandez
2021-06-28 8:12 ` Richard Biener
2021-06-28 13:15 ` Andrew MacLeod
2021-06-29 10:54 ` Richard Biener
2021-07-18 19:25 ` Di Zhao OS
2021-07-28 9:38 ` Richard Biener
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=860299c5-8f2e-2d1f-c7bc-bab4eb25ec8a@redhat.com \
--to=amacleod@redhat.com \
--cc=aldyh@redhat.com \
--cc=dizhao@os.amperecomputing.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/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).