public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub 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: Thu, 04 Jan 2024 16:17:32 +0000	[thread overview]
Message-ID: <bug-110852-4-Msxj3N627m@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 #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #9)
> By removing the logic we lose ability to optimize things like
>   a = b * c;
> where b is predicted to value 0 and c has no useful prediction on it.

No, that is what my unposted WIP patch did, but predict-18.c test catched that.

> > @@ -2631,6 +2623,9 @@ expr_expected_value_1 (tree type, tree o
> > 
> >           if (predictor2 < *predictor)
> >             *predictor = predictor2;
> > +         if (*predictor != PRED_BUILTIN_EXPECT
> > +             && *predictor != PRED_BUILTIN_EXPECT_WITH_PROBABILITY)
> > +           *probability = -1;
> 
> This still can "upgrade" prediction to a predictor of lower enm value
> but higher probability that is not conservative thing to do.
> > 
> >           return res;
> >         }
> I ended up with the folloing patch that also takes care of various cases
> of phi merging and downgrading the predictor to new
> PRED_COMBINED_VALUE_PREDICTION which can, like PRED_BUILTIN_EXPECT hold
> custom probability but it is not trued as FIRST_MATCH.
> What do you think?

> +	      int p1 = get_predictor_value (*predictor, *probability);
> +	      int p2 = get_predictor_value (predictor2, probability2);
> +	      /* If both predictors agrees, it does not matter from which

s/agrees/agree/

> +         Consequently failing to fold both means that we will not suceed
> determinging

s/suceed/succeed/;s/determinging/determining/

Otherwise yes, but I think the code could be still simplified the way I had in
my patch (i.e. drop parts of the r14-2219 changes, and simply assume that
failed recursion for one operand is PRED_UNCONDITIONAL instead of returning
early, and not requiring the operands are INTEGER_CSTs, just that the result of
the binop folds to INTEGER_CST.

  parent reply	other threads:[~2024-01-04 16:17 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 [this message]
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
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-Msxj3N627m@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).