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 C425F3856DED for ; Thu, 5 May 2022 08:30:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C425F3856DED Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 2458QcYO039321; Thu, 5 May 2022 08:30:31 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fv8gd2uq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 May 2022 08:30:30 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2458LOH9022476; Thu, 5 May 2022 08:30:30 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3fv8gd2uph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 May 2022 08:30:30 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2458NC70028371; Thu, 5 May 2022 08:30:27 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma03ams.nl.ibm.com with ESMTP id 3ftp7fuqmx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 05 May 2022 08:30:27 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2458UOMK50921850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 May 2022 08:30:24 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45340A4060; Thu, 5 May 2022 08:30:24 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC92AA4054; Thu, 5 May 2022 08:30:21 +0000 (GMT) Received: from [9.200.34.6] (unknown [9.200.34.6]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 May 2022 08:30:21 +0000 (GMT) Message-ID: Date: Thu, 5 May 2022 16:30:19 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] Skip constant folding for fmin/max when either argument is sNaN [PR105414] Content-Language: en-US To: Richard Biener , HAO CHEN GUI Cc: Peter Bergner , gcc-patches , Segher Boessenkool , David References: <4df302c6-5bc7-f6fb-916a-6dd9c0460268@linux.ibm.com> From: "Kewen.Lin" In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Boyjh9rnEK4BdJzmZJHrfY3QMBCQlAlR X-Proofpoint-GUID: ojo4rK-ovNtP3U7ktR9B8QXS52P4Pjjg 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-04_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 malwarescore=0 mlxscore=0 adultscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2205050055 X-Spam-Status: No, score=-12.6 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 08:30:34 -0000 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? BR, Kewen