220 35508 <3031585.uCQqKE2Qzv@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Rotational shift operator
Date: Fri, 24 Nov 2017 21:37:32 -0800
Lines: 40
Approved: news@gmane.org
Message-ID: <3031585.uCQqKE2Qzv@tjmaciei-mobl1>
References: <69593098-e2cc-487e-bd14-9001b27aa7c1@isocpp.org> <1527647.07Qi8WvUZa@tjmaciei-mobl1> <f3dafdfb-df6a-ac57-fdff-fba300c734d9@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1511588255 21238 195.159.176.226 (25 Nov 2017 05:37:35 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sat, 25 Nov 2017 05:37:35 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBH4D4TIAKGQE3R374EA@isocpp.org Sat Nov 25 06:37:31 2017
Return-path: <std-proposals+bncBCB4TK757YBRBH4D4TIAKGQE3R374EA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f200.google.com ([209.85.128.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBH4D4TIAKGQE3R374EA@isocpp.org>)
	id 1eIT9d-00053E-0F
	for gclcip-std-proposals@m.gmane.org; Sat, 25 Nov 2017 06:37:29 +0100
Original-Received: by mail-wr0-f200.google.com with SMTP id d14sf15022718wrg.15
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 Nov 2017 21:37:36 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1511588256; cv=pass;
        d=google.com; s=arc-20160816;
        b=X7LKXevdLG+w9CK5lpih/OgHDgVE20OWz0aLSMCUF+kKLiE1Q9z8MP3Qvai1KzhG2i
         5VUmpiZreWRFihmCFUCUCkP+sP3ollsZlIPtSUm4mFmVf2QWV1yBDFrR2HfntCtBlpox
         CDaPAH6ArnMxJLYLnR3eYbos1YjjZqA+AQZepFosj9A7HxOdSirEJZgJrApmKOdFRtZd
         KSSz82+LhoylcvO7tjC4NxbB9pwDB2/jaV6HO2/me3e7s6hGgmvdVDHqtImhBOOQNTUp
         1Tnm357ig4zXnHYHDIP9X9jaXZXVPoExSViuofbggZW0jkYPTzZH+601hsEu/cDBrnE9
         e0jg==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:mime-version:references
         :in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=rPb3F+GBAoL8+neyT8v2gdvmmxfkGsjPycBjGXKIoik=;
        b=g1eMek8sFNkAoH9zdJ85nqgB3+YjLJVVZ3RHi2+iMetgN1qIP579WGqzRPNZz+NWG9
         y9mqg1jgJQ+DQAO1PHqPZVXgeWxf5abN/OaAG626IUZSiOYE5u7i5BOLvGDWuZRfOnV9
         /FMl23gWIux0f9bFhFEa6XzUI2OH3uQ4bb46KTe9HAlElGmDt8T3A4FaeLATvJQL812p
         JrduGbBg7wFf2G7FEwP35JL81JEsoK2MQJqZgnIq0/Jcsu1wLXdlQFnpp9D4w2V8jzeZ
         cPjypRUmWAGoNn1JePZaqLBG1f+c5vA1BUKkMNvHqoT7RBlt2ZtygfAo3flgQyHj4n72
         D4iA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:message-id:in-reply-to:references:mime-version
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=rPb3F+GBAoL8+neyT8v2gdvmmxfkGsjPycBjGXKIoik=;
        b=WYh0o2abFZIv0UQBlZG+E6Y3wm6Pu/xz0pXsdyhIQVG9ZTs1KjBy4//gcaWvonwKQo
         qLUhHtB7gF7aMSWNrqApWmuRfX+RMNqzFajWlibtBROoWjmD0Wmtwys52t9O/k9Eqmmg
         KuaDvxM6cbrOFdrFHqHw9lwabt1HDFGZd8tB++/mrPmGLRRa+mXRCbZ2hS6YNI25cfG3
         cj20eQNlIBVIiHPq0tYq975aBRihfT01rmw9z7Lcpl3yuWHEGnlCveOafuRnffpDJaet
         PYKG1PuW5frizsF5mme/G3mELJsjFlD9oZBm5MAacG5clsglW7WtpO5FgBY6PvSShjY5
         nlCQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references:mime-version:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=rPb3F+GBAoL8+neyT8v2gdvmmxfkGsjPycBjGXKIoik=;
        b=Xb5r+ce3WmQj0HeAIOBbvs57E+UvreY6UxSztcipDn8KrBREU4bdw7abAvKbs7I1x6
         WOExgui3/1mwN6nciRj5KpGn6OJT+63xIZjA3M07XCmge+FdhV3eRD0KvJTNlkhWVfwK
         msLIY3gTiekr/KtrZrgbRNtcVviO4zzouXlz19gZuUtLGjnrf9Xr5YJyenalD1Oz1yX1
         yeNqMZVfcvn++/y+2QogRs1OFoIPgRukJ/Ay4uBEtvFwoNP4WYFSku96Q0yJDUfe38zS
         05kVZjo9N7q56BooxCopfKRvSe0fgop0EbXKtqaTvYinvcXVil/ld+fVoomDRZqOcU/t
         BTTA==
X-Gm-Message-State: AJaThX55kbwpuTkegroJPZOKMaa2wKRRWns7XZ+MSmxB5MUm6ETIrX6G
	a8r3CKIMKlY1Iy+YZ8GA5T7giA==
X-Google-Smtp-Source: AGs4zMaCUTVpn4Ts1c9WhXDdc2Mn36HnbU72umWy41uipt87qii99jeaZAwXW21Nw/ro5dGP6BcmhQ==
X-Received: by 10.223.157.206 with SMTP id q14mr1757639wre.11.1511588256524;
        Fri, 24 Nov 2017 21:37:36 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.223.185.105 with SMTP id b38ls2685600wrg.1.gmail; Fri, 24 Nov
 2017 21:37:35 -0800 (PST)
X-Received: by 10.223.173.67 with SMTP id p61mr24637776wrc.226.1511588255387;
        Fri, 24 Nov 2017 21:37:35 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1511588255; cv=none;
        d=google.com; s=arc-20160816;
        b=HCz2pNVsNj1ECMLJ0Drgiq+zRQxmZ/pgUt6AMIABruZmRfSUv8I54irjYnUaQwyoLJ
         OXaPwvalA3mXj/rzfpn76IAGngx7VPO4X5Xl4P76oooRxEsTJjlo9w+tQpwJWZ6D9WhZ
         cBvV+TMWnH5L1PXZnLDrg2KmcpJIl1roo9uX8bI1eQyQdvbZmxiktSbzSj2MPeHQ9WT2
         tEH/bO6Ltx29wmbb2/M+U/YzIMqdu7o0tXg98rfm2i/K+tt/KAiJlXwXgsCEj5L0u597
         dmpe15RT+Qzbkg1PiD8AJWFWjousceTh5+biA9t09O9UEPNNKGwRKqKFJNJVHI4xbFFF
         0mOQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=55AMauaOZUsv6i4eyvKd1a32IB3t/9y3h+4gJKxa5a0=;
        b=k/rCRN5nfU3+PXPz6y5lwHDXwDffryXqYPLvwhpbrbjFzMolEsIbJDT+r0yRAbIyc8
         j1Pb9555thqYhtk04322QcV/2Gco0BCXiTwkDEpQvLWo8yOGMfLthK71rng8ZaMbsifP
         z5jJqRklMzrWIPUP2JW2ZberOhocdgShPU+avjFF23C+AqsIvIUNic4hdFAwaXxSVZIq
         JdqDGaUEUe/uvfvwzQrAdkipW+n7CzqoXUuHF5nolu9cZY3J0+jImfdJbTTIyAFWR/o7
         Hf+jN4atF02Sr6yM6bwcSlAjUEiLux3FV2xo+o5adATKwomZVkCrGyBC9hbsD88lvWGy
         nZaw==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [78.47.120.188])
        by mx.google.com with ESMTP id 140si8031386wmv.53.2017.11.24.21.37.35
        for <std-proposals@isocpp.org>;
        Fri, 24 Nov 2017 21:37:35 -0800 (PST)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) client-ip=78.47.120.188;
