From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CFD823858D28; Mon, 17 Oct 2022 09:25:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CFD823858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665998745; bh=00R+uBIoqnhzxouOT4S13hRUOBfAUlZrCILVFSl0T+I=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZJvK6IDGls+EQDf0yO+9mwgBzliQMf8rko4s5dSl1zyCFgWYq0UdjnMVyplL0b6O6 OkN0jy71Z1i19U/LXCTUPOC3ZAMxCL7Q06xbPZugu/vJThi5JoR3yYr3UIRX1hXjrg dyLFds/gFXwYr9S7JCr5rYh53iiLxtas5a+2WYV0= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/107285] Incorrect code generation when we use __builtin_constant_p built-in function. Date: Mon, 17 Oct 2022 09:25:44 +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: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: 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=3D107285 --- Comment #4 from Jakub Jelinek --- No, the generated code is just fine. At -O2, bar is inlined into main. So we have unsigned int a =3D __builtin_constant_p (3) ? 13 : 60; and 3 is constant. In the out of line copy of bar, value1 is a function parameter, so __builtin_constant_p evaluates to false. As I said, what is bad is the testcase, the above isn't how __builtin_constant_p should be used. I'd suggest you look in /usr/include/ or other codebases how one uses the builtin...=