From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 63EE0395CC54; Thu, 7 May 2020 17:06:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63EE0395CC54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1588871172; bh=bFpVP6fbvJ017SPOzal1uRKgvsBvi3pgumefnqXaEBQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q9RpeQQrUvQ81RHzoO9wPFDwvsFBrxZUgTKRj5dUMy4Wz8IU3jW+VZREzdCi0Q6Pc WFSCW4KR8pSP1/U6dk4bWlsfE8iHwDmpNGvAERl6rPN8jIRSPhtx5HfYxnuR+18BU6 NIOWkRXY4doQ2HahLj3VcCpWS29E9qoy5yJ2YWBo= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94793] Failure to optimize clz idiom Date: Thu, 07 May 2020 17:06:12 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: 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, 07 May 2020 17:06:12 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94793 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #2 from Jakub Jelinek --- You mean like PR82479 ? Though, __builtin_clz is UB at zero, so it would n= eed to be v >>=3D 1; r =3D v ? 32 - __builtin_clz(v) : 0; v =3D 0; or so, excep= t that on aarch64 (or where we CLZ_DEFINED_VALUE_AT_ZERO as 2, i.e. guarantee if CLZ = ifn or builtins to have the behavior defined at GIMPLE rather than say just RTL= or never). And on other targets that have CLZ_DEFINED_VALUE_AT_ZERO 1 with va= lue of precision, perhaps convert that conditional into just CLZ at RTL time.=