From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 522D53856944; Mon, 6 Nov 2023 07:38:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 522D53856944 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699256333; bh=VnTdJmMUiDj+gxgerYF10Iwo+e7ad6w6NLYtoi++9Bk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=OViSS1h7J/RXGwcnhVPmlfjAYrV70k3REd2UMcKHCFb2FwbAjnwDLZGAR1xbfYkCT GlXkvlSePIHJXok+d43VShvpV+PtNEeSb88xv1+AiyVlY7dNOsS/zQKo+AU9Vwsc2B d37vQ+sYMbn09SkZ3gM2XHKo1kjlQ4DWprfw1+sg= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112296] __builtin_constant_p doesn't propagate through member functions Date: Mon, 06 Nov 2023 07:38:52 +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: 13.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: bug_status keywords cc assigned_to 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=3D112296 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEW Keywords|documentation | CC| |jakub at gcc dot gnu.org Assignee|rguenth at gcc dot gnu.org |unassigned at gcc d= ot gnu.org --- Comment #15 from Richard Biener --- I clarified the documentation. While in the particular case 'span.size ()' doesn't have side-effects (well, I'm not 100% sure) in general function cal= ls are difficult to handle "delayed" while still allowing to discard side-effe= cts. Maybe the infrastructure we put in place for [[assume]] could help here by treating __builtin_constant_p (expr) as [["assume" (guard)]] { tem =3D expr; guard =3D __builtin_constant_p (tem); } guard; and lower it to .ASSUME (&artificial_fn, args...); but now with a return value that would become zero at the point we elide .ASSUME unless we end up with a [1,1] range for the result? That said, it's best to avoid relying on the side-effect removal, that is, avoid having arguments with possible side-effects in __builtin_constant_p.=