From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 54C6F3858CDB for ; Wed, 24 May 2023 12:53:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 54C6F3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id 3F67940737C0; Wed, 24 May 2023 12:53:34 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 3F67940737C0 From: Alexander Monakov To: gcc-patches@gcc.gnu.org Cc: Alexander Monakov Subject: [PATCH] doc: clarify semantics of vector bitwise shifts Date: Wed, 24 May 2023 15:53:32 +0300 Message-Id: <20230524125332.30839-1-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: Explicitly say that bitwise shifts for narrow types work similar to element-wise C shifts with integer promotions, which coincides with OpenCL semantics. gcc/ChangeLog: * doc/extend.texi (Vector Extensions): Clarify bitwise shift semantics. --- gcc/doc/extend.texi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index e426a2eb7d..6b4e94b6a1 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -12026,7 +12026,12 @@ elements in the operand. It is possible to use shifting operators @code{<<}, @code{>>} on integer-type vectors. The operation is defined as following: @code{@{a0, a1, @dots{}, an@} >> @{b0, b1, @dots{}, bn@} == @{a0 >> b0, a1 >> b1, -@dots{}, an >> bn@}}@. Vector operands must have the same number of +@dots{}, an >> bn@}}@. When the base type is narrower than @code{int}, +element-wise shifts are performed as if operands underwent C integer +promotions, like in OpenCL. This makes vector shifts by up to 31 bits +well-defined for vectors with @code{char} and @code{short} base types. + +Operands of binary vector operations must have the same number of elements. For convenience, it is allowed to use a binary vector operation -- 2.39.2