From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B202C3858D28; Tue, 11 Apr 2023 10:42:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B202C3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681209771; bh=loMMdiNGOD1DBO+HEmt9mq6AnkAppRlhSi5xxYkp9R0=; h=From:To:Subject:Date:From; b=ARjDZxV+CZSyXIBVunuAGNdmwFzYLS84Ib42Q+ZzBMZ9iMb21aEkc3XyVGGPkYz55 fpn0C0QjJBcewgl2zs2vsWQ00c8szsUPLZHPNvhGB3knyj2sdauiwKHh8xKxsaxmJB PiqHN/5VBTQMLDfcbpDSPhS/bferKmU7VJXbyfd4= From: "stefano.d at posteo dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109471] New: Missing loop unrolling for small std::vector? Date: Tue, 11 Apr 2023 10:42:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: stefano.d at posteo dot de 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=3D109471 Bug ID: 109471 Summary: Missing loop unrolling for small std::vector? Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: stefano.d at posteo dot de Target Milestone: --- Hi, I did some benchmarks where I wanted to bench a switch-case statement again= st a small std::vector. In GCC 12.2 the result was as expected: The switch-case statement was faster than the linear search in std::vector. But when I swit= ched to clang 13 or above, the std::vector implementation was much faster than t= he switch-case statement! You can the results here: https://quick-bench.com/q/9DEDS7rQm0MnIFxwZt3A2iD86G0 Please switch here between GCC and clang. Here an assembly output: https://godbolt.org/z/j8oenP8x9 Kind regards Stefano=