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 99FBF385770F for ; Tue, 8 Aug 2023 20:28:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 99FBF385770F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691526535; 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=N4dyyB4PpTfVhlIfwIYwaM2UldG0/pSp0pyld5M7zOo=; b=YB2gPDaak846yK0kKToXdmJW9rKBcVAYtq7Su5VL5IPrdVH2AuUAXhvoxHXAM0GWjVA3e4 9vmv7EUIBciXTq6XnxwDcEJPzzKu8xM2359+l01TTmNZ31W7b4sWAjxSIu9Z4r3DEIMy23 Cu7d1oGwJK/VfsM8xlgxnTkJ+AC9+0o= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-219-41aqQhymNqmd-LM78ZCOOQ-1; Tue, 08 Aug 2023 16:28:53 -0400 X-MC-Unique: 41aqQhymNqmd-LM78ZCOOQ-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2ba37b5519fso30634211fa.2 for ; Tue, 08 Aug 2023 13:28:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691526532; x=1692131332; 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=N4dyyB4PpTfVhlIfwIYwaM2UldG0/pSp0pyld5M7zOo=; b=Zi5LFjji/V28kjjplGdjO0HGxN1J8UnPkZXQoAOuHiSfA1/4ruOyTBhhnU5mOk6RT2 O7ygyqUb9zQWFIj4XTNqH5cyU1ZQzOjwpRzZmjp/JIKzn1vWIGXOAwP2aFR/qD7w7saZ EXKfhvko3jWBJTVtk3cQfb3agIM9mnN3rTuq1qh3QrhsxyeFwCrQuSJdZenFaQ99+trf yVXsVWY337xgTm1Ek5uqP3LFpEubZJ/BJl4nU5HQdKgFBkvvmABhb/z0K1aR2hYdnjL/ PnnO32pv3uKtqMryLvLS8jwBk4Jwj5UhH+RvsMw3rdTkM2H5mQzoByVZNKo5TQKkvnO6 9hgw== X-Gm-Message-State: AOJu0YxUI8WVHNtaJAts3H4HsQReT4z2eKMKwLE2fFzXAS8KdB/Hhm4B Fa38oiQDzkP9fUBV8T1BVfwpgnCN7vNrlcybtsX1ShSrMywj9cc/hWWlpXJ1ylLFx/ihpI0JMqm sIx68BYdkKPzPGJBWt3FWsyidg/TAyF46qnwBm/phlrLD X-Received: by 2002:a2e:964d:0:b0:2ba:18e5:1069 with SMTP id z13-20020a2e964d000000b002ba18e51069mr463990ljh.4.1691526532312; Tue, 08 Aug 2023 13:28:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGAkDbsY1nwTD2Zh5YML7T9J8GFkGcWoahvzdQqtqha/4H283u4efnRfKE59OJ7zp27n3OxlES32YQhJ5v7Pm4= X-Received: by 2002:a2e:964d:0:b0:2ba:18e5:1069 with SMTP id z13-20020a2e964d000000b002ba18e51069mr463983ljh.4.1691526532025; Tue, 08 Aug 2023 13:28:52 -0700 (PDT) MIME-Version: 1.0 References: <20230709125715.26884-1-kmatsui@gcc.gnu.org> <20230715045519.50684-1-kmatsui@gcc.gnu.org> <20230715045519.50684-2-kmatsui@gcc.gnu.org> In-Reply-To: From: Jonathan Wakely Date: Tue, 8 Aug 2023 21:28:40 +0100 Message-ID: Subject: Re: [PATCH v2 2/3] libstdc++: Optimize is_arithmetic performance by __is_arithmetic built-in 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="00000000000011ea5706026f3617" X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: --00000000000011ea5706026f3617 Content-Type: text/plain; charset="UTF-8" On Tue, 8 Aug 2023 at 21:09, Jonathan Wakely wrote: > > > On Sat, 15 Jul 2023 at 05:57, Ken Matsui via Libstdc++ < > libstdc++@gcc.gnu.org> wrote: > >> This patch optimizes the performance of the is_arithmetic trait by >> dispatching to the new __is_arithmetic built-in trait. >> >> libstdc++-v3/ChangeLog: >> >> * include/std/type_traits (is_arithmetic): Use __is_arithmetic >> built-in trait. >> (is_arithmetic_v): Likewise. >> >> Signed-off-by: Ken Matsui >> > > OK for trunk (if the front-end changes are approved). > Oh, this is the v2 patch and there's a v4 ... but I think they're the same. > > > > >> --- >> libstdc++-v3/include/std/type_traits | 14 ++++++++++++++ >> 1 file changed, 14 insertions(+) >> >> diff --git a/libstdc++-v3/include/std/type_traits >> b/libstdc++-v3/include/std/type_traits >> index 0e7a9c9c7f3..7ebbe04c77b 100644 >> --- a/libstdc++-v3/include/std/type_traits >> +++ b/libstdc++-v3/include/std/type_traits >> @@ -655,10 +655,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >> { }; >> >> /// is_arithmetic >> +#if __has_builtin(__is_arithmetic) >> + template >> + struct is_arithmetic >> + : public __bool_constant<__is_arithmetic(_Tp)> >> + { }; >> +#else >> template >> struct is_arithmetic >> : public __or_, is_floating_point<_Tp>>::type >> { }; >> +#endif >> >> /// is_fundamental >> template >> @@ -3198,8 +3205,15 @@ template >> inline constexpr bool is_reference_v<_Tp&> = true; >> template >> inline constexpr bool is_reference_v<_Tp&&> = true; >> + >> +#if __has_builtin(__is_arithmetic) >> +template >> + inline constexpr bool is_arithmetic_v = __is_arithmetic(_Tp); >> +#else >> template >> inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; >> +#endif >> + >> template >> inline constexpr bool is_fundamental_v = is_fundamental<_Tp>::value; >> template >> -- >> 2.41.0 >> >> --00000000000011ea5706026f3617--