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.133.124]) by sourceware.org (Postfix) with ESMTPS id 7916F3858291 for ; Tue, 8 Aug 2023 20:09:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7916F3858291 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=1691525363; 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=EmgPWUHzWcSRHBhbyRrReSTgzlI0yfBPEGa6AdIzBCA=; b=AfaOsBpCCl6Xo7XV0Pz5M6hZz0GHoKb9ERzXi3LYNDmWKpjpItKspFbTh4TGHbsKwXmDrU KtoL7r0Uo0x0OeIp0a2kZ/IDl8hlIroxxPR+Agge4zzvyICqlgLOWUqKth9eBgBAYXNKDi WMInLMaUHZuYECdjRYnUY8Xnr+RgrWo= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-MTordlW1OiSSalVvOiWo4Q-1; Tue, 08 Aug 2023 16:09:20 -0400 X-MC-Unique: MTordlW1OiSSalVvOiWo4Q-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2b9b00a80e9so59100361fa.1 for ; Tue, 08 Aug 2023 13:09:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691525358; x=1692130158; 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=EmgPWUHzWcSRHBhbyRrReSTgzlI0yfBPEGa6AdIzBCA=; b=RVBu7BThlfYSMrassf/+gNS3WPXPUlgN6EluUl3JXiO2TR6dxxNewzz5nFqHEbsXI1 6SVXz5HCU5ChJSJQn/if5shSRZmGKsscSmszw9bqmn6la2U3M7UvFfEBpvfeNbWdQMyN kbrtdQG/2qfvqGCjQZOLh/yBjjtQmkMyEpEF+/SzzLqes/tg+MDBRyzpWycr519FezN9 fBbysG34tOXtEq6xKO0iqE5/Y5bU5+5ddlhOShFHW0Gjg2DU+wMNzDCtHefL+t4MMOeI lXSZs83MpvuZNxkO6BXPe6tod4uAaNWGw2b7ULFJVrphjf8ULOatpAu0n/+PYur20g+B l50A== X-Gm-Message-State: AOJu0YyjutFzOo+ncpJ25CMMUCsXWDNNkBM6ueNoLdv2jQNxvCv9LgRc q/lU3Ge4gfPzc1XpJYpldChR9o7+1ABdQIej3IUZ+UKBe4f9OHx7MbZWe5lMHriQG2n1K9saLJa ko+0hwEyjPJ6p+pj1eWal7Pm4X4xyuqhN77gB81/Ppg== X-Received: by 2002:a2e:98c9:0:b0:2b6:f21a:3dae with SMTP id s9-20020a2e98c9000000b002b6f21a3daemr395198ljj.44.1691525358647; Tue, 08 Aug 2023 13:09:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsKagQqWfhRXQxCOeepkXOZwu2o82n6j5D1lNX4nSykwFt3nq3R7Pq8WQkrG8DQqxHZKCbcpTVX1Dq02MBxzA= X-Received: by 2002:a2e:98c9:0:b0:2b6:f21a:3dae with SMTP id s9-20020a2e98c9000000b002b6f21a3daemr395190ljj.44.1691525358369; Tue, 08 Aug 2023 13:09:18 -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: <20230715045519.50684-2-kmatsui@gcc.gnu.org> From: Jonathan Wakely Date: Tue, 8 Aug 2023 21:09:07 +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="0000000000001d559c06026ef0ba" X-Spam-Status: No, score=-12.0 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=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000001d559c06026ef0ba Content-Type: text/plain; charset="UTF-8" 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). > --- > 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 > > --0000000000001d559c06026ef0ba--