From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 30E453858D33; Wed, 1 Mar 2023 19:34:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30E453858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677699261; bh=XOY5Cwyyjb60gTrcPQuTE/SSx35bnJxzOcR5l/2knBE=; h=From:To:Subject:Date:From; b=Hz1QKXW3/z1+DJahPeZjuDCWuoi3G2wSTYZiZn+r+QDMGDGB2nGtdjmJ1hZ+EfN9m 4r4C3MABfxjZSSctETylEMhqdhtAFg5HkonJjEAjGH2VW6dcT1F7rFsVjW/tQlb3h0 /+Y3qtvISR7ofr6AdwK50O7LyREB6LvxH6APRSLI= From: "vineetg at rivosinc dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/108987] New: [13 Regression] RISC-V: shiftadd cost model bug needlessly preferring syth_multiply Date: Wed, 01 Mar 2023 19:34:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108987 Bug ID: 108987 Summary: [13 Regression] RISC-V: shiftadd cost model bug needlessly preferring syth_multiply Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vineetg at rivosinc dot com Target Milestone: --- gcc trunk is preferring synthetic multiply using shift+add even when they a= re costlier than multiply. unsigned long long f5(unsigned long long i) { return i * 0x0202020202020202ULL; } riscv64-unknown-linux-gnu-gcc -c -O2 -march=3Drv64gc_zba f5: slli a5,a0,8 add a0,a5,a0 slli a5,a0,16 add a0,a0,a5 slli a5,a0,32 add a0,a0,a5 slli a0,a0,1 ret With gcc 12.2 this used to be f5: lui a5,%hi(.LC0) ld a5,%lo(.LC0)(a5) mul a0,a0,a5 ret This is a regression introduced by commit f90cb39235c4 ("RISC-V: costs: sup= port shift-and-add in strength-reduction"). It introduced the cost for shift[1-3]+add (to favor SH*ADD) but due to a coding bug ended up doing this for all shift values, affecting synth multiply among others. This showed up as dynamic icount regression in SPEC 531.deepsjeng.=