public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
@ 2020-08-17 16:33 ` pinskia at gcc dot gnu.org
  2020-08-17 19:06 ` slyfox at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-17 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikulas at artax dot karlin.mff.cu
                   |                            |ni.cz

--- Comment #13 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 96649 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
  2020-08-17 16:33 ` [Bug middle-end/87256] hppa spends huge amount of time in synth_mult() pinskia at gcc dot gnu.org
@ 2020-08-17 19:06 ` slyfox at gcc dot gnu.org
  2020-08-25 18:03 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: slyfox at gcc dot gnu.org @ 2020-08-17 19:06 UTC (permalink / raw)
  To: gcc-bugs

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

Sergei Trofimovich <slyfox at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |slyfox at gcc dot gnu.org

--- Comment #14 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Created attachment 49069
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49069&action=edit
hack-25_all_hppa-faster-synth_mult.patch

For those who need to be unblocked right now Gentoo uses the following hack:
hack-25_all_hppa-faster-synth_mult.patch

I'll ask around in #gcc on how to convert it to proper gcc-friendly hash table
based solution discussed above.

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
  2020-08-17 16:33 ` [Bug middle-end/87256] hppa spends huge amount of time in synth_mult() pinskia at gcc dot gnu.org
  2020-08-17 19:06 ` slyfox at gcc dot gnu.org
@ 2020-08-25 18:03 ` cvs-commit at gcc dot gnu.org
  2020-08-26  6:24 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-25 18:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:050fc8b27a852007f8bb667999e1c8cfd31f90e1

commit r11-2851-g050fc8b27a852007f8bb667999e1c8cfd31f90e1
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Tue Aug 25 19:02:45 2020 +0100

    hppa: PR middle-end/87256: Improved hppa_rtx_costs avoids synth_mult
madness.

    This is my proposed fix to PR middle-end/87256 where synth_mult takes an
    unreasonable amount of CPU time determining an optimal sequence of
    instructions to perform multiplication by (large) integer constants on
hppa.
    One workaround proposed in bugzilla, is to increase the hash table used
    to cache/reuse intermediate results. This helps but is a workaround for
    the (hidden) underlying problem.

    The real issue is that the hppa_rtx_costs function is providing wildly
    inaccurate values (estimates) to the middle-end.  For example, (p*q)+(r*s)
    would appear to be cheaper than a single multiplication.  Another
    example is that "(ashiftrt:di regA regB)" is claimed to be only be
    COST_N_INSNS(1) when in fact the hppa backend actually generates
    slightly more than a single instruction.

    It turns out that simply tightening up the logic in hppa_rtx_costs to
    return more reasonable values, dramatically reduces the number of recursive
    invocations in synth_mult for the test case in PR87256, and presumably
    also produces faster code (that should be observable in benchmarks).

    2020-08-25  Roger Sayle  <roger@nextmovesoftware.com>

    gcc/ChangeLog
            PR middle-end/87256
            * config/pa/pa.c (hppa_rtx_costs_shadd_p): New helper function
            to check for coefficients supported by shNadd and shladd,l.
            (hppa_rtx_costs):  Rewrite to avoid using estimates based upon
            FACTOR and enable recursing deeper into RTL expressions.

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2020-08-25 18:03 ` cvs-commit at gcc dot gnu.org
@ 2020-08-26  6:24 ` cvs-commit at gcc dot gnu.org
  2020-08-26  6:38 ` roger at nextmovesoftware dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-08-26  6:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Roger Sayle <sayle@gcc.gnu.org>:

https://gcc.gnu.org/g:ed1e7a6a8ad6903ee952e82ac9ddac01efb286dd

commit r10-8674-ged1e7a6a8ad6903ee952e82ac9ddac01efb286dd
Author: Roger Sayle <roger@nextmovesoftware.com>
Date:   Wed Aug 26 07:21:08 2020 +0100

    hppa: PR middle-end/87256: Improved hppa_rtx_costs avoids synth_mult
