From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 337333858C32 for ; Tue, 28 May 2024 07:09:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 337333858C32 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 337333858C32 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=1716880164; cv=none; b=aYVbwsarJW314CjWekwrA8EphIhdfrS9I/tOwYHZ0fsts4/KzMqKg2sCOnuxHbe01UADvrf7trtVQJHVZEmrg1NZ0QJ6kiXd3pdOnXqtWJB8L7g3u+qlezFWdppnAleeT6DQYg7Id7y6hccvEIjpHsCqErLl6erIdqIY62BWoqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716880164; c=relaxed/simple; bh=a2U7IRjrWRqbYFuot+aklecphBayHdXmgGy+ZdAYS2Q=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=Nw216amQboP6i2DaLaIaTX7CHYKeKf0tZbIHYSa/GHmHjLg7fOH8Z0FXTT413mzxHaeXeTUvAVVnpREuCL+oSznbjJHEu0okrXjloxzbk66Tg8lCd2+fIfcM+NeJsyKjMCVpimS5Q3gydat9EejPOoMXAagQbgJOqv7AelZOfCo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 44S6AdVT004340; Tue, 28 May 2024 07:09:21 GMT DKIM-Signature: =?UTF-8?Q?v=3D1;_a=3Drsa-sha256;_c=3Drelaxed/relaxed;_d=3Dibm.com;_h=3Dcc?= =?UTF-8?Q?:content-transfer-encoding:content-type:date:from:in-reply-to:m?= =?UTF-8?Q?essage-id:mime-version:references:subject:to;_s=3Dpp1;_bh=3DEKZ?= =?UTF-8?Q?faUmD6/78ekmP+iPLDuYVrTYvAMNYsBFnElpA7CU=3D;_b=3DF+tATMiG4mUIPv?= =?UTF-8?Q?4t5RmR1FOWhywwJzcZmBjJV13r0a9vWWjR03N35pdSRSirKneNC6hf_2KmdWOKa?= =?UTF-8?Q?978ZnaiacD96OGuaEN9HwLoGGhrwxzjm83gXrG9RdGXyEk7gUSpJYKtcHg11_kQ?= =?UTF-8?Q?P/7rFMQ4LYlZTPObRdNhKbkRk3Vt6Ep7Z4B1m9lSOUd8LqE51NgOzyicu5ZzCHP?= =?UTF-8?Q?Nxn_qk7nYI1oTaz8Id4jHV4wHzhPSxcVYalVISvBvzei0MfxJMxNRoSsM0fq2yV?= =?UTF-8?Q?7kBx9WSn9_3zT7vIXOhEguIuFlDAl2O/JZNoOkbnUGhCUh6pj5wo58fW6Z1xIh7?= =?UTF-8?Q?gt50eV/z2MCupyf_vw=3D=3D_?= Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yd971r7u8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 May 2024 07:09:20 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 44S79Jts032746; Tue, 28 May 2024 07:09:20 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 3yd971r7u1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 May 2024 07:09:20 +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 44S4j5S7006749; Tue, 28 May 2024 07:09:19 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3ybtatdr60-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 28 May 2024 07:09:19 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 44S79DAe50463004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 28 May 2024 07:09:15 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C41C320043; Tue, 28 May 2024 07:09:13 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BF47520040; Tue, 28 May 2024 07:09:11 +0000 (GMT) Received: from [9.200.158.244] (unknown [9.200.158.244]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 28 May 2024 07:09:11 +0000 (GMT) Message-ID: <61a832c7-795b-581a-aec4-7c88c5e26360@linux.ibm.com> Date: Tue, 28 May 2024 15:09:10 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCHv3] Optab: add isfinite_optab for __builtin_isfinite Content-Language: en-US To: Richard Biener , HAO CHEN GUI Cc: gcc-patches , Segher Boessenkool , David , Peter Bergner , Andrew Pinski References: <936073f2-dfd4-4650-9b28-b905d97be477@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DejcJWRQMk_zUe5rtfLfT7nVbMXXy47W X-Proofpoint-GUID: 3S-oWQSi8HL-B5f-mvIPvy4YSp-YIlvz Content-Transfer-Encoding: 8bit X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-28_04,2024-05-27_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 impostorscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 clxscore=1015 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2405280051 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, on 2024/5/27 20:54, Richard Biener wrote: > On Mon, May 27, 2024 at 11:37 AM HAO CHEN GUI wrote: >> >> Hi, >> This patch adds an optab for __builtin_isfinite. The finite check can be >> implemented on rs6000 by a single instruction. It needs an optab to be >> expanded to the certain sequence of instructions. >> >> The subsequent patches will implement the expand on rs6000. >> >> Compared to previous version, the main change is to specify acceptable >> modes for the optab. >> https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652170.html >> >> Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no >> regressions. Is this OK for trunk? >> >> Thanks >> Gui Haochen >> >> ChangeLog >> optab: Add isfinite_optab for isfinite builtin >> >> gcc/ >> * builtins.cc (interclass_mathfn_icode): Set optab to isfinite_optab >> for isfinite builtin. >> * optabs.def (isfinite_optab): New. >> * doc/md.texi (isfinite): Document. >> >> >> patch.diff >> diff --git a/gcc/builtins.cc b/gcc/builtins.cc >> index f8d94c4b435..b8432f84020 100644 >> --- a/gcc/builtins.cc >> +++ b/gcc/builtins.cc >> @@ -2459,8 +2459,9 @@ interclass_mathfn_icode (tree arg, tree fndecl) >> errno_set = true; builtin_optab = ilogb_optab; break; >> CASE_FLT_FN (BUILT_IN_ISINF): >> builtin_optab = isinf_optab; break; >> - case BUILT_IN_ISNORMAL: >> case BUILT_IN_ISFINITE: >> + builtin_optab = isfinite_optab; break; >> + case BUILT_IN_ISNORMAL: >> CASE_FLT_FN (BUILT_IN_FINITE): >> case BUILT_IN_FINITED32: >> case BUILT_IN_FINITED64: >> diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi >> index 5730bda80dc..67407fad37d 100644 >> --- a/gcc/doc/md.texi >> +++ b/gcc/doc/md.texi >> @@ -8557,6 +8557,15 @@ operand 2, greater than operand 2 or is unordered with operand 2. >> >> This pattern is not allowed to @code{FAIL}. >> >> +@cindex @code{isfinite@var{m}2} instruction pattern >> +@item @samp{isfinite@var{m}2} >> +Set operand 0 to nonzero if operand 1 is a finite @code{SFmode}, >> +@code{DFmode}, or @code{TFmode} floating point number and to 0 > > It should probably say scalar floating-point mode? But what about the result? > Is any integer mode OK? That's esp. important if this might be used on > vector modes. > >> +otherwise. >> + >> +If this pattern @code{FAIL}, a call to the library function >> +@code{isfinite} is used. > > Or it's otherwise inline expanded? Or does this imply targets > have to make sure to implement the pattern when isfinite is > not available in libc/libm? I suggest to leave this sentence out, > we usually only say when a pattern may _not_ FAIL (and usually > FAILing isn't different from not providing a pattern). As Haochen's previous reply, I think there are three cases: 1) no optab defined, fold in a generic way; 2) optab defined, SUCC, expand as what it defines; 3) optab defined, FAIL, generate a library call; >From above, I had the concern that ports may assume FAILing can fall back with the generic folding, but it's not actually. Does your comment imply ports usually don't make such assumption (or they just check what happens for FAIL)? BR, Kewen > >> @end table >> >> @end ifset >> diff --git a/gcc/optabs.def b/gcc/optabs.def >> index ad14f9328b9..dcd77315c2a 100644 >> --- a/gcc/optabs.def >> +++ b/gcc/optabs.def >> @@ -352,6 +352,7 @@ OPTAB_D (fmod_optab, "fmod$a3") >> OPTAB_D (hypot_optab, "hypot$a3") >> OPTAB_D (ilogb_optab, "ilogb$a2") >> OPTAB_D (isinf_optab, "isinf$a2") >> +OPTAB_D (isfinite_optab, "isfinite$a2") >> OPTAB_D (issignaling_optab, "issignaling$a2") >> OPTAB_D (ldexp_optab, "ldexp$a3") >> OPTAB_D (log10_optab, "log10$a2")