From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E2C293849AC7; Fri, 19 Apr 2024 08:42:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2C293849AC7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713516161; bh=7shnFnV6qxpNRobHfYafQtUFE8/rVeoEm5goM5A0+Yw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VJxRwSlilPW372ZzZsSUNY5xyfJR3rrx8Bhh6XzhAxBHczVojqrz7FMvimn37EtVb QxCSaXdGdva6EeF6VrmTbtJrRdPe2AKi/W0D/czzgUKZJj+sIp6Aw9seVG7kI+kHi8 C4UkFj6MPqbtel+o2Psyv7BYniGvowQ53oNjwSn4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114779] __builtin_constant_p does not work in inline functions Date: Fri, 19 Apr 2024 08:42:41 +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: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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=3D114779 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek --- That has nothing to do with inline functions and everything to do with poin= ter arguments to __builtin_constant_p. The builtin behaved that way since at l= east 1998. The current version still has /* If this expression has side effects, show we don't know it to be a constant. Likewise if it's a pointer or aggregate type since in those case we only want literals, since those are only optimized when generating RTL, not later. And finally, if we are compiling an initializer, not code, we need to return a definite result now; there's not going to be any more optimization done. */ if (TREE_SIDE_EFFECTS (arg) || AGGREGATE_TYPE_P (TREE_TYPE (arg)) || POINTER_TYPE_P (TREE_TYPE (arg)) || cfun =3D=3D 0 || folding_initializer || force_folding_builtin_constant_p) return integer_zero_node; What triggers here is the POINTER_TYPE_P (TREE_TYPE (arg)) case. So, the builtin is immediately folded into 0 in that case.=