From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D434D385842B; Wed, 1 Mar 2023 19:56:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D434D385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677700614; bh=cc1Ubvd4Y+LKCwCK34m+DYFTWcDzRbr7fVLjNVe2Pe0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W00r0nWFrK2ThA2/T+3TdPyZTVPqP1Zc55DPV+KN7kYxwyB/j96EhxmcWmBgjja9d i4gQUIob0VB/NXIAUVKBDmqSYMURvWtPccYmbn6npiOngBVi9OTqqKGgydxWrUrMJK PrOU5wivbOBg6q1jH5zYr9oLfw/hnhtIGH4TyEzg= From: "vineetg at rivosinc dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108987] [13 Regression] RISC-V: shiftadd cost model bug needlessly preferring syth_multiply Date: Wed, 01 Mar 2023 19:56:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vineetg at rivosinc 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: 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=3D108987 --- Comment #1 from Vineet Gupta --- Fix posted here https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613106.html Essentially: case PLUS: if (TARGET_ZBA && mode =3D=3D word_mode && GET_CODE (XEXP (x, 0)) =3D=3D MULT && REG_P (XEXP (XEXP (x, 0), 0)) && CONST_INT_P (XEXP (XEXP (x, 0), 1)) - && IN_RANGE (pow2p_hwi (INTVAL (XEXP (XEXP (x, 0), 1))), 1, 3)) + && pow2p_hwi (INTVAL (XEXP (XEXP (x, 0), 1))) + && IN_RANGE (exact_log2 (INTVAL (XEXP (XEXP (x, 0), 1))), 1, 3)) { *total =3D COSTS_N_INSNS (1); return true; }=