From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5A0E8385B510; Fri, 17 Feb 2023 16:32:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A0E8385B510 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676651547; bh=R40bHutEyOrFO7nNLRWS4/WN6y/4bJrGuTIckjkKDU4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mYGW0Qa7QQQhCpzJSK9Kbgkxvu4ww0k1VHQvF9L3A/7qSfyC7fmROROcgogejlMa2 jf/ZmVbFdhYfXfgw1R4cbhMIFUFduOIDQtARO4ykuaVAnCHCeGW08vEQWQdFBZMwB0 HojbA7OIKwtboPC3rHg0Npac3c1AULcBRIK6KkqI= From: "wilco at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/90838] Detect table-based ctz implementation Date: Fri, 17 Feb 2023 16:32:26 +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: 9.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: wilco at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: wilco at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.0 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=3D90838 --- Comment #21 from Wilco --- (In reply to Gabriel Ravier from comment #19) > If the original code being branchless makes it faster, wouldn't that imply > that we should use the table-based implementation when generating code for > `__builtin_ctz` ? __builtin_ctz is 3-4 times faster than the table implementation, so this optimization is always worth it. This is why I believe the current situatio= n is not ideal since various targets still set CTZ_DEFINED_VALUE_AT_ZERO to 0 or= 1. One option would be to always allow it in Gimple (perhaps add an extra argu= ment for the value to return for a zero input), and at expand time check whether= the backend supports the requested value. It it doesn't, emit branches.=