From patchwork Fri Apr 12 06:02:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HAO CHEN GUI X-Patchwork-Id: 1922848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Q38csMXq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VG5bl2xygz1yYL for ; Fri, 12 Apr 2024 16:03:45 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B297C3858C66 for ; Fri, 12 Apr 2024 06:03:43 +0000 (GMT) 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 4C6633858D33 for ; Fri, 12 Apr 2024 06:03:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C6633858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4C6633858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712901803; cv=none; b=T38nT1LmmTEc87COkYRDpB8RppCm5iuG8QITv2u8pZGF9nSgugUwefv9o2eZwKMkCodeoLVWRCF8BnNkDIIgOwPKqgS7pCmJPYkAK/CXIsTga8ssT5L7mAdUbuQTHSakZpz4UvVec6rRsweN9ANlh8cdnnO8dr1aeERnLIeJsus= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712901803; c=relaxed/simple; bh=Ow3SSgvyr0trD+NGDLDA9Da1tdQBjGWapO4DGtG5n4E=; h=DKIM-Signature:Message-ID:Date:To:From:Subject:MIME-Version; b=UtTpjIBrkhA2K0FVkLnoVZg3o2dlNo38Zq1RtRS6ThrshQ9zpRnfSakFXpXEOICCPFBuntDfm+ttUrPEbN5pr43FCiC/tRzafuiybqncsyG+eSZmBuT5OFBJBa6YZSEpysu6trq79XI1OzMAGmwT9Ur78xvQYaN57j2FgTACcQI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43C637AW009223; Fri, 12 Apr 2024 06:03:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : to : cc : from : subject : content-type : content-transfer-encoding : mime-version; s=pp1; bh=PWK0UwjVhp+4eLrRKiCj2VolqOYSQX9XSrfS+mD/oyU=; b=Q38csMXqCSn4rZ6sI6Urm4y0TNhDvaTU9IpT/TepSq6/nUpJYgo9fyd/f+CNu/8ZDo0d bzSlP64JzIV4fJwajfm1bibDg1+Kg9H2lLNQZd73/gBBd4ldVKbqcDkT7yXa421Wrs7h xVYZBkVjuHODTOdmaqWvb+jVmWiYLUC3d4Y09iPf/7nAWBvm8/8QRv/SHi0rYkSeOzQD 78ih8VJEeVCABKwPcwON5mcCvHWqz9z6dT5dRnV9qkIUe4lPBdK4ZqnyHR6AKcNhKtD4 DiyX3ZY18lhmwfv6hlO7C1GV8XuHT/Fhrg/gtY/LUgargmcmIjYmHDju0R9Bca59FBfa lA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xeyb7801c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 06:03:19 +0000 Received: from m0353729.ppops.net (m0353729.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43C63J9u009580; Fri, 12 Apr 2024 06:03:19 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xeyb7801a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 06:03:19 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43C44dXG019089; Fri, 12 Apr 2024 06:03:18 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3xbh40r93a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 06:03:18 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43C63C5R28443370 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 06:03:14 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 67F882004D; Fri, 12 Apr 2024 06:03:12 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA7E12004B; Fri, 12 Apr 2024 06:02:56 +0000 (GMT) Received: from [9.69.93.160] (unknown [9.69.93.160]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP; Fri, 12 Apr 2024 06:02:45 +0000 (GMT) Message-ID: Date: Fri, 12 Apr 2024 14:02:42 +0800 User-Agent: Mozilla Thunderbird Content-Language: en-US To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner From: HAO CHEN GUI Subject: [PATCH-2, rs6000] Implement optab_isfinite for SFmode, DFmode and TFmode [PR97786] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Cdm-5MG5ph9SoieKwA0BFIQ20RWaOAb7 X-Proofpoint-GUID: twPVjrg_sR0G5TurI_HzcsYKg_SCFJOV X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-04-12_02,2024-04-09_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 phishscore=0 clxscore=1015 spamscore=0 bulkscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120041 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, This patch implemented optab_finite for SF/DF/TFmode by rs6000 test data class instructions. This patch relies on former patch which adds optab_finite. https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649339.html Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is it OK for next stage 1? Thanks Gui Haochen ChangeLog rs6000: Implement optab_isfinite for SFmode, DFmode and TFmode gcc/ PR target/97786 * config/rs6000/vsx.md (isfinite2): New expand for SFmode and DFmode. (isfinite2): New expand for TFmode. gcc/testsuite/ PR target/97786 * gcc.target/powerpc/pr97786-4.c: New test. * gcc.target/powerpc/pr97786-5.c: New test. patch.diff diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md index f0cc02f7e7b..a6c72ae33b0 100644 --- a/gcc/config/rs6000/vsx.md +++ b/gcc/config/rs6000/vsx.md @@ -5333,6 +5333,31 @@ (define_expand "isinf2" DONE; }) +(define_expand "isfinite2" + [(use (match_operand:SI 0 "gpc_reg_operand")) + (use (match_operand:SFDF 1 "gpc_reg_operand"))] + "TARGET_HARD_FLOAT + && TARGET_P9_VECTOR" +{ + rtx tmp = can_create_pseudo_p () ? gen_reg_rtx (SImode) : operands[0]; + emit_insn (gen_xststdcp (tmp, operands[1], GEN_INT (0x70))); + emit_insn (gen_xorsi3 (operands[0], tmp, const1_rtx)); + DONE; +}) + +(define_expand "isfinite2" + [(use (match_operand:SI 0 "gpc_reg_operand")) + (use (match_operand:IEEE128 1 "gpc_reg_operand"))] + "TARGET_HARD_FLOAT + && TARGET_P9_VECTOR" +{ + rtx tmp = can_create_pseudo_p () ? gen_reg_rtx (SImode) : operands[0]; + emit_insn (gen_xststdcqp_ (tmp, operands[1], GEN_INT (0x70))); + emit_insn (gen_xorsi3 (operands[0], tmp, const1_rtx)); + DONE; +}) + + ;; The VSX Scalar Test Negative Quad-Precision (define_expand "xststdcnegqp_" [(set (match_dup 2) diff --git a/gcc/testsuite/gcc.target/powerpc/pr97786-4.c b/gcc/testsuite/gcc.target/powerpc/pr97786-4.c new file mode 100644 index 00000000000..55b5ff507b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr97786-4.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power9 -mvsx" } */ + +int test1 (double x) +{ + return __builtin_isfinite (x); +} + +int test2 (float x) +{ + return __builtin_isfinite (x); +} + +/* { dg-final { scan-assembler-not {\mfcmpu\M} } } */ +/* { dg-final { scan-assembler-times {\mxststdc[sd]p\M} 2 } } */ diff --git a/gcc/testsuite/gcc.target/powerpc/pr97786-5.c b/gcc/testsuite/gcc.target/powerpc/pr97786-5.c new file mode 100644 index 00000000000..5b5a89681fc --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr97786-5.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target lp64 } } */ +/* { dg-require-effective-target ppc_float128_sw } */ +/* { dg-require-effective-target powerpc_vsx_ok } */ +/* { dg-options "-O2 -mdejagnu-cpu=power9 -mvsx -mabi=ieeelongdouble -Wno-psabi" } */ + +int test1 (long double x) +{ + return __builtin_isfinite (x); +} + + +/* { dg-final { scan-assembler-not {\mxscmpuqp\M} } } */ +/* { dg-final { scan-assembler {\mxststdcqp\M} } } */