From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ECE9A384C005; Thu, 6 Aug 2020 13:05:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECE9A384C005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1596719136; bh=oUHYO1kgz3aoJSrX2wWVxHExateWo6kMD0RSyFtncZU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TU50eb2dtBESqinrWlBD26QC6xpAD0KSqMIbeRLDUGi9nrtf/aA9/wMphY6BO7syv JW2TqFQtmZGpHHKXmbm1XPTOTyNoRiOPc6U+x+YAMoO1nzMRpWpT/rhzyS00eF+uPy WlJ8dU2XCH4nfzx9ZlftZDfWCpLyXXrZMHqUC5/Y= From: "matthew at wil dot cx" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/32911] Function __attribute__ ((idempotent)) Date: Thu, 06 Aug 2020 13:05:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: matthew at wil dot cx 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 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, 06 Aug 2020 13:05:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D32911 Matthew Wilcox changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |matthew at wil dot cx --- Comment #6 from Matthew Wilcox --- I actually have a use for a real idempotent function, that is f(f(x)) =3D= =3D f(x). I think it's different from the behaviour wanted here which is more of an initialiser functionality. The concrete example is Linux's compound_head() macro which takes a pointer= to a struct page and returns a pointer to a (potentially different) struct pag= e.=20 A page is its own head, and calls to compound_head can be buried inside mac= ros. So I'd like gcc to know that given this program: struct page *compound_head(struct page *) __attribute__((idempotent)); int g(struct page *page) { struct page *head =3D compound_head(page); return page->refcount; } int f(struct page *page) { struct page *head =3D compound_head(page); return g(head); } if it inlines g() into f(), it only needs to make one call to compound_head= ().=