From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 323063858CDB for ; Tue, 24 Oct 2023 11:02:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 323063858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 323063858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698145333; cv=none; b=wx1BmlFmQLWEdOVm0tRxxu6LttnJ00nmBN+Oi2cy/CacmxAcmyBIobdxQOfaT+FhrHznr7Fa93LzkSQcmah9xHeC0X8LhyNY5nwFoGV9XQ57RBVMjsS6RGLh6a0stFeJ6AvRkk2OyQKYEM2OVk2CKnNCU1ZkpuswveTsE/pMecs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698145333; c=relaxed/simple; bh=UJPFH3n2hklprwF4bdH2FFC/hB7YUA9ghirBPO53WOY=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=M0F2mqee6Apt6BE/3Z+nay47UBD0ZIGMFng6RHQATOAznwC0SL8Cj1Nia5Oa8IEvFhE3KOwy9TpFEMCJnDklMyIs9jj9g/Pr/H9W0xHG2eCwXJMcClpTDM4UVy9oxcOlqyI9Na1d8LP/yC5NeBDtwMJWHrh58XsYcJEhwHd963s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698145327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Sfw9o9mBh25TkoXLsqlLeCFh43pTMN9MSG4oX402pps=; b=YBLeUscCsljhEzR8E4f0CQAldhVUXFmCFX9CvauH3PAnSTvapsCjPihZ9Y3LPNztmt5C1T ZYeR6wS0EqXPVTlSWcOYwlZOt3kQsNvqdVMtCj7NgMM+fJgo5UWratPzQV9qrnaBEujOzJ AnnOeLzFw/kS4+EE2AaiFIxyEJtMbLk= Received: from mail-yw1-f198.google.com (mail-yw1-f198.google.com [209.85.128.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-199-nQiEDI6iPVCm2mj4wCEcNw-1; Tue, 24 Oct 2023 07:02:06 -0400 X-MC-Unique: nQiEDI6iPVCm2mj4wCEcNw-1 Received: by mail-yw1-f198.google.com with SMTP id 00721157ae682-5a8ead739c3so57680147b3.3 for ; Tue, 24 Oct 2023 04:02:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698145325; x=1698750125; h=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=Sfw9o9mBh25TkoXLsqlLeCFh43pTMN9MSG4oX402pps=; b=JZruuJ5YCQGiWea8iJdhKnf33xAwSVLRrqETIvZSiJXzFRJv8YjKe6UTq3mHGYpuTm zQ4PGaL658vGvwLsux0vJcJ4rNwqMQ+U74cXL4ork+/3rVhEGRIsRAvIxgUmzKG4T/dC JcZdetbLDKH9xKvzfJF8N9hu9Em/fJOtqEOLMUegc3ZO3Nj/S2daQh5m30A54JGB/PKi 3A2lb/78ZE7eGCCw/Z+olAcLdPh43c1uZrcamDwPsvvDpXR0yIAQVmS5Mo2DzZJDZfMK gHUAeG47IHXdDsiC8+k76yO8b3dEGX6NzbL4PXxOh9bNcRgTPIBEbk8db31U8ciAnCF1 x5Tg== X-Gm-Message-State: AOJu0YypiRPks12qrMSeyXT763762GEdgiKBfe3eoiGhG+BCFC+FNBgV vhvZXyrM7+UmEVBjA/nxcUzi7wyHIjus8GjE216g3bjL7237mCsAjvbaB1opphvNuz7PAqEKnpj 0bmIIdA01UmIcNDJkocDoO7O4KGgoe9QYPVn9cg6iSA== X-Received: by 2002:a05:690c:81:b0:5a8:dd5f:dbf with SMTP id be1-20020a05690c008100b005a8dd5f0dbfmr14004749ywb.34.1698145325227; Tue, 24 Oct 2023 04:02:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmQlCkzCdQiUFmQu1y6SHoGTHOq0ev2gXvNWM4HhL6jMft0CAYlvxYsJgq+AGjKn0kVDLWABCtgLBZrtqpoEk= X-Received: by 2002:a05:690c:81:b0:5a8:dd5f:dbf with SMTP id be1-20020a05690c008100b005a8dd5f0dbfmr14004728ywb.34.1698145324917; Tue, 24 Oct 2023 04:02:04 -0700 (PDT) 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: <20231024020424.699427-26-kmatsui@gcc.gnu.org> From: Jonathan Wakely Date: Tue, 24 Oct 2023 12:01:54 +0100 Message-ID: Subject: Re: [PATCH v25 25/33] libstdc++: Optimize std::is_function compilation performance To: Ken Matsui Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/alternative; boundary="000000000000de7ef106087444b6" X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP 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: --000000000000de7ef106087444b6 Content-Type: text/plain; charset="UTF-8" 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_volatile_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 = __is_union(_Tp); template inline constexpr bool is_class_v = __is_class(_Tp); -template - inline constexpr bool is_function_v = is_function<_Tp>::value; +// is_function_v is defined below, after is_const_v. + template inline constexpr bool is_reference_v = false; template @@ -3226,6 +3226,8 @@ template inline constexpr bool is_volatile_v = false; template inline constexpr bool is_volatile_v = true; +template + inline constexpr bool is_function_v = is_function<_Tp>::value; template inline constexpr bool is_trivial_v = __is_trivial(_Tp); The variable templates are currently defined in the order shown in the standard, 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. --000000000000de7ef106087444b6--