From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9FE8D382F980; Fri, 7 Oct 2022 14:20:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FE8D382F980 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665152416; bh=TMfF//HFCd1hQplx1P5+y1oMqx5gKht/2eZQmMdNCUk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZKoanbyHRwjQ8HYv/C62gHdSMjgiJl2pKaAF2IuPvF3Ik7nV2Z5COy3RYc7FpXXH+ JZOeM9wHCIAFmZJa2jyCBkWVEGQZl40mDB0AlNmH4dJbelEsd0xdNVv2tt9wtcf1Y4 7xdkguS8pR2Wt7BIuzq4RTs1FSDYkzT6URbLONnY= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106654] [C++23] P1774 - Portable assumptions Date: Fri, 07 Oct 2022 14:20:14 +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: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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 --- Comment #14 from Jakub Jelinek --- Created attachment 53675 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D53675&action=3Dedit gcc13-pr106654-gimple-wip.patch My current WIP patch for the handling of more complex assumptions. My current testcase is for -O2: int foo (int x) { [[assume (x =3D=3D 42)]]; return x; } int bar (int x) { [[assume (++x =3D=3D 43)]]; return x; } int baz (int x) { [[assume (({ int z =3D ++x; if (z =3D=3D 51) return -1; if (z =3D=3D 53) = goto lab1; z =3D=3D 43; }))]]; lab1: return x; } Before IPA, that is roughly how I'd like it to look like. What still needs to be done is: 1) mark the assumption functions somehow and arrange for not being actually expanded into RTL, just the bodies kept around for optimization of other functions 2) for LTO ideally ensure they are duplicated in every partition that refers to them 3) teach ranger to get something useful ouf ot it 4) perhaps for later, decide what to do e.g. for SRA, so that passing an argument by value to .ASSUME doesn't prevent its SRA optimization 5) guess see if one can somehow bypass fab pass (-fdisable-tree-fab doesn't seem to work) and if yes, don't ICE if .ASSUME call makes it down to expansio= n, instead fold it away right before or during expansion such that args don't need to be evaluated) Anyway, I must be doing something wrong, because on the above testcase I get ICE in: during RTL pass: expand a.C: In function =E2=80=98_Z3bari._assume.0=E2=80=99: a.C:11:3: internal compiler error: in adjust_one_expanded_partition_var, at cfgexpand.cc:1577 11 | [[assume (++x =3D=3D 43)]]; | ^~~~~~~~~~~~~~~~~~~~~~ 0x99d1ba adjust_one_expanded_partition_var ../../gcc/cfgexpand.cc:1577 0x9af44c execute ../../gcc/cfgexpand.cc:6737 where the name in question is default def for the argument - x_1(D): bool _Z3bari._assume.0 (int x) { bool _2; [local count: 1073741824]: _2 =3D x_1(D) =3D=3D 42; return _2; }=