From patchwork Thu Nov 24 09:15:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 25392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3282020wrr; Thu, 24 Nov 2022 01:19:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fNIL+41Tw37uSfqct7AWHnKkPfQuD2UIJf/dnqyyPs1n+H9gsRR2gG7CBBOhcxuPoHock X-Received: by 2002:a17:907:6d12:b0:7b2:bb8c:5398 with SMTP id sa18-20020a1709076d1200b007b2bb8c5398mr16575851ejc.573.1669281540731; Thu, 24 Nov 2022 01:19:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669281540; cv=none; d=google.com; s=arc-20160816; b=yRELJary0BMeLdWDIDH85CZLNR82OA/o3wmol3JqiMdYEYzfbdSexXkkSKRdPNkbWe 2Iz01gAjs9jEgAViz7CSerp99KtvoFp+DIKVkjOxYO9yR5lUEj6m3hOe7HajesPxzdVH uwh5mHB6M9fZjqKY7kfhecgr6SE9aMFufZjbg4Mnq1mS/IbWAoJS5mNk4vz9cGzzg/uj VZY7irK1nhV+u/HPZIqOWyKKNAYHFIZsdym6obRzyVh52t0J857dXw8j90N4LL6hdqOB vs0PaC2BHHmy4+OeWMgkBntqSmmXV0+10Lt+SvXx4ioMGi/d2mjr5NbbiIldxku+8bo8 QF3w== 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:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=2jD+DuXs4PEYRFcLqESybRk2qz6wZuCfRr22fk3IVSU=; b=CnmjUFbO0GzzLQEn5dDZCiZqDL6nuybzaVPmkx7kBt3lSH8XupcPNLUxZWNNiWc/4J RRCUBydxeIJj4qbVR/MlIQFYl+or1OpdUaIB93lIUOWSQgOyCkjRdvvzqiskEMeTzUTg VGoFJZKARn/sUTLXGlHEfOGIS8IBPEubiwT8buW6J3bjo+aqw30l2QYIrLoIpYrgn97g /q29zUCVGFtMxiSBBiau3ixGKkQF2bvzcxYStq1USojAv+LGuYtqQOtCzJA1w2hGPfvm 1Q4n5LEu7QXREqGw05D2bY5vHM/adiI/fyONvKg0XMkoPOxEn6RCxOmSu4xrxuAWeCBw qmEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dArYzPgS; 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 j7-20020a05640211c700b00456964d3369si602793edw.230.2022.11.24.01.19.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 01:19: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=dArYzPgS; 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 28FBB382EF31 for ; Thu, 24 Nov 2022 09:18:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28FBB382EF31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669281498; bh=2jD+DuXs4PEYRFcLqESybRk2qz6wZuCfRr22fk3IVSU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=dArYzPgSmBzXWw8D0cFNEkI6X7vZiUia+egl0HOUaKTpuoluoV/HF2bCEsP3Yo1hI HfNVoZT1IVkI5cs+YZYm6RMfQVMvQDqNOtJPRQFEwqrZRpyjdOwzXtg6w5vQd8FCRc qAicITeIH5JY+7KSYSNjIKQ+VL+4K3w3IEtZe4+M= 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 0601F38518A6 for ; Thu, 24 Nov 2022 09:17:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0601F38518A6 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AO7ev2m014326; Thu, 24 Nov 2022 09:17:08 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10pgy6te-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:07 +0000 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AO8xKPa026367; Thu, 24 Nov 2022 09:17:07 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m10pgy6sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:07 +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 2AO95IIF008387; Thu, 24 Nov 2022 09:17:04 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3kxps8yw5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:04 +0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AO9Hh1e49807620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Nov 2022 09:17:43 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98C2E42045; Thu, 24 Nov 2022 09:17:01 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98DD54203F; Thu, 24 Nov 2022 09:17:00 +0000 (GMT) Received: from trout.aus.stglabs.ibm.com (unknown [9.40.194.100]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 24 Nov 2022 09:17:00 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: Kewen Lin , segher@kernel.crashing.org, dje.gcc@gmail.com, bergner@linux.ibm.com, meissner@linux.ibm.com Subject: [PATCH 6/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p2 Date: Thu, 24 Nov 2022 03:15:54 -0600 Message-Id: <20221124091557.514727-7-linkw@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20221124091557.514727-1-linkw@linux.ibm.com> References: <20221124091557.514727-1-linkw@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: KLeHAdRlxKFRO37fv3ajWQq9dlLHk-SJ X-Proofpoint-GUID: QVD-AYfxwpFlsYqyf0hZ0uvp112AHYcl 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-24_06,2022-11-23_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 clxscore=1015 impostorscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211240072 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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?1750368560961313433?= X-GMAIL-MSGID: =?utf-8?q?1750368560961313433?= 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. So it's better to refactor the handlings of vector integer comparison here. This is part 2, it's to refactor the handlings on LT and LTU. This patch doesn't introduce any functionality change. gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_emit_vector_compare): Refine the handlings for operators LT and LTU. --- gcc/config/rs6000/rs6000.cc | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 0a5826800c5..c1aebbb5c03 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -15672,22 +15672,18 @@ rs6000_emit_vector_compare (enum rtx_code rcode, emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1))); return mask; } - - bool swap_operands = false; - bool try_again = false; + else if (rcode == LT || rcode == LTU) + { + /* lt{,u}(a,b) = gt{,u}(b,a) */ + enum rtx_code code = swap_condition (rcode); + std::swap (op0, op1); + mask = gen_reg_rtx (dmode); + emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1))); + return mask; + } switch (rcode) { - case LT: - rcode = GT; - swap_operands = true; - try_again = true; - break; - case LTU: - rcode = GTU; - swap_operands = true; - try_again = true; - break; case NE: /* Invert condition and try again. e.g., A != B becomes ~(A==B). */ @@ -15761,16 +15757,6 @@ rs6000_emit_vector_compare (enum rtx_code rcode, return NULL_RTX; } - if (try_again) - { - if (swap_operands) - std::swap (op0, op1); - - mask = rs6000_emit_vector_compare (rcode, op0, op1, dmode); - if (mask) - return mask; - } - /* You only get two chances. */ return NULL_RTX; }