From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8480C3858D1E; Fri, 30 Sep 2022 19:10:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8480C3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664565055; bh=D6nZ8603h7Wggy9am9kpoD6D9c4JcNrahGZyBbS7i2A=; h=From:To:Subject:Date:From; b=MYPDC5gvPBZqcbkE7qzpNQ5iL+hn/wcTxA2A59tiLWGtOyJwh7MpP1O7jx111JNqW /c1gzRv0B7B8U7U6/GGSWDgj9vIIFX0QfdnmmmFDKkirzRziYkvH/K5aQSffOjnuKY cK+u8dfAklfCjXI7p95Owzi81dnb1U3mb2vljwng= From: "vittorio.romeo at outlook dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107105] New: Consider folding `__and_`, `__or_`, and `__not_` at the front-end level Date: Fri, 30 Sep 2022 19:10:54 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vittorio.romeo at outlook 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=3D107105 Bug ID: 107105 Summary: Consider folding `__and_`, `__or_`, and `__not_` at the front-end level Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: vittorio.romeo at outlook dot com Target Milestone: --- This is another possible compilation speed improvement that came to mind af= ter running ClangBuildAnalyzer on a few open source projects (gzdoom, SFML, som= e of my own, ...) and noticing results like these: **** Template sets that took longest to instantiate: 35407 ms: std::__and_<$> (20262 times, avg 1 ms) 17745 ms: std::unique_ptr<$> (916 times, avg 19 ms) 14302 ms: std::__uniq_ptr_data<$> (916 times, avg 15 ms) 14153 ms: std::__uniq_ptr_impl<$> (916 times, avg 15 ms) 13537 ms: std::__or_<$> (15100 times, avg 0 ms) 13046 ms: std::basic_string<$> (2248 times, avg 5 ms) 11706 ms: std::_Hashtable<$> (1051 times, avg 11 ms) 10527 ms: std::unordered_map<$> (545 times, avg 19 ms) 10379 ms: std::is_convertible<$> (11737 times, avg 0 ms) It looks like `__and_`, `__or_`, and `__not_` are widely used throughout libstdc++'s implementation, and are used to implement most type traits.=20 I was wondering whether it would be possible and somewhat easy to fold thes= e in the front-end, similarly to what has been done for `std::move` and similar functions. Another option is to use a compiler intrinsic. I have not done any research, but I suppose that if this is possible, reduc= ing the number of instantiations of these small helpers would benefit pretty mu= ch every project using libstdc++. Just an idea -- feel free to close this tick= et if this is not possible or not worth the effort.=