From patchwork Mon Mar 20 06:32:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 72006 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1048988wrt; Sun, 19 Mar 2023 23:33:37 -0700 (PDT) X-Google-Smtp-Source: AK7set+dg+bofO9UoHNyHeaWOCBRLi5ay2shiBzd5BFlCWF0JCELHUA1yq/nH0Sxa6T03+xXEzdf X-Received: by 2002:aa7:dbc1:0:b0:4fa:8aa4:8d8b with SMTP id v1-20020aa7dbc1000000b004fa8aa48d8bmr9884076edt.7.1679294017645; Sun, 19 Mar 2023 23:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679294017; cv=none; d=google.com; s=arc-20160816; b=qrLhYM+tevXcRv2ZUinvqbBBTrGa5Mid6FaBxxaz2zUPaWC8ULKPv6McAChCfyxebY lF9ALD2vX6eKLhJhunMRGCCSZppBoolCZW+JLzwbSZXpKLcsZFItxsvelGOp0pAw/wWg TGaFctgwg4g5EtwIiFkaMcoNDClgqj7wAFX9ffj0lWta4viXqx3WOsm1lj60C7gnoVrH 7ZSRa2Zqy3qJ+t6JSNBotzGnNx0TCNy54IPzK8Fd2WqQEl3v60hWWcNWRlNhc+nkHnxh ShuaghziVrJ/+y/SkLbaIeJrvEzGrbuW/Dac/JhI6FKJQN3I744tg8xTdNG5c/ou4o1i U7RQ== 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:cc:to:subject:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=iWezXca+9X/QSKEslq+IXgc4f6Gbasy3/Og9tV9wGZg=; b=DnNb6pE4FlS9G5W0RWAgkjm4uFLKohwgY6ss2Eo3v+l3HOaiN3tNOfWKJzxdpsZVbf XxRNC5FH2teABE0WUZH54FrsUvcXNll/Png3S06YDdYNPIu/dg7bzOuQxS3c5rQMHMGS fEH0hPm7xCTeafEiCK1UpcbjcrNdDE1Tcc0DhQ4724QIgi9mGCFeUuD2CoWBYhu6xsQV B67p8CvQLMdPlpl8vFguPvRJeR/c9M6FpkDt8Kko1JupZ82YB+Pokir9mv0hsUV7rhJt KAy6FV6zeyxhorYLuLBWJLGyx1gCv0PLg8Dl8hIjoHohk6hBIndblLG/6a1oa4pHw5wV LbTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HGzKgrWZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id n11-20020aa7c78b000000b004fd3def3e85si8873434eds.180.2023.03.19.23.33.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 23:33:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HGzKgrWZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 08AD2385022A for ; Mon, 20 Mar 2023 06:33:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08AD2385022A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679293990; bh=iWezXca+9X/QSKEslq+IXgc4f6Gbasy3/Og9tV9wGZg=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=HGzKgrWZNEew/RYKjGQNgqcresKzNJb9N+6tgRaAGUS0S4mb0sKzCcjZASJchorsM cCDFM1ObX+WWhOO0+yGsPw9S1RwR2tviPegJb3qc69Rhs/uUeeCAOfcU1aTKRb56v2 HMtb/BTRVbUdNWxPLvakkvPLVvECL1+G3uPghY3w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 4DD1F3850867 for ; Mon, 20 Mar 2023 06:32:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DD1F3850867 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32K5RTNT031236; Mon, 20 Mar 2023 06:32:24 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pdq4rfqwh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Mar 2023 06:32:24 +0000 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 32K6ENGW022902; Mon, 20 Mar 2023 06:32:23 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pdq4rfqvp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Mar 2023 06:32:23 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32K4YQBI022403; Mon, 20 Mar 2023 06:32:21 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3pd4x6asp5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Mar 2023 06:32:21 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32K6WIga22283000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 20 Mar 2023 06:32:18 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A70F420049; Mon, 20 Mar 2023 06:32:18 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE7AB20040; Mon, 20 Mar 2023 06:32:16 +0000 (GMT) Received: from [9.177.11.227] (unknown [9.177.11.227]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 20 Mar 2023 06:32:16 +0000 (GMT) Message-ID: <9cac9802-cb71-ad06-fc2d-a79b486091fa@linux.ibm.com> Date: Mon, 20 Mar 2023 14:32:15 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US Subject: [PATCH] rs6000: Make _mm_slli_si128 and _mm_bslli_si128 consistent [PR109167] To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Peter Bergner X-TM-AS-GCONF: 00 X-Proofpoint-GUID: pSOBaEKz9p2NbPg0DjW2_d5wLW__YVVZ X-Proofpoint-ORIG-GUID: gXShOtMZB1pXJgrXAn9YUXXOgms5OchI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-20_04,2023-03-16_02,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 mlxscore=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 mlxlogscore=670 malwarescore=0 impostorscore=0 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303200057 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, 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 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: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" 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?1760867404068854563?= X-GMAIL-MSGID: =?utf-8?q?1760867404068854563?= Hi, As PR109167 shows, it's unexpected to have two different implementation ways for _mm_slli_si128 and _mm_bslli_si128, as gcc/config/i386/emmintrin.h they should be the same. So this patch is to fix it accordingly. Bootstrapped and regtested on powerpc64-linux-gnu P8 and powerpc64le-linux-gnu P9 and P10. I'm going to push this soon if no objections. BR, Kewen ----- PR target/109167 gcc/ChangeLog: * config/rs6000/emmintrin.h (_mm_bslli_si128): Move the implementation from ... (_mm_slli_si128): ... here. Change to call _mm_bslli_si128 directly. gcc/testsuite/ChangeLog: * gcc.target/powerpc/pr109167.c: New test. --- gcc/config/rs6000/emmintrin.h | 26 ++++-------- gcc/testsuite/gcc.target/powerpc/pr109167.c | 47 +++++++++++++++++++++ 2 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr109167.c -- 2.31.1 diff --git a/gcc/config/rs6000/emmintrin.h b/gcc/config/rs6000/emmintrin.h index bfff7ff6fea..44d01a83d8d 100644 --- a/gcc/config/rs6000/emmintrin.h +++ b/gcc/config/rs6000/emmintrin.h @@ -1601,8 +1601,14 @@ _mm_bslli_si128 (__m128i __A, const int __N) __v16qu __result; const __v16qu __zeros = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - if (__N >= 0 && __N < 16) + if (__N == 0) + return __A; + else if (__N > 0 && __N < 16) +#ifdef __LITTLE_ENDIAN__ __result = vec_sld ((__v16qu) __A, __zeros, __N); +#else + __result = vec_sld (__zeros, (__v16qu) __A, (16 - __N)); +#endif else __result = __zeros; @@ -1647,23 +1653,9 @@ _mm_srli_si128 (__m128i __A, const int __N) } extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -_mm_slli_si128 (__m128i __A, const int _imm5) +_mm_slli_si128 (__m128i __A, const int __N) { - __v16qu __result; - const __v16qu __zeros = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - - if (_imm5 == 0) - return __A; - else if (_imm5 > 0 && _imm5 < 16) -#ifdef __LITTLE_ENDIAN__ - __result = vec_sld ((__v16qu) __A, __zeros, _imm5); -#else - __result = vec_sld (__zeros, (__v16qu) __A, (16 - _imm5)); -#endif - else - __result = __zeros; - - return (__m128i) __result; + return _mm_bslli_si128 (__A, __N); } extern __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) diff --git a/gcc/testsuite/gcc.target/powerpc/pr109167.c b/gcc/testsuite/gcc.target/powerpc/pr109167.c new file mode 100644 index 00000000000..d490c995b14 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr109167.c @@ -0,0 +1,47 @@ +/* { dg-do run } */ +/* { dg-require-effective-target vsx_hw } */ +/* { dg-options "-O2 -mvsx" } */ + +/* Verify there is no warning message. */ + +#define NO_WARN_X86_INTRINSICS 1 + +#include + +#define N 5 + +__attribute__ ((noipa)) __m128i +test1 (__m128i v) +{ + return _mm_bslli_si128 (v, N); +} + +__attribute__ ((noipa)) __m128i +test2 (__m128i v) +{ + return _mm_slli_si128 (v, N); +} + +typedef union +{ + __m128i x; + unsigned char a[16]; +} union128i_ub; + +int main() +{ + union128i_ub v; + v.x + = _mm_set_epi8 (1, 2, 3, 4, 10, 20, 30, 90, 80, 40, 100, 15, 98, 25, 98, 7); + + union128i_ub r1, r2; + r1.x = test1 (v.x); + r2.x = test2 (v.x); + + for (int i = 0; i < 16; i++) + if (r1.a[i] != r2.a[i]) + __builtin_abort(); + + return 0; +} +