public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/110852] [14 Regression] ICE: in get_predictor_value, at predict.cc:2695 with -O -fno-tree-fre and __builtin_expect() since r14-2219-geab57b825bcc35
Date: Wed, 17 Jan 2024 14:20:06 +0000	[thread overview]
Message-ID: <bug-110852-4-07afematMv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-110852-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110852

--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jan Hubicka <hubicka@gcc.gnu.org>:

https://gcc.gnu.org/g:b00be6f1576993369522c16dba992bec9adab9b2

commit r14-8187-gb00be6f1576993369522c16dba992bec9adab9b2
Author: Jan Hubicka <jh@suse.cz>
Date:   Wed Jan 17 15:19:32 2024 +0100

    Fix merging of value predictors

    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>

            PR tree-optimization/110852

    gcc/ChangeLog:

            * predict.cc (expr_expected_value_1): Fix profile merging of PHI
and
            binary operations
            (get_predictor_value): Handle PRED_COMBINED_VALUE_PREDICTIONS and
            PRED_COMBINED_VALUE_PREDICTIONS_PHI
            * predict.def (PRED_COMBINED_VALUE_PREDICTIONS): New predictor.
            (PRED_COMBINED_VALUE_PREDICTIONS_PHI): New predictor.

    gcc/testsuite/ChangeLog:

            * gcc.dg/predict-18.c: Update template to expect combined value
predictor.
            * gcc.dg/predict-23.c: New test.
            * gcc.dg/tree-ssa/predict-1.c: New test.
            * gcc.dg/tree-ssa/predict-2.c: New test.
            * gcc.dg/tree-ssa/predict-3.c: New test.

  parent reply	other threads:[~2024-01-17 14:20 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-30  9:02 [Bug tree-optimization/110852] New: [14 Regression] ICE: in get_predictor_value, at predict.cc:2695 with -O -fno-tree-fre and __builtin_expect() zsojka at seznam dot cz
2023-07-30 20:04 ` [Bug tree-optimization/110852] " pinskia at gcc dot gnu.org
2023-08-01 13:57 ` hubicka at gcc dot gnu.org
2023-10-17 12:23 ` rguenth at gcc dot gnu.org
2023-10-17 12:23 ` rguenth at gcc dot gnu.org
2023-10-22 23:40 ` [Bug tree-optimization/110852] [14 Regression] ICE: in get_predictor_value, at predict.cc:2695 with -O -fno-tree-fre and __builtin_expect() since r14-2219-geab57b825bcc35 sjames at gcc dot gnu.org
2023-11-13  3:27 ` pinskia at gcc dot gnu.org
2024-01-04 14:42 ` jakub at gcc dot gnu.org
2024-01-04 15:24 ` hubicka at ucw dot cz
2024-01-04 15:30 ` jakub at gcc dot gnu.org
2024-01-04 15:59 ` jakub at gcc dot gnu.org
2024-01-04 16:06 ` hubicka at ucw dot cz
2024-01-04 16:17 ` jakub at gcc dot gnu.org
2024-01-04 16:26 ` hubicka at ucw dot cz
2024-01-04 16:35 ` jakub at gcc dot gnu.org
2024-01-04 16:37 ` jakub at gcc dot gnu.org
2024-01-04 17:06 ` hubicka at ucw dot cz
2024-01-17 14:20 ` cvs-commit at gcc dot gnu.org [this message]
2024-01-17 14:22 ` hubicka 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-110852-4-07afematMv@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).