public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/112936] New: LoongArch: Wrong instruction costs
@ 2023-12-09  9:12 xry111 at gcc dot gnu.org
  2023-12-09  9:17 ` [Bug target/112936] " xry111 at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-09  9:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112936
           Summary: LoongArch: Wrong instruction costs
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xry111 at gcc dot gnu.org
  Target Milestone: ---

Separated from PR112935 comment 3.

The current loongarch_rtx_cost_data constructor (for default cost model, used
by LA464 and LA664 for now) seems completely wrong.  Per my micro-benchmark the
values in reality should be:

loongarch_rtx_cost_data::loongarch_rtx_cost_data ()
  : fp_add (COSTS_N_INSNS (5)),
    fp_mult_sf (COSTS_N_INSNS (5)),
    fp_mult_df (COSTS_N_INSNS (5)),
    fp_div_sf (COSTS_N_INSNS (8)),
    fp_div_df (COSTS_N_INSNS (8)),
    int_mult_si (COSTS_N_INSNS (4)),
    int_mult_di (COSTS_N_INSNS (4)),
    int_div_si (COSTS_N_INSNS (5)),
    int_div_di (COSTS_N_INSNS (5)),
    branch_cost (6),
    memory_latency (4) {}

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

* [Bug target/112936] LoongArch: Wrong instruction costs
  2023-12-09  9:12 [Bug target/112936] New: LoongArch: Wrong instruction costs xry111 at gcc dot gnu.org
@ 2023-12-09  9:17 ` xry111 at gcc dot gnu.org
  2023-12-10  5:26 ` xry111 at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-09  9:17 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-12-09
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Self-confirming as the original performance issue is from Jia Jie and the cost
model issue was isolated by Andrew.

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

* [Bug target/112936] LoongArch: Wrong instruction costs
  2023-12-09  9:12 [Bug target/112936] New: LoongArch: Wrong instruction costs xry111 at gcc dot gnu.org
  2023-12-09  9:17 ` [Bug target/112936] " xry111 at gcc dot gnu.org
@ 2023-12-10  5:26 ` xry111 at gcc dot gnu.org
  2023-12-10  5:27 ` xry111 at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-10  5:26 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2023-Decembe
                   |                            |r/640012.html
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |xry111 at gcc dot gnu.org

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

* [Bug target/112936] LoongArch: Wrong instruction costs
  2023-12-09  9:12 [Bug target/112936] New: LoongArch: Wrong instruction costs xry111 at gcc dot gnu.org
  2023-12-09  9:17 ` [Bug target/112936] " xry111 at gcc dot gnu.org
  2023-12-10  5:26 ` xry111 at gcc dot gnu.org
@ 2023-12-10  5:27 ` xry111 at gcc dot gnu.org
  2023-12-17 11:24 ` cvs-commit at gcc dot gnu.org
  2023-12-17 11:25 ` xry111 at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-10  5:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Patch: https://gcc.gnu.org/pipermail/gcc-patches/2023-December/640012.html

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

* [Bug target/112936] LoongArch: Wrong instruction costs
  2023-12-09  9:12 [Bug target/112936] New: LoongArch: Wrong instruction costs xry111 at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-12-10  5:27 ` xry111 at gcc dot gnu.org
@ 2023-12-17 11:24 ` cvs-commit at gcc dot gnu.org
  2023-12-17 11:25 ` xry111 at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-17 11:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:

https://gcc.gnu.org/g:50b3f596bd943ec6110c1987f14e5497ce39622f

commit r14-6642-g50b3f596bd943ec6110c1987f14e5497ce39622f
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Sat Dec 9 17:41:32 2023 +0800

    LoongArch: Fix instruction costs [PR112936]

    Replace the instruction costs in loongarch_rtx_cost_data constructor
    based on micro-benchmark results on LA464 and LA664.

    This allows optimizations like "x * 17" to alsl, and "x * 68" to alsl
    and slli.

    gcc/ChangeLog:

            PR target/112936
            * config/loongarch/loongarch-def.cc
            (loongarch_rtx_cost_data::loongarch_rtx_cost_data): Update
            instruction costs per micro-benchmark results.
            (loongarch_rtx_cost_optimize_size): Set all instruction costs
            to (COSTS_N_INSNS (1) + 1).
            * config/loongarch/loongarch.cc (loongarch_rtx_costs): Remove
            special case for multiplication when optimizing for size.
            Adjust division cost when TARGET_64BIT && !TARGET_DIV32.
            Account the extra cost when TARGET_CHECK_ZERO_DIV and
            optimizing for speed.

    gcc/testsuite/ChangeLog

            PR target/112936
            * gcc.target/loongarch/mul-const-reduction.c: New test.

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

* [Bug target/112936] LoongArch: Wrong instruction costs
  2023-12-09  9:12 [Bug target/112936] New: LoongArch: Wrong instruction costs xry111 at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-12-17 11:24 ` cvs-commit at gcc dot gnu.org
@ 2023-12-17 11:25 ` xry111 at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: xry111 at gcc dot gnu.org @ 2023-12-17 11:25 UTC (permalink / raw)
  To: gcc-bugs

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

Xi Ruoyao <xry111 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Fixed for 14.

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

end of thread, other threads:[~2023-12-17 11:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-09  9:12 [Bug target/112936] New: LoongArch: Wrong instruction costs xry111 at gcc dot gnu.org
2023-12-09  9:17 ` [Bug target/112936] " xry111 at gcc dot gnu.org
2023-12-10  5:26 ` xry111 at gcc dot gnu.org
2023-12-10  5:27 ` xry111 at gcc dot gnu.org
2023-12-17 11:24 ` cvs-commit at gcc dot gnu.org
2023-12-17 11:25 ` xry111 at gcc dot gnu.org

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).