madness.

    Backport from master:

    2020-08-26  Roger Sayle  <roger@nextmovesoftware.com>

    gcc/ChangeLog
            PR middle-end/87256
            * config/pa/pa.c (hppa_rtx_costs_shadd_p): New helper function
            to check for coefficients supported by shNadd and shladd,l.
            (hppa_rtx_costs):  Rewrite to avoid using estimates based upon
            FACTOR and enable recursing deeper into RTL expressions.
            * config/pa/pa.md (shd_internal): Fix define_expand to provide
            gen_shd_internal.

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2020-08-26  6:24 ` cvs-commit at gcc dot gnu.org
@ 2020-08-26  6:38 ` roger at nextmovesoftware dot com
  2020-08-29 20:58 ` slyfox at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 8+ messages in thread
From: roger at nextmovesoftware dot com @ 2020-08-26  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

Roger Sayle <roger at nextmovesoftware dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
                 CC|                            |roger at nextmovesoftware dot com
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |10.0

--- Comment #17 from Roger Sayle <roger at nextmovesoftware dot com> ---
Fixed on mainline and the gcc-10 branch.

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2020-08-26  6:38 ` roger at nextmovesoftware dot com
@ 2020-08-29 20:58 ` slyfox at gcc dot gnu.org
  2020-09-06 14:15 ` danglin at gcc dot gnu.org
  2022-01-09  0:36 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: slyfox at gcc dot gnu.org @ 2020-08-29 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #18 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Thank you!

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2020-08-29 20:58 ` slyfox at gcc dot gnu.org
@ 2020-09-06 14:15 ` danglin at gcc dot gnu.org
  2022-01-09  0:36 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2020-09-06 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

John David Anglin <danglin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---
             Target|hppa-*                      |hppa*-*

--- Comment #19 from John David Anglin <danglin at gcc dot gnu.org> ---
hppa64 compiler is still slow:

$ hppa64-linux-gnu-gcc -S -O2 hog.c
hog.c: In function 'b':
hog.c:18:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL;
               ^~~~~~~~~~~~~~~~~~~~~
hog.c:19:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL;
               ^~~~~~~~~~~~~~~~~~~~~
hog.c:20:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL; /* this line adds 2 seconds: 7->9 */
               ^~~~~~~~~~~~~~~~~~~~~
hog.c:21:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL; /* this line adds 2 seconds: 9->11 */
               ^~~~~~~~~~~~~~~~~~~~~
dave@mx3210:~/gnu/gcc$ time hppa64-linux-gnu-gcc -S -O2 hog.c
hog.c: In function 'b':
hog.c:18:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL;
               ^~~~~~~~~~~~~~~~~~~~~
hog.c:19:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL;
               ^~~~~~~~~~~~~~~~~~~~~
hog.c:20:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL; /* this line adds 2 seconds: 7->9 */
               ^~~~~~~~~~~~~~~~~~~~~
hog.c:21:15: warning: integer constant is so large that it is unsigned
       c = c * 9650029242287828579LL; /* this line adds 2 seconds: 9->11 */
               ^~~~~~~~~~~~~~~~~~~~~

real    1m48.311s
user    1m47.665s
sys     0m0.471s

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

* [Bug middle-end/87256] hppa spends huge amount of time in synth_mult()
       [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2020-09-06 14:15 ` danglin at gcc dot gnu.org
@ 2022-01-09  0:36 ` pinskia at gcc dot gnu.org
  7 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-09  0:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.0                        |---

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

end of thread, other threads:[~2022-01-09  0:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-87256-4@http.gcc.gnu.org/bugzilla/>
2020-08-17 16:33 ` [Bug middle-end/87256] hppa spends huge amount of time in synth_mult() pinskia at gcc dot gnu.org
2020-08-17 19:06 ` slyfox at gcc dot gnu.org
2020-08-25 18:03 ` cvs-commit at gcc dot gnu.org
2020-08-26  6:24 ` cvs-commit at gcc dot gnu.org
2020-08-26  6:38 ` roger at nextmovesoftware dot com
2020-08-29 20:58 ` slyfox at gcc dot gnu.org
2020-09-06 14:15 ` danglin at gcc dot gnu.org
2022-01-09  0:36 ` pinskia 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).