From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id CC6CA3858D37; Thu, 26 Oct 2023 14:46:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC6CA3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1698331602; bh=LOeZttWvGo+DMuQp4IVv1n7I5tSwpwNEqh4zfK8Pawc=; h=From:To:Subject:Date:From; b=O7he55HSVGFeT0El64tfcLi+n4e3i/bo/Dwvz9Ijpj+ln5Hm2RUQ6Da1Tk20soJ+n /u5KfaEn26sfoN8suFuSWboCqznI12g1WRdk2Ezoiu53hw9ApGtt+381t7QPMPW7WF 8lpmQOQDItJf22MTtiFyqO2+nkYvj6CVQd/oD7Lo= From: "kazeemanuar at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/112102] New: Inefficient Integer multiplication on MIPS processors Date: Thu, 26 Oct 2023 14:46:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kazeemanuar at googlemail 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=3D112102 Bug ID: 112102 Summary: Inefficient Integer multiplication on MIPS processors Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: kazeemanuar at googlemail dot com Target Milestone: --- Running integer multiplication with the -Os flag enabled can generate 2 unnecessary NOP instructions. This increases the cost of integer multiplica= tion from 7 to 9 cycles in most cases. Example code: int test(int a, int b, int c, int d) { return 788*a + 789 * b + 187 + c + d; } output: li $2,788 mult $4,$2 li $2,789 <--- could be moved down into one of the NOPs mflo $4 nop nop mult $5,$2 mflo $5 addu $4,$4,$5 addiu $4,$4,187 <--- could be moved up into one of the NOPs addu $4,$4,$6 <--- could be moved up into one of the NOPs jr $31 addu $2,$4,$7 This happens on all GCC versions as far as I can tell. Compiler explorer link: https://godbolt.org/z/M3x3s3KhM=