public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97623] New: Extremely slow O2 compile (>>O(n^2))
@ 2020-10-29  2:02 wsnyder at wsnyder dot org
  2020-10-29  2:03 ` [Bug c++/97623] " wsnyder at wsnyder dot org
                   ` (25 more replies)
  0 siblings, 26 replies; 27+ messages in thread
From: wsnyder at wsnyder dot org @ 2020-10-29  2:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97623
           Summary: Extremely slow O2 compile (>>O(n^2))
           Product: gcc
           Version: 9.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wsnyder at wsnyder dot org
  Target Milestone: ---

Created attachment 49461
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49461&action=edit
slow.cpp

The attached program compiles very slowly with -O2.  It is fast with clang
(FWIW).

This is an shortened version of a routine taking > 10 minutes.

$ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

time g++ -O2 -c slow.cpp
 6.457  (average)
time g++ -Os -c slow.cpp
 0.236  (average)
time g++ -O2 -DNO_BOTTOM -c slow.cpp
 0.560  (average)
time g++ -O2 -DNO_TOP -c slow.cpp
 0.702  (average)
time g++ -O2 -DNO_FINAL -c slow.cpp
 6.271  (average)
time clang++ -O2 -c slow.cpp
 0.210  (average)

Note Os is much faster.  The defines remove the top half of the function, or
bottom half, note the time is crazy faster, one would expect the whole program
to be only slightly slower than the sum of these.  Removing a single statement
from the bottom (-DNO_FINAL) also makes an enormous 0.21 second difference, so
some algorithm is not scaling correctly.

Would greatly appreciate some indication of 1. a compiler flag to bypass the
bad optimization if possible, and 2. a hint as to what operator or how to avoid
this as this is generated code so there's some flexibility for a workaround.

Thanks.

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

end of thread, other threads:[~2022-05-27  8:56 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29  2:02 [Bug c++/97623] New: Extremely slow O2 compile (>>O(n^2)) wsnyder at wsnyder dot org
2020-10-29  2:03 ` [Bug c++/97623] " wsnyder at wsnyder dot org
2020-10-29  7:17 ` [Bug tree-optimization/97623] [9/10/11 Regression] " rguenth at gcc dot gnu.org
2020-10-29  7:18 ` rguenth at gcc dot gnu.org
2020-10-30 12:35 ` rguenth at gcc dot gnu.org
2020-10-30 12:35 ` rguenth at gcc dot gnu.org
2020-10-30 13:25 ` cvs-commit at gcc dot gnu.org
2020-10-30 13:28 ` rguenth at gcc dot gnu.org
2020-10-30 13:55 ` wsnyder at wsnyder dot org
2020-11-03 14:16 ` rguenth at gcc dot gnu.org
2020-11-03 15:23 ` cvs-commit at gcc dot gnu.org
2020-11-06  1:50 ` wsnyder at wsnyder dot org
2020-11-06  9:52 ` rguenther at suse dot de
2020-11-06 12:37 ` wsnyder at wsnyder dot org
2020-11-06 13:00 ` rguenth at gcc dot gnu.org
2020-11-06 13:19 ` marxin at gcc dot gnu.org
2020-11-06 13:28 ` rguenth at gcc dot gnu.org
2020-11-06 13:45 ` rguenth at gcc dot gnu.org
2020-11-11 11:51 ` cvs-commit at gcc dot gnu.org
2020-11-11 16:11 ` tschwinge at gcc dot gnu.org
2020-11-11 17:17 ` cvs-commit at gcc dot gnu.org
2020-12-07 13:03 ` [Bug tree-optimization/97623] [9/10 " rguenth at gcc dot gnu.org
2021-01-11 13:37 ` cvs-commit at gcc dot gnu.org
2021-01-11 13:37 ` cvs-commit at gcc dot gnu.org
2021-01-11 13:39 ` [Bug tree-optimization/97623] [9 " rguenth at gcc dot gnu.org
2021-06-01  8:18 ` rguenth at gcc dot gnu.org
2022-05-27  8:56 ` rguenth 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).