public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9
@ 2020-05-05 15:44 hehaochen at hotmail dot com
2020-05-05 16:42 ` [Bug c++/94957] " jakub at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: hehaochen at hotmail dot com @ 2020-05-05 15:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
Bug ID: 94957
Summary: Compilation slowww for simple code with -O1/2/3 and -g
in GCC 8 and 9
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hehaochen at hotmail dot com
Target Milestone: ---
code:
---------------------------------
class MyObject
{
public:
MyObject() {}
};
class MyClassSlow
{
MyObject array[30000] {};
};
int main()
{
MyClassSlow slow;
}
---------------------------------
run :
g++ -Ox -g -std=c++11 test.cpp
in
gcc-7 gcc-8 gcc-9 with -O1/2/3 -g
#############
##
## Hangs "forever"
## gcc version 9.2.0 (GCC)
##
#############
-O3
real 0m1.299s
user 0m0.910s
sys 0m0.197s
-O3 -g
Forever... (kill after 15min)
#############
##
## Hangs "forever"
## gcc version 8.2.0 (GCC)
##
#############
-O3
real 0m1.434s
user 0m1.062s
sys 0m0.229s
-O2 -g
Forever... (kill after 15min)
#############
##
## Acceptable but still slow in
## gcc version 7.4.0 (GCC)
##
#############
-O0 -g
real 0m 3.892s
user 0m 3.404s
sys 0m 0.482s
-O1 -g
real 1m 6.103s
user 1m 5.718s
sys 0m 0.302s
-O2 -g
real 1m 23.666s
user 1m 23.310s
sys 0m 0.280s
-O3
real 0m 1.451s
user 0m 1.229s
sys 0m 0.221s
-O3 -g
real 1m 19.463s
user 1m 19.037s
sys 0m 0.349s
Execution times (seconds)
phase opt and generate : 84.89 (99%) usr 1.88 (90%) sys 86.89 (99%) wall
139631 kB (65%) ggc
trivially dead code : 82.12 (96%) usr 0.00 ( 0%) sys 82.26 (94%) wall
0 kB ( 0%) ggc
#############
##
## OK in clang
##
#############
clang version 9.0.0-svn366056
root@c5c7aa8003d9:/downloads# time clang++-9 -O3 -g test.cpp
real 0m 0.176s
user 0m 0.103s
sys 0m 0.073s
root@c5c7aa8003d9:/downloads# time clang++-9 -O3 test.cpp
real 0m 0.165s
user 0m 0.102s
sys 0m 0.063s
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/94957] Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
@ 2020-05-05 16:42 ` jakub at gcc dot gnu.org
2020-05-06 7:00 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-05 16:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org,
| |jason at gcc dot gnu.org,
| |mpolacek at gcc dot gnu.org
Version|unknown |9.0
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Seems var-tracking, we end up with -O2 -g with main containing just debug
stmts,
# DEBUG BEGIN_STMT
# DEBUG thisD.212422 => NULL
# DEBUG thisD.212423 => NULL
# DEBUG thisD.212424 => NULL
...
# DEBUG thisD.242421 => NULL
# DEBUG thisD.212421 => NULL
return 0;
for those 30000 this pointers of the ctor, and var-tracking is quite slow on
that indeed.
Though, code-generation-wise, I think that for these larger arrays we shouldn't
emit
_1 = &this->array[0];
MyObject::MyObject (_1);
_2 = &this->array[1];
MyObject::MyObject (_2);
_3 = &this->array[2];
MyObject::MyObject (_3);
...
_29997 = &this->array[29996];
MyObject::MyObject (_29997);
_29998 = &this->array[29997];
MyObject::MyObject (_29998);
_29999 = &this->array[29998];
MyObject::MyObject (_29999);
_30000 = &this->array[29999];
MyObject::MyObject (_30000);
but instead just a loop over the array elts initializing them, because e.g. if
everything doesn't get inlined, it will be much shorter.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/94957] Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
2020-05-05 16:42 ` [Bug c++/94957] " jakub at gcc dot gnu.org
@ 2020-05-06 7:00 ` rguenth at gcc dot gnu.org
2020-05-06 7:15 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-05-06 7:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Plenty of dups for this in bugzilla - but FE folks never get that idea of using
a loop ...
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/94957] Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
2020-05-05 16:42 ` [Bug c++/94957] " jakub at gcc dot gnu.org
2020-05-06 7:00 ` rguenth at gcc dot gnu.org
@ 2020-05-06 7:15 ` jakub at gcc dot gnu.org
2020-05-07 13:44 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-05-06 7:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Some of it changed recently, e.g. when the FEs use ARRAY_RANGE_REFs in the
initializer the gimplifier's gimplify_init_ctor_eval emits a loop.
But in this case I think we need the FE to emit the loop itself.
Marek, would you like to have a look?
I'd use serial code if the array doesn't have too many elts (perhaps compare to
a param, or hardcode something small like 16).
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/94957] Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
` (2 preceding siblings ...)
2020-05-06 7:15 ` jakub at gcc dot gnu.org
@ 2020-05-07 13:44 ` mpolacek at gcc dot gnu.org
2021-11-25 23:51 ` pinskia at gcc dot gnu.org
2021-11-25 23:52 ` [Bug c++/94957] Compilation slowww for simple code with big array of structs with constructors pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-05-07 13:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
Last reconfirmed| |2020-05-07
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I'll try to play with this in GCC 11.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/94957] Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
` (3 preceding siblings ...)
2020-05-07 13:44 ` mpolacek at gcc dot gnu.org
@ 2021-11-25 23:51 ` pinskia at gcc dot gnu.org
2021-11-25 23:52 ` [Bug c++/94957] Compilation slowww for simple code with big array of structs with constructors pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-25 23:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ilord.tiran at yandex dot ru
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 98547 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/94957] Compilation slowww for simple code with big array of structs with constructors
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
` (4 preceding siblings ...)
2021-11-25 23:51 ` pinskia at gcc dot gnu.org
@ 2021-11-25 23:52 ` pinskia at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-11-25 23:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94957
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 92385.
*** This bug has been marked as a duplicate of bug 92385 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-11-25 23:52 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-05 15:44 [Bug c++/94957] New: Compilation slowww for simple code with -O1/2/3 and -g in GCC 8 and 9 hehaochen at hotmail dot com
2020-05-05 16:42 ` [Bug c++/94957] " jakub at gcc dot gnu.org
2020-05-06 7:00 ` rguenth at gcc dot gnu.org
2020-05-06 7:15 ` jakub at gcc dot gnu.org
2020-05-07 13:44 ` mpolacek at gcc dot gnu.org
2021-11-25 23:51 ` pinskia at gcc dot gnu.org
2021-11-25 23:52 ` [Bug c++/94957] Compilation slowww for simple code with big array of structs with constructors 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).