From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 545763857C67; Wed, 31 Mar 2021 18:18:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 545763857C67 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/99309] [10/11 Regression] Segmentation fault with __builtin_constant_p usage at -O2 Date: Wed, 31 Mar 2021 18:18:07 +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: hubicka at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.3 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: Wed, 31 Mar 2021 18:18:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99309 --- Comment #5 from Jan Hubicka --- As discussed, I can prepare patch to make inliner to redirect __builtin_constant_p to __builtin_true whenever inliner detect that the expression is compile time ocnstant. This will avoid us eventually hitting unreachable when late optimizations forget to make the transformation. I was worried about this idea since this will still lead to some inconsiste= ncy since uses guarded by the __builtin_constnat_p may or may not be constant propagated and it seems logical to assume that in the block guarded by builtin_constnat_p the expression will indeed evaluate to compile time constant. However we can get similar inconsistencies with alias oracle walking limits= as well, so these constructions are generally fragile (but seems increasingly common in C++ codebases). It would be still nice to have fre5 to constant propagate this. IPA analysis are very simplistics. Richi, any idea on this?=