From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F1D933858D38; Wed, 14 Sep 2022 11:23:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1D933858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663154598; bh=GAsyx8L9/r02w2IGWi0EbOnYWM/WXWC+BQEXzyD1Cg8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k07FKYu2gkYKV485k2QgdlFiyJ3OoLSe75kR7PftqyHQeB+5qs8lgXPlqTeN864/V qbVXijGOKcYKe0P9kw/SogEtnrADnYy1lWZGQIBoMteZLUEifhxmq4ol/bqLcSibRD 6QEmUZhcTLKLH8hmhwn2XlfYznVS+SwuX70R+EpU= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106654] [C++23] P1774 - Portable assumptions Date: Wed, 14 Sep 2022 11:23:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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=3D106654 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org --- Comment #2 from Richard Biener --- Note my main dislike is because the former is essentially if (0) { if (!cond) __builtin_unreachable (); } that is, the assumption itself, not only its condition computation (and side-effects) are thrown away. With cond =3D .IFN_ASSUME (outlined_cond_computer, args...); if (!cond) __builtin_unreachable (); or as Jakub prefers with implicit unreachable, the side-effects we want to elide are in 'outlined_cond_computer' and we can later "optimize" the .IFN_ASSUME call to compute true. For ranger the difficulty in the latter form is that there will be assertions on 'args...', variables at the call site, but what they are is specified by outlined_cond_computer returning true. Consider _bool outlined_cond_computer (int i, int j) { return i_1(D) =3D=3D j_2(D); } from [[assume(i =3D=3D j)]]; we'd then have .IFN_ASSUME (cond_fn, i_2, j_5); and just like IPA does, we'd have to "connect" relations/ranges produced by outlined_cond_computer via argument positions. I think we can easily funnel in argument ranges from the caller and thus possibly compute outlined_cond_computer outgoing ranges for the arguments (only those are interesting!) on the "true" return edge. Complication is the IL is in another function, set_cfun is a bit expensive but in theory most things could be formulated in a way to not require 'cfun' be set "correctly". On the C++ frontend side I'd simply handle [[assume(expr)]] as if 'expr' were in a lambda -> bool with everything captured by value.=