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 10E6C3858434 for ; Thu, 5 May 2022 09:31:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 10E6C3858434 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2457g7RA012757; Thu, 5 May 2022 09:31:10 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fvadw9vwb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 May 2022 09:31:09 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2459PriS030496; Thu, 5 May 2022 09:31:09 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fvadw9vvr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 May 2022 09:31:09 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2459S5hC007719; Thu, 5 May 2022 09:31:06 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06fra.de.ibm.com with ESMTP id 3fttcj2vr3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 May 2022 09:31:06 +0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2459V3RZ50135518 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 May 2022 09:31:03 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DBF65204F; Thu, 5 May 2022 09:31:03 +0000 (GMT) Received: from [9.197.252.62] (unknown [9.197.252.62]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 00D2A5204E; Thu, 5 May 2022 09:31:00 +0000 (GMT) Message-ID: <0aa8c058-5dd3-c7bf-935a-8df4947ebab0@linux.ibm.com> Date: Thu, 5 May 2022 17:30:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH] Skip constant folding for fmin/max when either argument is sNaN [PR105414] Content-Language: en-US To: "Kewen.Lin" , Richard Biener Cc: Peter Bergner , gcc-patches , Segher Boessenkool , David References: <4df302c6-5bc7-f6fb-916a-6dd9c0460268@linux.ibm.com> From: HAO CHEN GUI In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ce0gAkq-04SSwbAi2gt2Pz1Byzb0IV8b X-Proofpoint-GUID: CCgfIa86CxVqebBPJtTt57EdPGZMMTtV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-05_02,2022-05-05_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 phishscore=0 priorityscore=1501 malwarescore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205050063 X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-List-Received-Date: Thu, 05 May 2022 09:31:12 -0000 On 5/5/2022 下午 4:30, Kewen.Lin wrote: > on 2022/5/5 16:09, Richard Biener via Gcc-patches wrote: >> On Thu, May 5, 2022 at 10:07 AM HAO CHEN GUI via Gcc-patches >> wrote: >>> >>> Hi, >>> This patch skips constant folding for fmin/max when either argument >>> is sNaN. According to C standard, >>> fmin(sNaN, sNaN)= qNaN, fmin(sNaN, NaN) = qNaN >>> So signaling NaN should be tested and skipped for fmin/max in match.pd. >>> >>> Bootstrapped and tested on ppc64 Linux BE and LE with no regressions. >>> Is this okay for trunk? Any recommendations? Thanks a lot. >> >> OK. >> >> Thanks, >> Richard. >> >>> ChangeLog >>> >>> 2022-05-05 Haochen Gui >>> >>> gcc/ >>> PR target/105414 >>> * match.pd (minmax): Skip constant folding for fmin/fmax when both >>> arguments are sNaN or one is sNaN and another is NaN. >>> >>> gcc/testsuite/ >>> PR target/105414 >>> * gcc.dg/pr105414.c: New. >>> >>> patch.diff >>> >>> diff --git a/gcc/match.pd b/gcc/match.pd >>> index cad61848daa..f256bcbb483 100644 >>> --- a/gcc/match.pd >>> +++ b/gcc/match.pd >>> @@ -3093,7 +3093,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >>> (for minmax (min max FMIN_ALL FMAX_ALL) >>> (simplify >>> (minmax @0 @0) >>> - @0)) >>> + /* if both are sNaN, it should return qNaN. */ >>> + (if (!tree_expr_maybe_signaling_nan_p (@0)) >>> + @0))) > > Sorry for chiming in. > > IIUC this patch is mainly for libc function fmin/fmax and the iterator here > covers min/max and fmin/fmax. I wonder if it's intent to make this change > for min/max as well? > > As tree.def, "if either operand is NaN, then it is unspecified", the optimization > for min/max seems still acceptable? For MIN/MAX_EXPR, the result is undefined with NaN. So I think we shouldn't do constant folding. We should let target decide how to deal with it. The "undefined" here means the result depends on targets as far as I understand. > > BR, > Kewen