From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A55CA3858C41; Thu, 4 Jan 2024 16:26:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A55CA3858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704385583; bh=/lj5OAYqrUj5GI/JljnHDvAiiaghKpZ1ZAtqSNjo56M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=u/S/fCtZD7T4nrj7jZuAfZH5x8UXHpZm2zQmwUg/H2POq+k6QF6kkt0Evg0VbnYat pe9yxjaYVdbDKLoGxtxVSx2yyJFvMNaanEN8a0DkTmO0Pyw5ibXjEPu1B+Z9JBOkPI NRaPJCqESSXQdMK1KuY6aFzM6y69O3PCKa4QElUY= From: "hubicka at ucw dot cz" 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:26:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at ucw dot cz X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110852 --- Comment #11 from Jan Hubicka --- > > + int p1 =3D get_predictor_value (*predictor, *probability); > > + int p2 =3D get_predictor_value (predictor2, probability2); > > + /* If both predictors agrees, it does not matter from which >=20 > s/agrees/agree/ >=20 > > + Consequently failing to fold both means that we will not suce= ed > > determinging >=20 > s/suceed/succeed/;s/determinging/determining/ Fixed that, thanks! >=20 > Otherwise yes, but I think the code could be still simplified the way I h= ad 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 returni= ng > early, and not requiring the operands are INTEGER_CSTs, just that the res= ult of > the binop folds to INTEGER_CST. I added the early exits to handle the following case. a =3D b * c If b is prediced to 0 with predictor1, while c is predicted to 1 with predictor2 your version will predict a to be 0, but will merge predictor1 and 2 leading to lower probability than predictor1 alone. So the early exit will give bit higher chance for not losing information. The code is still lax if both b and c are predicted to 0 in which case we can work out that combined probability is at least max of the two predictor probabilities, but I was not sure if that is work extra folding overhead. >=20 > --=20 > You are receiving this mail because: > You are on the CC list for the bug.=