From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 40C4F3858D20 for ; Wed, 9 Aug 2023 08:47:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40C4F3858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3798Y0sE025373; Wed, 9 Aug 2023 08:47:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=1o45PNnzda7/IdrDZiTmU+yXU2bLXYEbiVt5n00ufk0=; b=CTSYExBeA5kQgSKRLlL1CBA/6JqmON93lBY32i/mcxAdObyPHcBfHkvUcNOYa8zGGk5Y arzwoBBYEZEbEm6liCPJhud2aCI/vv2KICBXE2lQvnkrTSHtsOU/TtpMsPve2Y2LsG3d MQHivLr1gIeSVuZCJaJL174r9/up3XHG/77ninkzb5VekThVKqtJwxFxov2oU/MqXhvo mwxt39qS4/YPYIcxsEV9lRwpyupfkyy7aUgAj3I10/is8CsNKxcCk9vEh+GMOWP+jhbk X1wx+cVAHqv5rZJ2x3pKipzDNkn48FyG0fXjgros5bBxX7r6L+ijPY/vxr0DXP4IHI0T DQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sc7d7ggmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Aug 2023 08:47:23 +0000 Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3798hYmU007892; Wed, 9 Aug 2023 08:47:22 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3sc7d7ggmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Aug 2023 08:47:22 +0000 Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3798DBll001792; Wed, 9 Aug 2023 08:47:22 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 3sa3f1x2p4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 09 Aug 2023 08:47:22 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3798lKwh46072542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 9 Aug 2023 08:47:20 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6794520040; Wed, 9 Aug 2023 08:47:20 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EBD420043; Wed, 9 Aug 2023 08:47:18 +0000 (GMT) Received: from [9.197.227.215] (unknown [9.197.227.215]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 9 Aug 2023 08:47:18 +0000 (GMT) Message-ID: Date: Wed, 9 Aug 2023 16:47:16 +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 Subject: Re: [PATCH ver 3] rs6000: Fix __builtin_altivec_vcmpne{b,h,w} implementation Content-Language: en-US To: Carl Love Cc: Peter Bergner , Segher Boessenkool , David Edelsohn , gcc-patches@gcc.gnu.org References: <5c776123d5122c174875a9a7e5e47e59f22a66ea.camel@us.ibm.com> From: "Kewen.Lin" In-Reply-To: <5c776123d5122c174875a9a7e5e47e59f22a66ea.camel@us.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GFdlYTxh2WSp3R2AdhGqKLo6hMPPD0OQ X-Proofpoint-ORIG-GUID: KukUqEq0LXENa_vJXbZJgOpQbSe4E5vy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-08-09_06,2023-08-08_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 bulkscore=0 clxscore=1015 adultscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2306200000 definitions=main-2308090075 X-Spam-Status: No, score=-14.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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 List-Id: Hi Carl, on 2023/8/8 01:50, Carl Love wrote: > > GCC maintainers: > > Ver 3: Updated description to make it clear the patch fixes the > confusion on the availability of the builtins. Fixed the dg-require- > effective-target on the test cases and the dg-options. Change the test > case so the for loop for the test will not be unrolled. Fixed a > spelling error in a vec-cmpne.c comment. Retested on Power 10LE. > > Ver 2: Re-worked the test vec-cmpne.c to create a compile only test > verify the instruction generation and a runnable test to verify the > built-in functionality. Retested the patch on Power 8 LE/BE, Power > 9LE/BE and Power 10 LE with no regressions. > > The following patch cleans up the definition for the > __builtin_altivec_vcmpne{b,h,w}. The current implementation implies > that the built-in is only supported on Power 9 since it is defined > under the Power 9 stanza. However the built-in has no ISA restrictions > as stated in the Power Vector Intrinsic Programming Reference document. > The current built-in works because the built-in gets replaced during > GIMPLE folding by a simple not-equal operator so it doesn't get > expanded and checked for Power 9 code generation. > > This patch moves the definition to the Altivec stanza in the built-in > definition file to make it clear the built-ins are valid for Power 8, > Power 9 and beyond. > > The patch has been tested on Power 8 LE/BE, Power 9 LE/BE and Power 10 > LE with no regressions. > > Please let me know if the patch is acceptable for mainline. Thanks. > > Carl > > ------------------------------------------------ > > rs6000: Fix __builtin_altivec_vcmpne{b,h,w} implementation > > The current built-in definitions for vcmpneb, vcmpneh, vcmpnew are defined > under the Power 9 section of r66000-builtins. This implies they are only > supported on Power 9 and above when in fact they are defined and work with > Altivec as well with the appropriate Altivec instruction generation. > > The vec_cmpne builtin should generate the vcmpequ{b,h,w} instruction with > Altivec enabled and generate the vcmpne{b,h,w} on Power 9 and newer > processors. > > This patch moves the definitions to the Altivec stanza to make it clear > the built-ins are supported for all Altivec processors. The patch > removes the confusion as to which processors support the vcmpequ{b,h,w} > instructions. > > There is existing test coverage for the vec_cmpne built-in for > vector bool char, vector bool short, vector bool int, > vector bool long long in builtins-3-p9.c and p8vector-builtin-2.c. > Coverage for vector signed int, vector unsigned int is in > p8vector-builtin-2.c. > > Test vec-cmpne.c is updated to check the generation of the vcmpequ{b,h,w} > instructions for Altivec. A new test vec-cmpne-runnable.c is added to > verify the built-ins work as expected. > > Patch has been tested on Power 8 LE/BE, Power 9 LE/BE and Power 10 LE > with no regressions. Okay for trunk with two nits below fixed, thanks! > > gcc/ChangeLog: > > * config/rs6000/rs6000-builtins.def (vcmpneb, vcmpneh, vcmpnew): > Move definitions to Altivec stanza. > * config/rs6000/altivec.md (vcmpneb, vcmpneh, vcmpnew): New > define_expand. > > gcc/testsuite/ChangeLog: > > * gcc.target/powerpc/vec-cmpne-runnable.c: New execution test. > * gcc.target/powerpc/vec-cmpne.c (define_test_functions, > execute_test_functions) moved to vec-cmpne.h. Added > scan-assembler-times for vcmpequb, vcmpequh, vcmpequw. s/ moved/: Move/ => "... execute_test_functions): Move " s/Added/Add/ > * gcc.target/powerpc/vec-cmpne.h: New include file for vec-cmpne.c > and vec-cmpne-runnable.c. Split define_test_functions definition > into define_test_functions and define_init_verify_functions. > --- > gcc/config/rs6000/altivec.md | 12 ++ > gcc/config/rs6000/rs6000-builtins.def | 18 +-- > .../gcc.target/powerpc/vec-cmpne-runnable.c | 36 ++++++ > gcc/testsuite/gcc.target/powerpc/vec-cmpne.c | 112 ++---------------- > gcc/testsuite/gcc.target/powerpc/vec-cmpne.h | 90 ++++++++++++++ > 5 files changed, 156 insertions(+), 112 deletions(-) > create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-cmpne-runnable.c > create mode 100644 gcc/testsuite/gcc.target/powerpc/vec-cmpne.h > > diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md > index ad1224e0b57..31f65aa1b7a 100644 > --- a/gcc/config/rs6000/altivec.md > +++ b/gcc/config/rs6000/altivec.md > @@ -2631,6 +2631,18 @@ (define_insn "altivec_vcmpequt_p" > "vcmpequq. %0,%1,%2" > [(set_attr "type" "veccmpfx")]) > > +;; Expand for builtin vcmpne{b,h,w} > +(define_expand "altivec_vcmpne_" > + [(set (match_operand:VSX_EXTRACT_I 3 "altivec_register_operand" "=v") > + (eq:VSX_EXTRACT_I (match_operand:VSX_EXTRACT_I 1 "altivec_register_operand" "v") > + (match_operand:VSX_EXTRACT_I 2 "altivec_register_operand" "v"))) > + (set (match_operand:VSX_EXTRACT_I 0 "altivec_register_operand" "=v") > + (not:VSX_EXTRACT_I (match_dup 3)))] > + "TARGET_ALTIVEC" > + { > + operands[3] = gen_reg_rtx (GET_MODE (operands[0])); > + }); Nit: Useless ";". BR, Kewen