From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1E4953857809; Fri, 7 May 2021 06:17:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E4953857809 From: "xry111 at mengyan1223 dot wang" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/100466] New: compilation of assignment from initialization list to std::array with non-trivial constructor of T is very slow Date: Fri, 07 May 2021 06:17:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 11.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xry111 at mengyan1223 dot wang X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 May 2021 06:17:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100466 Bug ID: 100466 Summary: compilation of assignment from initialization list to std::array 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 struct t { int a; t() : a(0) {} }; std::array g; int main() { g =3D {}; } $ for i in 10 100 1000 10000 100000; do > time g++ t.cc -DX=3D$i > done g++ t.cc -DX=3D$i 0.74s user 0.06s system 99% cpu 0.798 total g++ t.cc -DX=3D$i 0.74s user 0.05s system 99% cpu 0.794 total g++ t.cc -DX=3D$i 0.78s user 0.06s system 99% cpu 0.833 total g++ t.cc -DX=3D$i 1.08s user 0.08s system 99% cpu 1.167 total g++ t.cc -DX=3D$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=3D$i -O2 > done g++ t.cc -DX=3D$i -O2 0.07s user 0.01s system 99% cpu 0.089 total g++ t.cc -DX=3D$i -O2 0.08s user 0.01s system 99% cpu 0.087 total g++ t.cc -DX=3D$i -O2 0.49s user 0.01s system 99% cpu 0.503 total g++ t.cc -DX=3D$i -O2 6.34s user 0.03s system 99% cpu 6.376 total g++ t.cc -DX=3D$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 401047: 00 00 00 00=20 40104b: 31 c0 xor %eax,%eax 40104d: 48 c7 05 90 aa 0e 00 movq $0x0,0xeaa90(%rip) # 4ebae8 401054: 00 00 00 00=20 401058: 48 c7 05 8d aa 0e 00 movq $0x0,0xeaa8d(%rip) # 4ebaf0 40105f: 00 00 00 00=20 401063: 48 c7 05 8a aa 0e 00 movq $0x0,0xeaa8a(%rip) # 4ebaf8 40106a: 00 00 00 00=20 ... ... 4874a7: 48 c7 05 a6 60 0c 00 movq $0x0,0xc60a6(%rip) # 54d558 4874ae: 00 00 00 00=