From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3FFB3858C2C; Thu, 24 Mar 2022 13:59:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3FFB3858C2C From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/99309] [10/11/12 Regression] Segmentation fault with __builtin_constant_p usage at -O2 Date: Thu, 24 Mar 2022 13:59:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Mar 2022 13:59:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99309 --- Comment #10 from Richard Biener --- The issue for FRE is that we have [local count: 10737416]: step.val =3D 610334368; value.val =3D 1; goto ; [100.00%] [local count: 1073741824]: # __1 =3D PHI <0(2), __11(4)> if (__1 !=3D 100) goto ; [99.00%] else goto ; [1.00%] [local count: 1063004409]: __builtin_printf ("%d %d\n", 1, 610334368); m =3D step; _12 =3D m.val; _13 =3D __builtin_constant_p (_12); if (_13 !=3D 0) goto ; [100.00%] else goto ; [0.00%] [local count: 1063004409]: __builtin_puts (&"normal"[0]); m =3D{v} {CLOBBER(eol)}; __builtin_printf ("%d %d\n", 1, 610334368); __11 =3D __1 + 1; goto ; [100.00%] [count: 0]: __builtin_unreachable (); and while the first FRE iteration correctly determines that m.val is 610334= 368 we then make the backedge of the loop executable and because we translated the lookup expression from m.val to step.val we are refusing to handle loops (the abort_on_visited argument to get_continuation_for_phi, set from translated in walk_non_aliased_vuses). I don't remember why I disregarded the fix in comment#3 of PR54498, a fix along that line would enable CSE here. The concern was probably compile-time (but we limit the amount of alias queries done). It's a bit late to do such change for GCC 12 I think. I will queue this for GCC 13.=