From patchwork Wed May 3 15:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Love X-Patchwork-Id: 89775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1421587vqo; Wed, 3 May 2023 08:38:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7hlZiPQooMzqQlYHTO30ly1b8X7AX7/4RoLCaozpuM/gp+wxR4lRB7HmaDD/XUZEt0GE93 X-Received: by 2002:aa7:d0c5:0:b0:506:ba8d:c317 with SMTP id u5-20020aa7d0c5000000b00506ba8dc317mr11175231edo.40.1683128310178; Wed, 03 May 2023 08:38:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683128310; cv=none; d=google.com; s=arc-20160816; b=b9m81GhUqasF1vSqCy8z83wU6hqFYNYJ0BA8dmUIionI0DsJU8R+R9GZIgzk8R3X3H 0+YbBEOVe7Zvw0dVCCaYl/pnPQ6XHPhiTBRXI+MnL7Y2mRkxvyGY5FgoWQSuVahj0Kg1 5WgYW6C3ukLemnU84WL5mpFps8rFvp+4ToM5jZvlWBgr1DqvWskiTCfjvh8XT5zomq8b pDyT6nPeYTg0zBbaHtIM8BSerrrpXZUXxTNqIORGXe27RqngFPxx3PtT44trYDl5UGma oeretnUFEmKI9JbZCN697bbkn4F1aowLHDjlZc8JvThCs7cKe+FBM5EBciLptUegBH/1 GvOQ== 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:date:cc:to:subject :message-id:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=7UiLKtzoallQvOpC2CFdz9LEAQLlqDoWSyWovJl9ivY=; b=N8kA9v9qKIoSOzzSN/8zFFMjK5q2rQvKTV6e3OctFaoADtHgJjPFmxa6a1+7+Q6QnV B5G+cbSz3RyDUZ/QctGxN6EKvic9Yjrpw1hdNAsbHufQGi6G2ZndEHY+a2xHCY8/iBfO Er3DtnX3DHx0s0Vg9P5WeRKZKS3BMBhqfCpxJ23y+rvDkSAAmi5i/R2zNsyuXOJTvZo0 l9+xwjWIi6dy0GWBFsk2MLHq+2XufUVBbHHISZscAEW2DZzS8FPl0MpmpIKc/VCix5XC m6PtA8vwdPjWY82nExcnLQqVcxsDslD6qvd665/4VYVqDEnuEhbNI2n4ysEYOz1Sjh+0 xNcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nQ0eiAbB; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t11-20020aa7d4cb000000b0050bcd75a0c5si1195395edr.120.2023.05.03.08.38.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 08:38:30 -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=nQ0eiAbB; 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 9656A3856947 for ; Wed, 3 May 2023 15:31:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9656A3856947 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683127874; bh=7UiLKtzoallQvOpC2CFdz9LEAQLlqDoWSyWovJl9ivY=; h=Subject:To:Cc:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=nQ0eiAbBczG0dDDPGlEB//pdEFBPijARf3sRgBCVezLgN7IH29dKifRHlCRHL4QKg x2HYmoREpJbDUlYBzt12gcAamqPttyangQdZd8UnmXSGlZSY/qo7cmgCExkdS09DTV 13DJAHRJJWaUijo8od8K6Ph7Unpw3JaeK4R/mHU0= 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 0147F385771E for ; Wed, 3 May 2023 15:30:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0147F385771E Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 343FMiWG027367; Wed, 3 May 2023 15:30:21 GMT Received: from ppma02wdc.us.ibm.com (aa.5b.37a9.ip4.static.sl-reverse.com [169.55.91.170]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qbt6y071s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 15:30:20 +0000 Received: from pps.filterd (ppma02wdc.us.ibm.com [127.0.0.1]) by ppma02wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 343BuJc8002605; Wed, 3 May 2023 15:30:18 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([9.208.129.119]) by ppma02wdc.us.ibm.com (PPS) with ESMTPS id 3q8tv8d43w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 03 May 2023 15:30:18 +0000 Received: from smtpav06.wdc07v.mail.ibm.com (smtpav06.wdc07v.mail.ibm.com [10.39.53.233]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 343FUGgj22610400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 3 May 2023 15:30:16 GMT Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BEC035804E; Wed, 3 May 2023 15:30:16 +0000 (GMT) Received: from smtpav06.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3DC725803F; Wed, 3 May 2023 15:30:16 +0000 (GMT) Received: from li-e362e14c-2378-11b2-a85c-87d605f3c641.ibm.com (unknown [9.163.52.55]) by smtpav06.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 3 May 2023 15:30:16 +0000 (GMT) Message-ID: <77735edd316c9aacaf33698825bf22b005ae6d4d.camel@us.ibm.com> Subject: [PATCH] rs6000: vec_cmpne confusing implementation To: gcc-patches@gcc.gnu.org, Segher Boessenkool Cc: cel@us.ibm.com, Peter Bergner Date: Wed, 03 May 2023 08:30:14 -0700 X-Mailer: Evolution 3.28.5 (3.28.5-18.el8) Mime-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 4oEwgZ0m1KntNZp_lhH8jpVhZkYyACLu X-Proofpoint-ORIG-GUID: 4oEwgZ0m1KntNZp_lhH8jpVhZkYyACLu 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-05-03_10,2023-05-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 priorityscore=1501 impostorscore=0 phishscore=0 mlxlogscore=991 spamscore=0 adultscore=0 clxscore=1015 mlxscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2305030127 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 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: Carl Love via Gcc-patches From: Carl Love Reply-To: Carl Love 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?1764887950883776839?= X-GMAIL-MSGID: =?utf-8?q?1764887950883776839?= GCC maintainers: The following patch cleans up the definition for the __builtin_altivec_vcmpnet. The current implementation implies that the builtin is only supported on Power 9 since it is defined under the Power 9 stanza. However the builtin has no ISA restrictions as stated in the Power Vector Intrinsic Programming Reference document. The current built-in works because the builtin 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 builtin definition file. The builtin then generates code for Power 8 and earlier processors or Power 9 and later processors. The patch has been tested on Power 8 and Power 9 with no regressions. Please let me know if the patch is acceptable for mainline. Thanks. Carl ----------------------------------------- rs6000: vec_cmpne confusing implementation __builtin_altivec_vcmpnet does not have any ISA restrictions. The current built-in definitions for vcmpneb, vcmpneh, vcmpnew, vcmpnet are defined under the Power 9 section. This implies they are only supported on Power 9 and above when in fact they are defined and work on Power 8. This patch moves the definitions to the Altivec stanza and maps the builtin dispatches to different code generation for Power 8 and earlier or for Power 9 and later. gcc/ChangeLog: * config/rs6000/rs6000-builtins.def (vcmpneb, vcmpneh, vcmpnew. vcmpnet): Move definitions to Altivec stanza. * config/rs6000/vsx.md (cmpneb, vcmpneh, vcmpnew, vcmpnet): New define_expand. (cmpneb, vcmpneh, vcmpnew, vcmpnet): Rename define_insn. Patch has been tested on Power 8 and Power 9 with no regressions. --- gcc/config/rs6000/rs6000-builtins.def | 24 ++++++------ gcc/config/rs6000/vsx.md | 54 +++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/gcc/config/rs6000/rs6000-builtins.def b/gcc/config/rs6000/rs6000-builtins.def index 638d0bc72ca..adb4122be29 100644 --- a/gcc/config/rs6000/rs6000-builtins.def +++ b/gcc/config/rs6000/rs6000-builtins.def @@ -641,6 +641,18 @@ const int __builtin_altivec_vcmpgtuw_p (int, vsi, vsi); VCMPGTUW_P vector_gtu_v4si_p {pred} + const vsc __builtin_altivec_vcmpneb (vsc, vsc); + VCMPNEB vcmpneb {} + + const vss __builtin_altivec_vcmpneh (vss, vss); + VCMPNEH vcmpneh {} + + const vsi __builtin_altivec_vcmpnew (vsi, vsi); + VCMPNEW vcmpnew {} + + const vbq __builtin_altivec_vcmpnet (vsq, vsq); + VCMPNET vcmpnet {} + const vsi __builtin_altivec_vctsxs (vf, const int<5>); VCTSXS altivec_vctsxs {} @@ -2599,9 +2611,6 @@ const signed int __builtin_altivec_vcmpaew_p (vsi, vsi); VCMPAEW_P vector_ae_v4si_p {} - const vsc __builtin_altivec_vcmpneb (vsc, vsc); - VCMPNEB vcmpneb {} - const signed int __builtin_altivec_vcmpneb_p (vsc, vsc); VCMPNEB_P vector_ne_v16qi_p {} @@ -2614,15 +2623,9 @@ const signed int __builtin_altivec_vcmpnefp_p (vf, vf); VCMPNEFP_P vector_ne_v4sf_p {} - const vss __builtin_altivec_vcmpneh (vss, vss); - VCMPNEH vcmpneh {} - const signed int __builtin_altivec_vcmpneh_p (vss, vss); VCMPNEH_P vector_ne_v8hi_p {} - const vsi __builtin_altivec_vcmpnew (vsi, vsi); - VCMPNEW vcmpnew {} - const signed int __builtin_altivec_vcmpnew_p (vsi, vsi); VCMPNEW_P vector_ne_v4si_p {} @@ -3203,9 +3206,6 @@ const signed int __builtin_altivec_vcmpgtut_p (signed int, vuq, vuq); VCMPGTUT_P vector_gtu_v1ti_p {pred} - const vbq __builtin_altivec_vcmpnet (vsq, vsq); - VCMPNET vcmpnet {} - const signed int __builtin_altivec_vcmpnet_p (vsq, vsq); VCMPNET_P vector_ne_v1ti_p {} diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index 7d845df5c2d..3f05e3e6d00 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -5652,8 +5652,56 @@ DONE; }) +;; Expand for builtin vcmpneb +(define_expand "vcmpneb" + [(set (match_operand:V16QI 0 "altivec_register_operand" "=v") + (not:V16QI + (eq:V16QI (match_operand:V16QI 1 "altivec_register_operand" "v") + (match_operand:V16QI 2 "altivec_register_operand" "v"))))] + "" + { + if (TARGET_P9_VECTOR) + emit_insn (gen_vcmpneb_p9 (operands[0], operands[1], operands[2])); + else + emit_insn (gen_altivec_vcmpequb_p (operands[0], operands[1], + operands[2])); + DONE; + }) + +;; Expand for builtin vcmpneh +(define_expand "vcmpneh" + [(set (match_operand:V8HI 0 "altivec_register_operand" "=v") + (not:V8HI + (eq:V8HI (match_operand:V8HI 1 "altivec_register_operand" "v") + (match_operand:V8HI 2 "altivec_register_operand" "v"))))] + "" + { + if (TARGET_P9_VECTOR) + emit_insn (gen_vcmpneh_p9 (operands[0], operands[1], operands[2])); + else + emit_insn (gen_altivec_vcmpequh_p (operands[0], operands[1], + operands[2])); + DONE; + }) + +;; Expand for builtin vcmpnew +(define_expand "vcmpnew" + [(set (match_operand:V4SI 0 "altivec_register_operand" "=v") + (not:V4SI + (eq:V4SI (match_operand:V4SI 1 "altivec_register_operand" "v") + (match_operand:V4SI 2 "altivec_register_operand" "v"))))] + "" + { + if (TARGET_P9_VECTOR) + emit_insn (gen_vcmpnew_p9 (operands[0], operands[1], operands[2])); + else + emit_insn (gen_altivec_vcmpequw_p (operands[0], operands[1], + operands[2])); + DONE; + }) + ;; Vector Compare Not Equal Byte (specified/not+eq:) -(define_insn "vcmpneb" +(define_insn "vcmpneb_p9" [(set (match_operand:V16QI 0 "altivec_register_operand" "=v") (not:V16QI (eq:V16QI (match_operand:V16QI 1 "altivec_register_operand" "v") @@ -5703,7 +5751,7 @@ [(set_attr "type" "vecsimple")]) ;; Vector Compare Not Equal Half Word (specified/not+eq:) -(define_insn "vcmpneh" +(define_insn "vcmpneh_p9" [(set (match_operand:V8HI 0 "altivec_register_operand" "=v") (not:V8HI (eq:V8HI (match_operand:V8HI 1 "altivec_register_operand" "v") @@ -5723,7 +5771,7 @@ [(set_attr "type" "vecsimple")]) ;; Vector Compare Not Equal Word (specified/not+eq:) -(define_insn "vcmpnew" +(define_insn "vcmpnew_p9" [(set (match_operand:V4SI 0 "altivec_register_operand" "=v") (not:V4SI (eq:V4SI (match_operand:V4SI 1 "altivec_register_operand" "v")