From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 060E5387085A; Mon, 27 Apr 2020 10:00:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 060E5387085A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587981621; bh=5dqUFgasrOJpQET0bFyx8cfsRZseB1uecZmo3TgtsGg=; h=From:To:Subject:Date:From; b=jnJei7LWs8A9ukypWXUK6sHYtHzeyqYe5jtlDt247RhUSNsvysplOUS+XPNKR1WlM CSEd8pvVjEGGizcqplgO3YwQZcR0tZL3AotyFYspf3MV7okpCTdkmi05lUa7K/EpwF TMiDNvjk0GKZ1iOzDVgQHrEzBnCkuqwl8BAfn3V0= From: "gabravier at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/94793] New: Failure to optimize clz idiom Date: Mon, 27 Apr 2020 10:00:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: gabravier at gmail dot com 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Mon, 27 Apr 2020 10:00:21 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94793 Bug ID: 94793 Summary: Failure to optimize clz idiom Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gabravier at gmail dot com Target Milestone: --- unsigned r1(unsigned v) { unsigned r =3D 0; while (v >>=3D 1) r++; return r; } This can optimized to `32 - __builtin_clz(v >> 1);`. LLVM does this transformation, but GCC does not. Comparison here : https://godbolt.org/z/u73iap=