Original-Received: from tjmaciei-mobl1.localnet (unknown [IPv6:2601:1c0:4501:5f9f:10a8:5dac:57fd:2747])
	by gondolin.macieira.info (Postfix) with ESMTPSA id 4FC3111A585
	for <std-proposals@isocpp.org>; Fri, 24 Nov 2017 21:37:34 -0800 (PST)
In-Reply-To: <f3dafdfb-df6a-ac57-fdff-fba300c734d9@gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 78.47.120.188 as permitted sender) smtp.mailfrom=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:35508
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35508>

On sexta-feira, 24 de novembro de 2017 21:14:19 PST Andrey Semashev wrote:
> On 11/25/17 03:09, Thiago Macieira wrote:
> > On sexta-feira, 24 de novembro de 2017 10:46:09 PST Nicol Bolas wrote:
> >> Bit-*rotation* is a less common operation than bit shifting.
> > 
> > Proof: the fact that there's no built-in rotation operator in any major
> > language, not even in C that was supposed to be "portable assembly".
> > Especially in the olden days when you coudn't count on the compilers
> > understanding what you meant.
> > 
> > And if you want an even less common operation: rotate with carry.
> 
> That's not exactly a proof, more of a conservative approach of language
> designers. Every widespread CPU architecture includes rotation
> instructions because theys are important in some areas.

No doubt they are, because unlike a high-level language, executing a rotation 
in assembly couldn't be executed in one cycle due to the data dependency[*], 
not to mention the need to use one extra register, possibly two. A dedicated 
instruction for rotation (and one more for rotate-with-carry) can probably 
execute in one cycle by just reusing the barrel-shifter.

The high-level language doesn't need that because the compilers are smart 
enough to notice the pattern of two-shifts-and-or as a rotation and write 
assembly accordingly.

[*] unless the processor is smart enough to do macro-op fusing of three 
instructions. The Intel x86 processors' microcode can fuse CMP+Jcc, but I 
don't know of three-instruction fusing.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/3031585.uCQqKE2Qzv%40tjmaciei-mobl1.

.
