From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9FE1B3858C36; Fri, 20 Jan 2023 22:20:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FE1B3858C36 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674253232; bh=CQtCqk3s9ikjlKtriU3BTJJUGIDJlOeNGtOAyzJND9o=; h=From:To:Subject:Date:From; b=P9X/ulhMMZuEkmmajUNWMAlOSwb8dMKJpEdLXX6QxgbZuLdQpGpdqlArUS75JSHl5 bwWlFlawhKHsVTJkGQtqC2cNsLWLKCe1pMks2DGuCZ0xzXWgcFP12W0ubiFuizp9s4 XH5Z01ikZvL+sZyjPKaT3x6T9Rl9yOG8/lwv00RY= From: "Mark_B53 at yahoo dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/108487] New: ~20-30x slowdown in populating std::vector from std::ranges::iota_view Date: Fri, 20 Jan 2023 22:20:32 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: Mark_B53 at yahoo dot com 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108487 Bug ID: 108487 Summary: ~20-30x slowdown in populating std::vector from std::ranges::iota_view Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: Mark_B53 at yahoo dot com Target Milestone: --- Using -std=3Dc++20 -O3, comparing gcc 12.2 vs. gcc 10.3: * fn2 is 20-30x slower on gcc 12.2 (i.e. 2000-3000% more)=20 * fn1 is ~20% slower on gcc 12.2=20 This test was run on an 52 core Intel Xeon Gold 6278C CPU. Tests on www.godbolt.org directionally align with these findings. It seems the slow= down was introduced in 10.4 & 11.1. The trunk has identical performance to 12.2. #include #include #include #include __attribute__((noinline)) std::vector fn1(int n) { auto v =3D std::vector(n); for(int i =3D 0; i !=3D n; ++i) v[i] =3D i; return v; } __attribute__((noinline)) std::vector fn2(int n) { auto rng =3D std::ranges::iota_view{0, n}; return std::vector{rng.begin(), rng.end()}; } int main() { int n =3D 100'000; int times =3D 100'000; auto t0 =3D std::clock(); for (int i =3D 0; i < times; ++i) fn1(n);=20=20=20=20=20=20=20=20=20=20=20=20 auto t1 =3D std::clock(); for (int i =3D 0; i < times; ++i) fn2(n);=20=20=20=20=20=20=20=20=20=20=20=20 auto t2 =3D std::clock(); std::cout << t1 - t0 << '\n'; std::cout << t2 - t1 << '\n'; return 0; } P.S. 20% slowdown for a common vector population is still significant IMO. = I am not sure that qualifies as a bug. I did not file one on account of the 'fn1' slowdown.=