From patchwork Thu Nov 24 09:15:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 25391 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp3281945wrr; Thu, 24 Nov 2022 01:18:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HrOg6G9DIgMFv1wfu5bCsJvun9B0cniqiSpD4N79uhbaCFrRlPLVRQGmOvQCnI+uk2EfG X-Received: by 2002:a17:907:8b19:b0:7b5:3288:2cb with SMTP id sz25-20020a1709078b1900b007b5328802cbmr17897641ejc.638.1669281527318; Thu, 24 Nov 2022 01:18:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669281527; cv=none; d=google.com; s=arc-20160816; b=qvTWgFYbxXumfYOzGgGUz7U4VfN2JbxYwNifI6n1kaRCsitbCUTPKNgZuoo2P8o6ps 80M/sdDqZRv10NjLMLt8cy27SF5Ap3vCnMairCFIs+iuEz0ektaAB6zNeKnHZ6hRwQoV f4YDQVbZRFMD4OTLpq2DYTcvRnmaSejlsuyGFbGX7+4LsCJdaiVncMbFwDP7iS2IUWvg GQrjtqtVeLuvz7/ZfNf7HzTPvLmQqK5q85DntlwDrS6B6+Wn9zE9zuny4dZYeQMPqV3D jeL+/4PLfoCidB21AGNYQdKxHnmVhMywZzLWUmPoBghENjj/cWAmZONs6fmTtDrfet7B 9dDw== 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=Onv7GAkdDSIeFug9FPT3aWfwfZBH+TkVXKchL9HN+Co=; b=tshqtliXZ4giZTmS9f2Yy1blfW6MXzF/XTP0TaFrZgkAYPLykytr2HoL4xVSgf6O7D 8Yl8G2olp2uMPTUJx5HtAE+dKMg0iba25SeiP1Vxq24FEha0t6jDsitDADqswq4ZokHR uzZdyNnWXgp5pO5JUKuxY16QZMq50oJFiT29yPycoPmc1mmUw7hZbb3WgAEyWPBlbMqU 7EP3H5iG900azu/xs370q98pYI8RbCbJyekINuCHMW8v50rJP2VV9QvcB3KIV7Le1/72 AyX16fhLKQanXUnfyqjKkc8HtJAlSNZGGyAkmPEs+DTV2a7nVwjHcB+y6elnSIg2bEml jYsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ksXlPOOh; 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 mp14-20020a1709071b0e00b00781dbee4273si546634ejc.514.2022.11.24.01.18.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Nov 2022 01:18:47 -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=ksXlPOOh; 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 C3DCD3841446 for ; Thu, 24 Nov 2022 09:18:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3DCD3841446 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669281489; bh=Onv7GAkdDSIeFug9FPT3aWfwfZBH+TkVXKchL9HN+Co=; 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=ksXlPOOh+zIsRd3tNZ/LK2/+QEgYzx8uUGnsg4LVca9rusZx7V66wubax8itosPju dUJwkPDP3aZ4ztuVWC8ZjHyFeqBbAAZ5uprc7Raez3bFlIBg9n+g9QOK2/R9mhJKKl JoAFqwgflllrDdUoiCrMmODfXKlVeUsQ3LWYIA9o= 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 D03DE38425BC for ; Thu, 24 Nov 2022 09:17:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D03DE38425BC 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 2AO84RHg002530; Thu, 24 Nov 2022 09:17:00 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m1xk91g45-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:17:00 +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 2AO7w7ac001361; Thu, 24 Nov 2022 09:16:59 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 3m1xk91g38-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:16:59 +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 2AO95Pm9026415; Thu, 24 Nov 2022 09:16:57 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 3kxpdhyx57-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 24 Nov 2022 09:16:57 +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 2AO9HaEW57475406 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 24 Nov 2022 09:17:36 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 99E0742045; Thu, 24 Nov 2022 09:16:54 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 99D5E4203F; Thu, 24 Nov 2022 09:16:53 +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:16:53 +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 3/9] rs6000: Rework vector float comparison in rs6000_emit_vector_compare - p3 Date: Thu, 24 Nov 2022 03:15:51 -0600 Message-Id: <20221124091557.514727-4-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: HI8CePGvgEABI1GRbu7yrBlPDddpcm80 X-Proofpoint-GUID: bQsfvsl3gQ2s1pHU5kHk_y8Q3Um0sCkv 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.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, 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?1750368546836584988?= X-GMAIL-MSGID: =?utf-8?q?1750368546836584988?= All kinds of vector float comparison operators have been supported in a 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 part 3, it further checks for comparison opeators LE/UNGT. In rs6000_emit_vector_compare, UNGT is handled with reversed code LE and inverting with one_cmpl_optab, LE is handled with LT ior EQ, while in vector.md, we have the support: ; le(a,b) = ge(b,a) ; ungt(a,b) = ~le(a,b) The associated test case shows it's an improvement. gcc/ChangeLog: * config/rs6000/rs6000.cc (rs6000_emit_vector_compare): Emit rtx comparison for operators LE/UNGT of MODE_VECTOR_FLOAT directly. gcc/testsuite/ChangeLog: * gcc.target/powerpc/vcond-fp.c: New test. --- gcc/config/rs6000/rs6000.cc | 9 ++++---- gcc/testsuite/gcc.target/powerpc/vcond-fp.c | 25 +++++++++++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.target/powerpc/vcond-fp.c diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc index 09299bef6a2..98754805bd2 100644 --- a/gcc/config/rs6000/rs6000.cc +++ b/gcc/config/rs6000/rs6000.cc @@ -15682,15 +15682,15 @@ rs6000_emit_vector_compare (enum rtx_code rcode, of raising invalid exception. For EQ/GT/GE/UNORDERED/ ORDERED/LTGT/UNEQ, they are handled equivalently as before; for NE/UNLE/UNLT, they are handled with reversed code - and inverting, it's the same as before. + and inverting, it's the same as before; for LE/UNGT, they + are handled with LE ior EQ previously, emitting directly + here will make use of GE later, it's slightly better; FIXME: Handle the remaining vector float comparison operators here. */ if (GET_MODE_CLASS (dmode) == MODE_VECTOR_FLOAT && rcode != LT - && rcode != LE - && rcode != UNGE - && rcode != UNGT) + && rcode != UNGE) { mask = gen_reg_rtx (dmode); emit_insn (gen_rtx_SET (mask, gen_rtx_fmt_ee (rcode, dmode, op0, op1))); @@ -15719,7 +15719,6 @@ rs6000_emit_vector_compare (enum rtx_code rcode, break; case NE: case UNGE: - case UNGT: /* Invert condition and try again. e.g., A != B becomes ~(A==B). */ { diff --git a/gcc/testsuite/gcc.target/powerpc/vcond-fp.c b/gcc/testsuite/gcc.target/powerpc/vcond-fp.c new file mode 100644 index 00000000000..b71861d3588 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/vcond-fp.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target powerpc_p8vector_ok } */ +/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model -mpower8-vector" } */ + +/* Test we use xvcmpge[sd]p rather than xvcmpeq[sd]p and xvcmpgt[sd]p + for UNGT and LE handlings. */ + +#define UNGT(a, b) (!__builtin_islessequal ((a), (b))) +#define LE(a, b) (((a) <= (b))) + +#define TEST_VECT(NAME, TYPE) \ + __attribute__ ((noipa)) void test_##NAME##_##TYPE (TYPE *x, TYPE *y, \ + int *res, int n) \ + { \ + for (int i = 0; i < n; i++) \ + res[i] = NAME (x[i], y[i]); \ + } + +#define TEST(TYPE) \ + TEST_VECT (UNGT, TYPE) \ + TEST_VECT (LE, TYPE) + +TEST (float) +TEST (double) + +/* { dg-final { scan-assembler-not {\mxvcmp(gt|eq)[sd]p\M} } } */