From patchwork Fri Apr 12 06:17:15 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: 1922851 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=pIzdjZ18; 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 4VG5wW1QwGz1yYL for ; Fri, 12 Apr 2024 16:18:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BD49385828B for ; Fri, 12 Apr 2024 06:18:16 +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 A5F083858CDB for ; Fri, 12 Apr 2024 06:17:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A5F083858CDB 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 A5F083858CDB 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=1712902671; cv=none; b=h8JumPubuvoadi6xjnKKceI/1br9ZGv1NOGj+Rk848MJ1MF5N04PFZjVefdvucQ5GAcnfL76Z82wNAoCCcIMULBnOtz8ytEPyer/qIZD69gzJUyS8LMvHs+8MH+JpaMkalHjrgp8h+3+oTU9HQkuy0xgHtfiWDDqIz6w+soyhyY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712902671; c=relaxed/simple; bh=jyMCyvU9KtHBi9rYhEJxaAQsEhcLdMJSQccnoD4lw58=; h=DKIM-Signature:Message-ID:Date:To:From:Subject:MIME-Version; b=JTnffJJdMUC3FB00OBdshftXYuhfWvKHf1H1z3np64xlPbTU/WaJEA5EE+W5kV6xmDx3e0yZWOWiASwFGBjHdidB6OqaXpUoJa2UsrD5GR05G7AK56PgimO5CjAFCOQCDQ856jivxtfGEH3bxCpgL5o74uxJkLzGBGwY80S5s78= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 43C6H6ui006960; Fri, 12 Apr 2024 06:17:48 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=4emBFenxsN4/+TvsjGYnfrkzTvFY3tov43R3fy4TuXs=; b=pIzdjZ18WmSMZvMNemyfE/BlaYnsHECQKRdC3gcAjlsdy97InSUFDqN1BSZj1tLlJnFa hfXdD5r3+3dYbQpVvnRscnuMWFsvS4cvhUsNMTv2LsONZkyYW5YCBSjEZxgtdIz0eCle qr/XmSQrxSHSSnWmrU20hk4xfnHTlOEGoiqozUi3MFq2ejI5ckJlH4KKsq7Ded6l+OKT smpYUL48he8TCV8gyALhsbZQY+xEdQ8IppD1zogYzt0xQXSpu+S3OTQEBtXaDk62zwbG EHBoyRkvPnZszFCALKfVB3vcrJwksOnFVcTFAMR+kAnmS/IbSS50TkiOMvfn64jGNO7b sg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xeyj3r01a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 06:17:48 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 43C6HlNS007827; Fri, 12 Apr 2024 06:17:47 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3xeyj3r017-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 06:17:47 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 43C3cmOD013539; Fri, 12 Apr 2024 06:17:47 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3xbgqu0dkf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 12 Apr 2024 06:17:46 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 43C6HeCZ44499246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Apr 2024 06:17:42 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 83A162009E; Fri, 12 Apr 2024 06:17:34 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDD39200AC; Fri, 12 Apr 2024 06:17:15 +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:17:15 +0000 (GMT) Message-ID: Date: Fri, 12 Apr 2024 14:17:15 +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-3] Builtin: Fold builtin_isfinite on IBM long double to builtin_isfinite on double [PR97786] X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 8uwgysZwEAFmUV7HXMGaITBGTSp4S3U1 X-Proofpoint-GUID: wUT-BNz1hD4YGciyhkWLGooyEK5GKLBH 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 clxscore=1015 priorityscore=1501 lowpriorityscore=0 adultscore=0 bulkscore=0 mlxlogscore=886 mlxscore=0 phishscore=0 impostorscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2404010000 definitions=main-2404120043 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 folds builtin_isfinite on IBM long double to builtin_isfinite on double type. The former patch https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649346.html implemented the DFmode isfinite_optab. Bootstrapped and tested on powerpc64-linux BE and LE with no regressions. Is it OK for next stage 1? Thanks Gui Haochen ChangeLog Builtin: Fold builtin_isfinite on IBM long double to builtin_isfinite on double For IBM long double, INF and NAN is encoded in the high-order double value only. So the builtin_isfinite on IBM long double can be folded to builtin_isfinite on double type. As former patch implemented DFmode isfinite_optab, this patch converts builtin_isfinite on IBM long double to builtin_isfinite on double type if the DFmode isfinite_optab exists. gcc/ PR target/97786 * builtins.cc (fold_builtin_interclass_mathfn): Fold IBM long double isfinite call to double isfinite call when DFmode isfinite_optab exists. gcc/testsuite/ PR target/97786 * gcc.target/powerpc/pr97786-6.c: New test. patch.diff diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 5262aa01660..3174f52ebe8 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -9605,6 +9605,12 @@ fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg) type = double_type_node; mode = DFmode; arg = fold_build1_loc (loc, NOP_EXPR, type, arg); + tree const isfinite_fn = builtin_decl_explicit (BUILT_IN_ISFINITE); + if (interclass_mathfn_icode (arg, isfinite_fn) != CODE_FOR_nothing) + { + result = build_call_expr (isfinite_fn, 1, arg); + return result; + } } get_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf), false); real_from_string (&r, buf); diff --git a/gcc/testsuite/gcc.target/powerpc/pr97786-6.c b/gcc/testsuite/gcc.target/powerpc/pr97786-6.c new file mode 100644 index 00000000000..c86c765651d --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/pr97786-6.c @@ -0,0 +1,12 @@ +/* { 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=ibmlongdouble -Wno-psabi" } */ + +int test1 (long double x) +{ + return __builtin_isfinite (x); +} + +/* { dg-final { scan-assembler-not {\mfcmpu\M} } } */ +/* { dg-final { scan-assembler {\mxststdcdp\M} } } */