public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow
@ 2021-05-07 6:17 xry111 at mengyan1223 dot wang
2021-05-07 6:21 ` [Bug libstdc++/100466] " xry111 at mengyan1223 dot wang
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-05-07 6:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100466
Bug ID: 100466
Summary: compilation of assignment from initialization list to
std::array<T, N> with non-trivial constructor of T is
very slow
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: xry111 at mengyan1223 dot wang
Target Milestone: ---
Code:
#include <array>
struct t
{
int a;
t() : a(0) {}
};
std::array<t, X> g;
int main()
{
g = {};
}
$ for i in 10 100 1000 10000 100000; do
> time g++ t.cc -DX=$i
> done
g++ t.cc -DX=$i 0.74s user 0.06s system 99% cpu 0.798 total
g++ t.cc -DX=$i 0.74s user 0.05s system 99% cpu 0.794 total
g++ t.cc -DX=$i 0.78s user 0.06s system 99% cpu 0.833 total
g++ t.cc -DX=$i 1.08s user 0.08s system 99% cpu 1.167 total
g++ t.cc -DX=$i 4.55s user 0.25s system 99% cpu 4.809 total
With -O2, it's much worse:
$ for i in 10 100 1000 10000 100000; do
> time g++ t.cc -DX=$i -O2
> done
g++ t.cc -DX=$i -O2 0.07s user 0.01s system 99% cpu 0.089 total
g++ t.cc -DX=$i -O2 0.08s user 0.01s system 99% cpu 0.087 total
g++ t.cc -DX=$i -O2 0.49s user 0.01s system 99% cpu 0.503 total
g++ t.cc -DX=$i -O2 6.34s user 0.03s system 99% cpu 6.376 total
g++ t.cc -DX=$i -O2 68.91s user 0.18s system 99% cpu 1:09.09 total
And the resulted code seems "unrolling a loop" too excessively:
401040: 48 c7 05 95 aa 0e 00 movq $0x0,0xeaa95(%rip) #
4ebae0 <g>
401047: 00 00 00 00
40104b: 31 c0 xor %eax,%eax
40104d: 48 c7 05 90 aa 0e 00 movq $0x0,0xeaa90(%rip) #
4ebae8 <g+0x8>
401054: 00 00 00 00
401058: 48 c7 05 8d aa 0e 00 movq $0x0,0xeaa8d(%rip) #
4ebaf0 <g+0x10>
40105f: 00 00 00 00
401063: 48 c7 05 8a aa 0e 00 movq $0x0,0xeaa8a(%rip) #
4ebaf8 <g+0x18>
40106a: 00 00 00 00
... ...
4874a7: 48 c7 05 a6 60 0c 00 movq $0x0,0xc60a6(%rip) #
54d558 <g+0x61a78>
4874ae: 00 00 00 00
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100466] compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow
2021-05-07 6:17 [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow xry111 at mengyan1223 dot wang
@ 2021-05-07 6:21 ` xry111 at mengyan1223 dot wang
2021-05-07 6:56 ` xry111 at mengyan1223 dot wang
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-05-07 6:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100466
--- Comment #1 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
clang-12 handles this correctly.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100466] compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow
2021-05-07 6:17 [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow xry111 at mengyan1223 dot wang
2021-05-07 6:21 ` [Bug libstdc++/100466] " xry111 at mengyan1223 dot wang
@ 2021-05-07 6:56 ` xry111 at mengyan1223 dot wang
2021-05-07 7:24 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-05-07 6:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100466
Xi Ruoyao <xry111 at mengyan1223 dot wang> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|11.1.0 |12.0
Known to fail| |10.3.0, 11.1.0, 12.0,
| |8.3.0, 9.3.0
--- Comment #2 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
Updated version, based on the test result on godbolt.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/100466] compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow
2021-05-07 6:17 [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow xry111 at mengyan1223 dot wang
2021-05-07 6:21 ` [Bug libstdc++/100466] " xry111 at mengyan1223 dot wang
2021-05-07 6:56 ` xry111 at mengyan1223 dot wang
@ 2021-05-07 7:24 ` rguenth at gcc dot gnu.org
2021-05-07 7:33 ` [Bug c++/100466] compilation of assignment from initialization list to an object with array member T[N] and " xry111 at mengyan1223 dot wang
2021-05-07 7:38 ` xry111 at mengyan1223 dot wang
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-05-07 7:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100466
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |compile-time-hog
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think that's an old known C++ FE issue which should emit a loop for inits
instead of repeating assignments for each element.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100466] compilation of assignment from initialization list to an object with array member T[N] and non-trivial constructor of T is very slow
2021-05-07 6:17 [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow xry111 at mengyan1223 dot wang
` (2 preceding siblings ...)
2021-05-07 7:24 ` rguenth at gcc dot gnu.org
@ 2021-05-07 7:33 ` xry111 at mengyan1223 dot wang
2021-05-07 7:38 ` xry111 at mengyan1223 dot wang
4 siblings, 0 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-05-07 7:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100466
Xi Ruoyao <xry111 at mengyan1223 dot wang> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|libstdc++ |c++
Summary|compilation of assignment |compilation of assignment
|from initialization list to |from initialization list to
|std::array<T, N> with |an object with array member
|non-trivial constructor of |T[N] and non-trivial
|T is very slow |constructor of T is very
| |slow
--- Comment #4 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
(In reply to Richard Biener from comment #3)
> I think that's an old known C++ FE issue which should emit a loop for inits
> instead of repeating assignments for each element.
Change summary and component then.
Is this a dup? I tried to search an existing PR but couldn't find it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/100466] compilation of assignment from initialization list to an object with array member T[N] and non-trivial constructor of T is very slow
2021-05-07 6:17 [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow xry111 at mengyan1223 dot wang
` (3 preceding siblings ...)
2021-05-07 7:33 ` [Bug c++/100466] compilation of assignment from initialization list to an object with array member T[N] and " xry111 at mengyan1223 dot wang
@ 2021-05-07 7:38 ` xry111 at mengyan1223 dot wang
4 siblings, 0 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-05-07 7:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100466
Xi Ruoyao <xry111 at mengyan1223 dot wang> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #5 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
Alright, there is PR77443 and PR84281. But the "fix" to PR84281 only fixed the
memory issue, the compile time is still too excessive.
I'll mark it as a dup of PR77443.
*** This bug has been marked as a duplicate of bug 77443 ***
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-05-07 7:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-07 6:17 [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array<T, N> with non-trivial constructor of T is very slow xry111 at mengyan1223 dot wang
2021-05-07 6:21 ` [Bug libstdc++/100466] " xry111 at mengyan1223 dot wang
2021-05-07 6:56 ` xry111 at mengyan1223 dot wang
2021-05-07 7:24 ` rguenth at gcc dot gnu.org
2021-05-07 7:33 ` [Bug c++/100466] compilation of assignment from initialization list to an object with array member T[N] and " xry111 at mengyan1223 dot wang
2021-05-07 7:38 ` xry111 at mengyan1223 dot wang
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).