public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112102] New: Inefficient Integer multiplication on MIPS processors
@ 2023-10-26 14:46 kazeemanuar at googlemail dot com
  2023-10-26 15:03 ` [Bug c/112102] " kazeemanuar at googlemail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kazeemanuar at googlemail dot com @ 2023-10-26 14:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112102

            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 multiplication
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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-10-26 18:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-26 14:46 [Bug c/112102] New: Inefficient Integer multiplication on MIPS processors kazeemanuar at googlemail dot com
2023-10-26 15:03 ` [Bug c/112102] " kazeemanuar at googlemail dot com
2023-10-26 17:31 ` [Bug target/112102] " pinskia at gcc dot gnu.org
2023-10-26 17:46 ` pinskia at gcc dot gnu.org
2023-10-26 18:41 ` kazeemanuar at googlemail dot com
2023-10-26 18:41 ` pinskia at gcc dot gnu.org
2023-10-26 18:45 ` pinskia at gcc dot gnu.org
2023-10-26 18:47 ` pinskia at gcc dot gnu.org
2023-10-26 18:59 ` kazeemanuar at googlemail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).