From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0D92A3858C74; Fri, 21 Apr 2023 17:27:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0D92A3858C74 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682098069; bh=zcH8H7D3Z5nw+jYo+hUzJPQ4YyZCaMA4jqhR6p9hWWM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Z3zyw1mUIiTu3+in7zDCPO9UTvCmNx7k75LHP4HWvp3HWNVGE4gwt2Ccc2/16QQZl Fl6fQgEHSFj4IumwCyoM4Ycsk74untj4nQM+iFjRXkV7mG10VYrEP2bJl5ce5keD37 FMEOoMO5MJx8wSV8/sQw+NLhaBk8HMZgc8AzZFWg= From: "roger at nextmovesoftware dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106888] [RISCV] Negative optimization that excess andi instructions are generated in gcc.dg/pr90838.c Date: Fri, 21 Apr 2023 17:27:48 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: roger at nextmovesoftware 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: attachments.created 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=3D106888 --- Comment #5 from Roger Sayle --- Created attachment 54905 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54905&action=3Dedit proposed patch This patch should fix this problem, by adding another pattern the machine description to also recognize zero_extend of clz/ctz/pcnt, matching the cur= rent pattern that only matches sign_extend. Clearly for SI operands, the result must always be 0..32, so sign extension and zero extension are equivalent, = and the zero extension is perhaps (now) the preferred canonical form.=