From patchwork Wed Nov 16 06:48:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 20736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3125165wru; Tue, 15 Nov 2022 22:49:22 -0800 (PST) X-Google-Smtp-Source: AA0mqf5hY+zz9DgLj+dhv+eCoOcaGxrXuwlBm2BVM+2GZGzwhMesQgO90d+KxWahLjjBBZ7iHemG X-Received: by 2002:a17:907:9142:b0:78d:9c18:7307 with SMTP id l2-20020a170907914200b0078d9c187307mr18253792ejs.23.1668581362694; Tue, 15 Nov 2022 22:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668581362; cv=none; d=google.com; s=arc-20160816; b=yMEzk6646/sKakc1/moYeEWPubUX9ZjzLoZ3ZTZ4P6Tp4FrroSykqv3OZO2CtCWLMQ nIYZHt/hQueSab5lTzEIlvmbl0jmKbFm5twGClzoxpF14jp910GB+MvP7LIJmTU7QKfT VPrKUdcNd0xr3T77Wj+kW5xbnGtEZrNoJNtMahaZAbiVTgrD+MHAiYswxRQBW7j7l+Uj rNi6ndWJOIUjLkk2Agq1//pvPHaWfopPnb4vrMKZHQjhPzJ6cY1lBbc4cschUQGvqd2t uh9Dq+9bTFp0x3S7sAyZvQd+Mb+S33s/77ko+kExB3XBeKtz3YZ+k6nBeyvVQTsR1TIo U+yQ== 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=qayZK5jaKAbiTSsGEMyaLgOIvnrAo3/bKiOeUkZUKcU=; b=yr4E4G36z7SUQ7vfWk2cRIeaXAsU3ICv+P4tB4RsVqgYD2wFlbZKDu1cRqzhDvxuFn UOBNuYiStZmKc/DQHvdHPaSs4OQ3LgRucJpb7U6V06EMAxujJJQB9bfCdhZlsny62qgz MplikfFB+0MJx1uuHmwdRVvamL+2ukvWibHYc6NCFYy/rO5W3oFH3IS2Q+XaFEQHEVQA EF/29A6+lbJ+S11kaH6mntqb6vVHd0zvfOe48mqkbYc0CfPFXNIGCEu6tj5v/7Zw5ESC LUfqT/97O73Yg4ool8rOd+6F4vN6CoGyIGYXp9GMIoBwY5z3CWX4t8ogZ62xpuSScO5Z 8lRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iQqCJKbh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r22-20020aa7c156000000b004615ccd71a0si12176254edp.162.2022.11.15.22.49.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 22:49:22 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=iQqCJKbh; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 1E1093954C6E for ; Wed, 16 Nov 2022 06:49:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E1093954C6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668581361; bh=qayZK5jaKAbiTSsGEMyaLgOIvnrAo3/bKiOeUkZUKcU=; h=Date:Subject:To:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=iQqCJKbhT+IuJGlwJwMLPv/HsUS9BtzcN+2st6bgw5CZZgjY46zMghyDMX+ol2F6e LtV4GQo33ggVECV3uOB00tNEs3ThOBjL2J4O00ZH/+Bu3V2Cpm4ohh6LfxEJC8e7vt 1ji8WIybV+rvOlCthxoPWU84UUvSj91vnBkZmCCE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id B4F8C3954C63 for ; Wed, 16 Nov 2022 06:48:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B4F8C3954C63 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AG4WIDa008562; Wed, 16 Nov 2022 06:48:35 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kvnv9e89k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 06:48:35 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AG6kOO9000306; Wed, 16 Nov 2022 06:48:34 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kvnv9e891-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 06:48:34 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AG6Zpxc007594; Wed, 16 Nov 2022 06:48:32 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma04ams.nl.ibm.com with ESMTP id 3kt348we0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 06:48:32 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AG6mS3x5898912 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 06:48:28 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CDA704C040; Wed, 16 Nov 2022 06:48:28 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DBCAC4C044; Wed, 16 Nov 2022 06:48:26 +0000 (GMT) Received: from [9.197.233.36] (unknown [9.197.233.36]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 16 Nov 2022 06:48:26 +0000 (GMT) Message-ID: Date: Wed, 16 Nov 2022 14:48:25 +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 1/2] rs6000: Emit vector fp comparison directly in rs6000_emit_vector_compare To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Peter Bergner , Michael Meissner X-TM-AS-GCONF: 00 X-Proofpoint-GUID: ZHUM9Wm41DPQ3ER_Wjs4J35SEQmGJ-bk X-Proofpoint-ORIG-GUID: MM0xQNkROM4Qvz08HP0QPiY1yYZV_dMS X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 adultscore=0 impostorscore=0 phishscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160046 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_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?1749634370721339347?= X-GMAIL-MSGID: =?utf-8?q?1749634370721339347?= Hi, All kinds of vector float comparison operators have been supported in one rtl comparison pattern as vector.md, we can just emit an rtx comparison insn with the given comparison operator in function rs6000_emit_vector_compare instead of checking and handling the reverse condition cases. This is also for a subsequent patch to deal with some comparison operators under trapping math enabled or disabled, so it's important to have one centralized place for vector float comparison handlings for better maintenance. Bootstrapped and regtested on powerpc64-linux-gnu P7 and P8, and powerpc64le-linux-gnu P9 and P10. I'm going to push this later this week if no objections. BR, Kewen ----- gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_emit_vector_compare_inner): Remove float only comparison operators. (rs6000_emit_vector_compare): Emit vector comparison insn directly for float modes. --- gcc/config/rs6000/rs6000.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) -- 2.27.0 diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 635aced6105..56db12f08a0 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -15660,10 +15660,6 @@ rs6000_emit_vector_compare_inner (enum rtx_code code, rtx op0, rtx op1) case EQ: case GT: case GTU: - case ORDERED: - case UNORDERED: - case UNEQ: - case LTGT: mask = gen_reg_rtx (mode); emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, mode, op0, op1))); return mask; @@ -15681,12 +15677,24 @@ rs6000_emit_vector_compare (enum rtx_code rcode, machine_mode dmode) { rtx mask; - bool swap_operands = false; - bool try_again = false; - gcc_assert (VECTOR_UNIT_ALTIVEC_OR_VSX_P (dmode)); gcc_assert (GET_MODE (op0) == GET_MODE (op1)); + /* In vector.md, we support all kinds of vector float point + comparison operators in a comparison rtl pattern, we can + just emit the comparison rtx insn directly here. Besides, + we should have a centralized place to handle the possibility + of raising invalid exception. */ + if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT) + { + mask = gen_reg_rtx (dmode); + emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1))); + return mask; + } + + bool swap_operands = false; + bool try_again = false; + /* See if the comparison works as is. */ mask = rs6000_emit_vector_compare_inner (rcode, op0, op1); if (mask) @@ -15705,10 +15713,6 @@ rs6000_emit_vector_compare (enum rtx_code rcode, try_again = true; break; case NE: - case UNLE: - case UNLT: - case UNGE: - case UNGT: /* Invert condition and try again. e.g., A != B becomes ~(A==B). */ { From patchwork Wed Nov 16 06:51:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 20738 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3126046wru; Tue, 15 Nov 2022 22:52:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf5RIW8ZH+x9JLFLFUUYTH5sQCVOVYe6+MXqUUIZfwcRN49kS6ft/DCov98fFsfePAfzqpTm X-Received: by 2002:aa7:cac1:0:b0:467:7827:232 with SMTP id l1-20020aa7cac1000000b0046778270232mr16574270edt.268.1668581520708; Tue, 15 Nov 2022 22:52:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668581520; cv=none; d=google.com; s=arc-20160816; b=Rn7ixTgcXR1J0FWcPPOgHJuCnBBn3vqs0okIWlJDURHL4DEVMrD6g3JnFmE2JbHD/v umUekYlf1i7Vdfid3h0UzwMDLpsiodB1Vm150Kv/WY2bc/NH/3Wxt5vFeYFR349FI/9s QiB/wNzDlHBbM5qpZnPMG5u5MT/W9YkUcuD5RabI1kYf6rTWUyt71mVz7+P67yh8Avm8 wu9Y56SAD6ERv3gr+Ju/kSXPujYFoWjaW8+FqdQ3r0neeRb8OQ+69CPN6TNt3x3mcEaF DLCdmfM/4ECGxIm8i8v/Hq/Pln9ScxaCne7F86uZ8IsfDaFzGqxYlU8ge4p5Idam3ItW XvlQ== 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:in-reply-to:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=l0vFr+PZww7+hh8OBCfjy9jlORvkd9GsbNlfzkqFLoM=; b=Rrql0dIbZ/JIMw+qVMXkX45Z3YWa+CH/cX/ju2Quh7hp8HI4d/3lyHGe04TyEg4lPo 9FNaAAfh9FLEel1eBnwyM7m5XqQ4aBYM98bjXcM3ZJTgXr4tR+vARg/AA4zhXi7yB/U4 twwIOfgYPk9lRMX5H03pUNPAhU68IDu8MXPH0cKE5ZWQykCqMj1UfOEMW21ouzPgQZDV eh+NqtfbtYtclMR0PJiSdKZ75b1yYG6oNUSwW+8hJenmHsjW7rtQeoiENabCV2oA/7dx 839RGRX2k7qfK0igYLNzUNWktT4yDSZAMbUzGbHEalBBPuyu6Kv67buOw5keSXTQMVFL /C4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cxrb8Mds; 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 21-20020a508e15000000b00461f44d7bfcsi11606124edw.573.2022.11.15.22.52.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 22:52:00 -0800 (PST) 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=cxrb8Mds; 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 E9BE93954C73 for ; Wed, 16 Nov 2022 06:51:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9BE93954C73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1668581519; bh=l0vFr+PZww7+hh8OBCfjy9jlORvkd9GsbNlfzkqFLoM=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=cxrb8MdsvfGZ16ePcxmrO2dcE532ThFFchFJf1J317Jy/1WZ4wfit8jg5p7EmnUhN 2cxwHPmsW5o1tJ3Ix2s/SF+FAeFlZziBYpM3/wFsnDmiJPmq0Hf+CFSHptmKxKnf+R /pJQ9KdE4n5hXWLrdD5Pw8pXWHyEdtArIp72/2ZA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 5A2503954C57 for ; Wed, 16 Nov 2022 06:51:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5A2503954C57 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AG6eSdv015358; Wed, 16 Nov 2022 06:51:14 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kvsqah5m2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 06:51:13 +0000 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AG6lG1S005056; Wed, 16 Nov 2022 06:51:13 GMT Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3kvsqah5kf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 06:51:13 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AG6ZarG021224; Wed, 16 Nov 2022 06:51:11 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 3kt349c1yd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 16 Nov 2022 06:51:11 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AG6j91C26214856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Nov 2022 06:45:09 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 378634C044; Wed, 16 Nov 2022 06:51:08 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 275294C040; Wed, 16 Nov 2022 06:51:06 +0000 (GMT) Received: from [9.197.233.36] (unknown [9.197.233.36]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 16 Nov 2022 06:51:05 +0000 (GMT) Message-ID: <247bf71b-e0ab-7cf7-098b-a106a0764301@linux.ibm.com> Date: Wed, 16 Nov 2022 14:51:04 +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: [PATCH 2/2] rs6000: Refine integer comparison handlings in rs6000_emit_vector_compare Content-Language: en-US To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , Peter Bergner , Michael Meissner References: In-Reply-To: X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: WJmjDWiSh5_qxtefsuAVe2I6qw29lssD X-Proofpoint-GUID: IJMVGG1eAQsYl5PVSzDxxYEf5SBB3VpI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-15_08,2022-11-15_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 suspectscore=0 phishscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211160046 X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, 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?1749634536421908926?= X-GMAIL-MSGID: =?utf-8?q?1749634536421908926?= Hi, The current handlings in rs6000_emit_vector_compare is a bit complicated to me, especially after we emit vector float comparison insn with the given code directly. This patch is to refine the handlings for vector integer comparison operators, it becomes not recursive, and we don't need the helper function rs6000_emit_vector_compare_inner any more. Bootstrapped and regtested on powerpc64-linux-gnu P7 and P8, and powerpc64le-linux-gnu P9 and P10. I'm going to push this later this week if no objections. BR, Kewen ----- gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_emit_vector_compare_inner): Remove. (rs6000_emit_vector_compare): Refine it by directly using the reversed or swapped code, to avoid the recursion. --- gcc/config/rs6000/rs6000.cc | 159 ++++++++---------------------------- 1 file changed, 34 insertions(+), 125 deletions(-) -- 2.27.0 diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 56db12f08a0..21f4cda7b80 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -15639,169 +15639,78 @@ output_cbranch (rtx op, const char *label, int reversed, rtx_insn *insn) return string; } -/* Return insn for VSX or Altivec comparisons. */ - -static rtx -rs6000_emit_vector_compare_inner (enum rtx_code code, rtx op0, rtx op1) -{ - rtx mask; - machine_mode mode = GET_MODE (op0); - - switch (code) - { - default: - break; - - case GE: - if (GET_MODE_CLASS (mode) == MODE_VECTOR_INT) - return NULL_RTX; - /* FALLTHRU */ - - case EQ: - case GT: - case GTU: - mask = gen_reg_rtx (mode); - emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, mode, op0, op1))); - return mask; - } - - return NULL_RTX; -} - /* Emit vector compare for operands OP0 and OP1 using code RCODE. - DMODE is expected destination mode. This is a recursive function. */ + DMODE is expected destination mode. */ static rtx rs6000_emit_vector_compare (enum rtx_code rcode, rtx op0, rtx op1, machine_mode dmode) { - rtx mask; gcc_assert (VECTOR_UNIT_ALTIVEC_OR_VSX_P (dmode)); gcc_assert (GET_MODE (op0) == GET_MODE (op1)); + rtx mask = gen_reg_rtx (dmode); /* In vector.md, we support all kinds of vector float point comparison operators in a comparison rtl pattern, we can just emit the comparison rtx insn directly here. Besides, we should have a centralized place to handle the possibility - of raising invalid exception. */ - if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT) + of raising invalid exception. Also emit directly for vector + integer comparison operators EQ/GT/GTU. */ + if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT + || rcode == EQ + || rcode == GT + || rcode == GTU) { - mask = gen_reg_rtx (dmode); emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1))); return mask; } bool swap_operands = false; - bool try_again = false; - - /* See if the comparison works as is. */ - mask = rs6000_emit_vector_compare_inner (rcode, op0, op1); - if (mask) - return mask; + bool need_invert = false; + enum rtx_code code = UNKNOWN; switch (rcode) { case LT: - rcode = GT; - swap_operands = true; - try_again = true; - break; case LTU: - rcode = GTU; + code = swap_condition (rcode); swap_operands = true; - try_again = true; break; case NE: - /* Invert condition and try again. - e.g., A != B becomes ~(A==B). */ - { - enum rtx_code rev_code; - enum insn_code nor_code; - rtx mask2; - - rev_code = reverse_condition_maybe_unordered (rcode); - if (rev_code == UNKNOWN) - return NULL_RTX; - - nor_code = optab_handler (one_cmpl_optab, dmode); - if (nor_code == CODE_FOR_nothing) - return NULL_RTX; - - mask2 = rs6000_emit_vector_compare (rev_code, op0, op1, dmode); - if (!mask2) - return NULL_RTX; - - mask = gen_reg_rtx (dmode); - emit_insn (GEN_FCN (nor_code) (mask, mask2)); - return mask; - } + case LE: + case LEU: + code = reverse_condition (rcode); + need_invert = true; break; case GE: + code = GT; + swap_operands = true; + need_invert = true; + break; case GEU: - case LE: - case LEU: - /* Try GT/GTU/LT/LTU OR EQ */ - { - rtx c_rtx, eq_rtx; - enum insn_code ior_code; - enum rtx_code new_code; - - switch (rcode) - { - case GE: - new_code = GT; - break; - - case GEU: - new_code = GTU; - break; - - case LE: - new_code = LT; - break; - - case LEU: - new_code = LTU; - break; - - default: - gcc_unreachable (); - } - - ior_code = optab_handler (ior_optab, dmode); - if (ior_code == CODE_FOR_nothing) - return NULL_RTX; - - c_rtx = rs6000_emit_vector_compare (new_code, op0, op1, dmode); - if (!c_rtx) - return NULL_RTX; - - eq_rtx = rs6000_emit_vector_compare (EQ, op0, op1, dmode); - if (!eq_rtx) - return NULL_RTX; - - mask = gen_reg_rtx (dmode); - emit_insn (GEN_FCN (ior_code) (mask, c_rtx, eq_rtx)); - return mask; - } + code = GTU; + swap_operands = true; + need_invert = true; break; default: - return NULL_RTX; + gcc_unreachable (); + break; } - if (try_again) - { - if (swap_operands) - std::swap (op0, op1); + if (swap_operands) + std::swap (op0, op1); + + emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1))); - mask = rs6000_emit_vector_compare_inner (rcode, op0, op1); - if (mask) - return mask; + if (need_invert) + { + enum insn_code nor_code = optab_handler (one_cmpl_optab, dmode); + gcc_assert (nor_code != CODE_FOR_nothing); + emit_insn (GEN_FCN (nor_code) (mask, mask)); } - /* You only get two chances. */ - return NULL_RTX; + return mask; } /* Emit vector conditional expression. DEST is destination. OP_TRUE and