From: Jakub Jelinek <jakub@redhat.com>
To: Jan Hubicka <hubicka@ucw.cz>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Fix merging of value predictors
Date: Wed, 17 Jan 2024 13:50:13 +0100 [thread overview]
Message-ID: <ZafNBbemPwVkdIHG@tucnak> (raw)
In-Reply-To: <ZafL3hji22r6utDb@kam.mff.cuni.cz>
On Wed, Jan 17, 2024 at 01:45:18PM +0100, Jan Hubicka wrote:
> Hi,
> expr_expected_value is doing some guesswork when it is merging two or more
> independent value predictions either in PHI node or in binary operation.
> Since we do not know how the predictions interact with each other, we can
> not really merge the values precisely.
>
> The previous logic merged the prediciton and picked the later predictor
> (since predict.def is sorted by reliability). This however leads to troubles
> with __builtin_expect_with_probability since it is special cased as a predictor
> with custom probabilities. If this predictor is downgraded to something else,
> we ICE since we have prediction given by predictor that is not expected
> to have customprobability.
>
> This patch fixies it by inventing new predictors PRED_COMBINED_VALUE_PREDICTIONS
> and PRED_COMBINED_VALUE_PREDICTIONS_PHI which also allows custom values but
> are considered less reliable then __builtin_expect_with_probability (they
> are combined by ds theory rather then by first match). This is less likely
> going to lead to very stupid decisions if combining does not work as expected.
>
> I also updated the code to be bit more careful about merging values and do not
> downgrade the precision when unnecesary (as tested by new testcases).
>
> Bootstrapped/regtested x86_64-linux, will commit it tomorrow if there are
> no complains.
>
> 2024-01-17 Jan Hubicka <jh@suse.cz>
> Jakub Jelinek <jakub@redhat.com>
2 spaces before < rather than 1.
>
> PR tree-optimization/110852
>
> gcc/ChangeLog:
>
> * predict.cc (expr_expected_value_1):
> (get_predictor_value):
> * predict.def (PRED_COMBINED_VALUE_PREDICTIONS):
> (PRED_COMBINED_VALUE_PREDICTIONS_PHI):
>
> gcc/testsuite/ChangeLog:
>
> * gcc.dg/predict-18.c:
Please fill in what has changed, both for predict-18.c and predict.{cc,def}
changes.
> @@ -2613,24 +2658,40 @@ expr_expected_value_1 (tree type, tree op0, enum tree_code code,
> if (!nop1)
> nop1 = op1;
> }
> + /* We already checked if folding one of arguments to constant is good
> + enough. Consequently failing to fold both means that we will not
> + succeed determinging the value. */
s/determinging/determining/
Otherwise LGTM.
Jakub
next prev parent reply other threads:[~2024-01-17 12:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 12:45 Jan Hubicka
2024-01-17 12:50 ` Jakub Jelinek [this message]
2024-01-17 13:20 ` Jan Hubicka
2024-01-19 21:37 ` rep.dot.nop
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=ZafNBbemPwVkdIHG@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
/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).