From patchwork Thu Nov 24 09:15:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 25393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3282101wrr; Thu, 24 Nov 2022 01:19:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf420pJheGGvF7q8WFf27JxLe2EUBciGGXdHmnP5NNs/izHwND6/NEI9fxx190vNQqTYrZxh X-Received: by 2002:a05:6402:1744:b0:459:2d37:dfbd with SMTP id v4-20020a056402174400b004592d37dfbdmr14764119edx.336.1669281555774; Thu, 24 Nov 2022 01:19:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669281555; cv=none; d=google.com; s=arc-20160816; b=TWXF1CMHr4vO3QtCteNQw0kgR8vTjB06xltm/EFI20osCfyP3Y/uwLd7qx5izkjBZb rBy8ZJhsNw5rvbmV9kXy051HpDaek7SYNGpBKs+95qHZxp0v0lWgu6F/yZXVV757utLJ leMYam+CggZXTT3QjZQ1xBH9h7Tk2pfvLcB+D8XPyeM6x1ARRDEy/xiz8o5k7JsytCEg rtBIuw8i8zUJcb/8vx1LGiDkauqMzWes20oWRgtMAhIlX3hbJBAYBeJMkqaW+t1VfiIm 76em4u0G3mdQFQk9CoKQidSDWlRnLKXkV+5cuWLt3yAksHf9omG63DUfJairnRlk82AN GpIg== 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=bTwVgI3n/OwH2U8k5/NnZopdJ1HLqG+MYKoondA2BQQ=; b=D0lis9ZyH1U5L7wXt1G0Jfab/6FUT/G3a29QtwMRO3OVoRnchKUkWrEUwk0tn/ARK1 hQ4j+tMBD0nCVXXmDdEaXMvDSEHUVju1QBIvde+DJLRhfQ/xdikEyTYMXzi9ZNXq0Avx k6R/ZJpnxiQfV+uRl8VWpsK3CoquZl+T2FSKh5vRcTKWvrcXPfi45JEJSsNxK0PpbZoj PQnfeJ7KyKVoArus8xfq3GSbE0o+R5sVmWjTv7effPiKAJe1JHV+P3jYLOAKAkTezT7R p6W+mxsCT1ur1oZC7Sizzxik0C5wRICafNnUZgKbtvRk6jtjOch3E9c1PwusDHb+TasA CuHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=nnwWgVeb; 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 di13-20020a170906730d00b00782e437a368si553551ejc.160.2022.11.24.01.19.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 01:19:15 -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=nnwWgVeb; 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 E2FEE382EF06 for ; Thu, 24 Nov 2022 09:18:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E2FEE382EF06 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669281505; bh=bTwVgI3n/OwH2U8k5/NnZopdJ1HLqG+MYKoondA2BQQ=; 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=nnwWgVebJeRSGHbkVMDAZuolGAoJ2/hqPtAebcbmAryoU7LR2rL/A+eND035iKjZu YSpgoObJ5hc6y0uAf5YLqZQVZLkSNIqGFMX5QT5XTXqok5rKqg3aney3gR4xcT6sCn X2KlrQy7cRNXJSbKSXFq2XsmT3zC/ydDz/4KQMOc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 88F233870C01 for ; Thu, 24 Nov 2022 09:17:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 88F233870C01 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2AO7qJ6P002386; Thu, 24 Nov 2022 09:17:14 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m1xk91g9d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:13 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2AO9B71Z002932; Thu, 24 Nov 2022 09:17:13 GMT Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m1xk91g8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:13 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2AO960km026732; Thu, 24 Nov 2022 09:17:11 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma06ams.nl.ibm.com with ESMTP id 3kxpdhyx5n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:11 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2AO9HnWI5046870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Nov 2022 09:17:50 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 74DF34203F; Thu, 24 Nov 2022 09:17:08 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DDD542041; Thu, 24 Nov 2022 09:17:07 +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:07 +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 9/9] rs6000: Rework vector integer comparison in rs6000_emit_vector_compare - p5 Date: Thu, 24 Nov 2022 03:15:57 -0600 Message-Id: <20221124091557.514727-10-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: GmTVno1Ciz2sJsEePT1lWr_8W0YvQ5mv X-Proofpoint-GUID: bBKbvvbaSJF1mlkzsbRZy_UzqfPL8meI 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 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 phishscore=0 impostorscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2211240072 X-Spam-Status: No, score=-12.3 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?1750368576779318694?= X-GMAIL-MSGID: =?utf-8?q?1750368576779318694?= 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 5, it's to refactor all the handlings of vector integer comparison to make it neat. This patch doesn't introduce any functionality change. gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_emit_vector_compare): Refactor the handlings of vector integer comparison. --- gcc/config/rs6000/rs6000.cc | 68 ++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index a3645e321a7..b694080840a 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -15662,34 +15662,54 @@ rs6000_emit_vector_compare (enum rtx_code rcode, return mask; } - /* For any of vector integer comparison operators for which we - have direct hardware instructions, just emit it directly - here. */ - if (rcode == EQ || rcode == GT || rcode == GTU) - emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1))); - else if (rcode == LT || rcode == LTU) + bool swap_operands = false; + bool need_invert = false; + enum rtx_code code = rcode; + + switch (rcode) { + case EQ: + case GT: + case GTU: + /* Emit directly with native hardware insn. */ + break; + case LT: + case 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))); + code = swap_condition (rcode); + swap_operands = true; + break; + case NE: + case LE: + case LEU: + /* ne(a,b) = ~eq(a,b); le{,u}(a,b) = ~gt{,u}(a,b) */ + code = reverse_condition (rcode); + need_invert = true; + break; + case GE: + /* ge(a,b) = ~gt(b,a) */ + code = GT; + swap_operands = true; + need_invert = true; + break; + case GEU: + /* geu(a,b) = ~gtu(b,a) */ + code = GTU; + swap_operands = true; + need_invert = true; + break; + default: + gcc_unreachable (); + break; } - else if (rcode == NE || rcode == LE || rcode == LEU) + + if (swap_operands) + std::swap (op0, op1); + + emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1))); + + if (need_invert) { - /* ne(a,b) = ~eq(a,b); le{,u}(a,b) = ~gt{,u}(a,b) */ - enum rtx_code code = reverse_condition (rcode); - mask = gen_reg_rtx (dmode); - emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1))); - 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)); - } else { - /* ge{,u}(a,b) = ~gt{,u}(b,a) */ - gcc_assert (rcode == GE || rcode == GEU); - enum rtx_code code = rcode == GE ? GT : GTU; - mask = gen_reg_rtx (dmode); - emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (code, dmode, op0, op1))); 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));