From patchwork Thu Sep 8 18:31:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp383326wrt; Thu, 8 Sep 2022 11:33:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR7qKePdDz4z5SwIrrCyaQOzfCZk1pSuJkhdCmGF32+L46Mm5h3k5U0UzoOp9INGnyF8bzIz X-Received: by 2002:a17:907:2cd3:b0:741:550e:17ea with SMTP id hg19-20020a1709072cd300b00741550e17eamr6903828ejc.595.1662661997241; Thu, 08 Sep 2022 11:33:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662661997; cv=none; d=google.com; s=arc-20160816; b=s8aA5lL+P5JCOJM2u2L9Sx+7Bzv8kIrx+Fwm0xVgEEVLLxmIfK3izdYntvPeugNcEv EAW4CHIMVU4ID+bPr8ShGoOtiVqMvOUR7CWd0q4o/xSZ5pasQSVR/+X/3iwB8JvSNiUj hJakR3b4zkP4kirA+ElPk8lJVt5tHiKn6XKg+lEM5y92f13+Mm9cPafksniwGLLJSkDg QfH9vI9ZHU360ggB7GpqZk55DcygfyIHDRKFN3c+9RU9+91fAZ5SGd0bVZL/xXHXhsEW FSECa/VchfMV86V4WqkfH/AeHH3t5vrxOOFqN2MCuVA+gFUFnsBhrKR0wYOVUHq376uw 65fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=E27UHdSi429wbzzJGEueeZM/m8ZCNUMub2yOkXkvDhY=; b=ZHHmo4QL24FwSNbm4K18OjZphVLJOQRQAxFZ5rpelp41yu1v4gNZCGNBKRVAdHjVzW Gp/TPty3unfQHQoZFhzEmnpJ3aOrPFVCg1cFbq7IWbdkjHrdp2B/IyuEJDM1j+Ni4X6d 79pKlwgXvsqHDhVYbx9ykNdiBIXj4pVBdekDLNgkS0YKapJn5WOrCGhH4HlOXzVMLdma hizPmHQpgECvBWee/JAkMfLRPiYR/v8ZIHlbOfJiCwpH0jiboW0vCV8Slg+B4imfZw9j 8fV2e3bXCbytjT3SIkQVaykRwkPXou353GUiTMsZc0P387tklQAwR7kHViinmNfLTvs5 4F4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jzcwoAlB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l25-20020a170906415900b0076fa83bd1c3si2472639ejk.359.2022.09.08.11.33.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 11:33:17 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=jzcwoAlB; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 848E73857C67 for ; Thu, 8 Sep 2022 18:33:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 848E73857C67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662661989; bh=E27UHdSi429wbzzJGEueeZM/m8ZCNUMub2yOkXkvDhY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jzcwoAlBarQaZE3yx+Lp/g2kXtuJcQkEblxZI9s2fMEbCozPs53qjW1HfQwDAe2UL +Wc9Y3OnkPc1suufKlAmL/2NLPXMghUjzHmrxPmp13EIhjY0u3yBsRtAVHEGlulIqy a3R9TQS9mDWtkCoe+wBZC9ycVbGb24PQKnn3QzRQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 2506C3858C2D for ; Thu, 8 Sep 2022 18:31:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2506C3858C2D Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-484-v0I99CsqPZehV1kGdEZ4IA-1; Thu, 08 Sep 2022 14:31:51 -0400 X-MC-Unique: v0I99CsqPZehV1kGdEZ4IA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5BAF2185A7BA; Thu, 8 Sep 2022 18:31:51 +0000 (UTC) Received: from localhost (unknown [10.33.36.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2617B40334F; Thu, 8 Sep 2022 18:31:51 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Add always_inline attribute to std::byte operators Date: Thu, 8 Sep 2022 19:31:50 +0100 Message-Id: <20220908183150.3290641-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1743427466293255922?= X-GMAIL-MSGID: =?utf-8?q?1743427466293255922?= These are all trivial bit-twiddling operations that don't need the overhead of a function call in unoptimized code. Tested powerpc64le-linux, pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * include/c_global/cstddef (byte): Add always_inline attribute to all operator overloads. (to_integer): Add always_inline attribute. --- libstdc++-v3/include/c_global/cstddef | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef index 4970c2dfcfb..df2d88a2ce5 100644 --- a/libstdc++-v3/include/c_global/cstddef +++ b/libstdc++-v3/include/c_global/cstddef @@ -119,55 +119,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __byte_op_t = typename __byte_operand<_IntegerType>::__type; template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType> operator<<(byte __b, _IntegerType __shift) noexcept { return (byte)(unsigned char)((unsigned)__b << __shift); } template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType> operator>>(byte __b, _IntegerType __shift) noexcept { return (byte)(unsigned char)((unsigned)__b >> __shift); } + [[__gnu__::__always_inline__]] constexpr byte operator|(byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); } + [[__gnu__::__always_inline__]] constexpr byte operator&(byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); } + [[__gnu__::__always_inline__]] constexpr byte operator^(byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); } + [[__gnu__::__always_inline__]] constexpr byte operator~(byte __b) noexcept { return (byte)(unsigned char)~(unsigned)__b; } template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType>& operator<<=(byte& __b, _IntegerType __shift) noexcept { return __b = __b << __shift; } template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType>& operator>>=(byte& __b, _IntegerType __shift) noexcept { return __b = __b >> __shift; } + [[__gnu__::__always_inline__]] constexpr byte& operator|=(byte& __l, byte __r) noexcept { return __l = __l | __r; } + [[__gnu__::__always_inline__]] constexpr byte& operator&=(byte& __l, byte __r) noexcept { return __l = __l & __r; } + [[__gnu__::__always_inline__]] constexpr byte& operator^=(byte& __l, byte __r) noexcept { return __l = __l ^ __r; } template - [[nodiscard]] + [[nodiscard,__gnu__::__always_inline__]] constexpr _IntegerType to_integer(__byte_op_t<_IntegerType> __b) noexcept { return _IntegerType(__b); }