From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vs1-xe2f.google.com (mail-vs1-xe2f.google.com [IPv6:2607:f8b0:4864:20::e2f]) by sourceware.org (Postfix) with ESMTPS id AEA033858C2C for ; Thu, 7 Dec 2023 03:21:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AEA033858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=cs.washington.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.washington.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AEA033858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::e2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701919265; cv=none; b=uu8VgwC9IkJVwFDShqQexGIfd3UQ8U5J51XPrywXZy2+WJvUwKZZ/gY+JgQJJ09UftaDKzPWKqlGk3Ybv7V29agcZn5gth5PHtxt54mgwid2Ptn9fz6pYh4G2f/ovzWth3luW4pLGwMdL1o9mKvz0+bQmdX4oeue36Mx0g5Famc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701919265; c=relaxed/simple; bh=K9auss3kM3fZt0ZUyL7Yq5SYm8vMUjFRZolX725+dcU=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=PFPFjNp1P0Q4qXoz165pUABmE+OOWqW2q/FCxnC7ciH0e7q9NU/1KAf1ed+4BecYivBsCS1Th4sIXwI7YIfWreak7TBuz9LgKAIcdkS7cvBJXvZui9YB3XQgdBojg/B+Vpp7LEgAP21xnJ+b8T3lnYfGgExFfujTQJE5kDAIdbE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-vs1-xe2f.google.com with SMTP id ada2fe7eead31-464964d59b7so66593137.3 for ; Wed, 06 Dec 2023 19:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cs.washington.edu; s=goo201206; t=1701919259; x=1702524059; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=rcz3YaJqWswVsjw+933HoEv4QMNmrlK/r+aVLrA2Jmk=; b=B/+8nyeihTmGynTuJwEkxuZRGJySfyepY74Hav4MAzO6tXNwfFDyLQ4QllOG24Ki+r CHp0zdmF2x4fBts+XJiv7A7Lc6BS5MqXc48Jvq+T4L9jw8HlQSPPjuMmbXyAkjivGVe3 wVX2Gp9VdeKokyjrrg7/fRFuSScfJXaW4RaZA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701919259; x=1702524059; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rcz3YaJqWswVsjw+933HoEv4QMNmrlK/r+aVLrA2Jmk=; b=mu1NNn6ZinJB/zdB6/yu4ynj0d+0R/ykScLPYF4ZoZ/maKWTHhGbhkWUrozBt8h9MB Ybv/KFeZfjU77fgUcPmMpnvVPygUl/o/kark0H2Zsvs5wrZ58UcU9Tw/k44Cj8/s67wG gUiP0mHyWrxZzZ5mW0HjFWvelP+wdwidZKXR74crLoU6qoUQ2rA26IO8fbTexGCyDX6F fVeVZVIx22+GecuT3yhn3Hz6O9nlg6mtlitKyge74QwpZvbdL/IkK/2kiMFRSN0cbkvo S7CsxZ7ZbBJJ/vS96CLKIHSirMMxNlbMHO+/oQ9UAiq6zQhH1s0wj12MNGSYJW+v4gHp u01A== X-Gm-Message-State: AOJu0Yyom8vKT17siiWZEPFnYYRdMeEvJ34TevfSWkJRm3ZEj9K9DIeq QvbsSmpZG5p6btyT36eQ0C91iifTYZP8DHS5ZT6W9Q== X-Google-Smtp-Source: AGHT+IGJLRkLP+/Kr+Vsh1ZMgzQJQSqswcHzN6BPD3n8ipTwr7p/Q+5CzoZs4rJcVfFIGNhv8CzWQESnOUil7/os0Fo= X-Received: by 2002:a67:ee1a:0:b0:464:9e34:e452 with SMTP id f26-20020a67ee1a000000b004649e34e452mr1824716vsp.2.1701919259709; Wed, 06 Dec 2023 19:20:59 -0800 (PST) MIME-Version: 1.0 References: <20231020162115.2307797-1-kmatsui@gcc.gnu.org> <20231024020424.699427-1-kmatsui@gcc.gnu.org> <20231024020424.699427-26-kmatsui@gcc.gnu.org> In-Reply-To: From: Ken Matsui Date: Wed, 6 Dec 2023 19:20:24 -0800 Message-ID: Subject: Re: [PATCH v25 25/33] libstdc++: Optimize std::is_function compilation performance To: Jonathan Wakely Cc: Ken Matsui , gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Oct 24, 2023 at 4:02=E2=80=AFAM Jonathan Wakely wrote: > > > > On Tue, 24 Oct 2023 at 03:16, Ken Matsui wrote: >> >> This patch optimizes the compilation performance of std::is_function >> by dispatching to the new __is_function built-in trait. >> >> libstdc++-v3/ChangeLog: >> >> * include/std/type_traits (is_function): Use __is_function >> built-in trait. >> (is_function_v): Likewise. Optimize its implementation. >> (is_const_v): Move on top of is_function_v as is_function_v now >> depends on is_const_v. > > > I think I'd prefer to keep is_const_v where it is now, adjacent to is_vol= atile_v, and move is_function_v after those. > > i.e. like this (but with the additional changes to use the new built-in): > > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -3198,8 +3198,8 @@ template > inline constexpr bool is_union_v =3D __is_union(_Tp); > template > inline constexpr bool is_class_v =3D __is_class(_Tp); > -template > - inline constexpr bool is_function_v =3D is_function<_Tp>::value; > +// is_function_v is defined below, after is_const_v. > + > template > inline constexpr bool is_reference_v =3D false; > template > @@ -3226,6 +3226,8 @@ template > inline constexpr bool is_volatile_v =3D false; > template > inline constexpr bool is_volatile_v =3D true; > +template > + inline constexpr bool is_function_v =3D is_function<_Tp>::value; > > template > inline constexpr bool is_trivial_v =3D __is_trivial(_Tp); > > The variable templates are currently defined in the order shown in the st= andard, in te [meta.type.synop] synopsis, and in the [meta.unary.cat] table= . So let's move _is_function_v later and add a comment saying why it's not = in the expected place. > > Sorry for missing this. Thank you for your review! That totally makes sense, and I will update my patches accordingly.