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 85EF43887008 for ; Thu, 20 Jun 2024 06:56:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 85EF43887008 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 85EF43887008 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=1718866600; cv=none; b=OgWdusC+fobyZFdvz4Cd6iA3GVzmfBGCHYIt9eix7gn/h0IpXacFF3tNiO53kRwTknaLeN5O27KMYx8VUR0qll3IgULSfgBubtFYEBcnCPRTwX0CjB/fMgYWTLSSY9kMAJ6ah3fw6MowbU8312xWr+VcLdBtpD6rw2YOtGKqpT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718866600; c=relaxed/simple; bh=Xc8wuTY7H7f3xAMPzxC6/QthjIR0hw7kpo4hrJqh3Vg=; h=DKIM-Signature:Message-ID:Date:Subject:From:To:MIME-Version; b=ftCrI1Mfa703TcnHjlxTfqapf/ixdwMbVxvs8N++eHBrhYJPd1RG/SC/HFEKC6oUNMoJW1Zir8yZA2u+fZfG1WcBIRoVQK+/u/eFMO73Z1dO1QAgTzGrCmJzcdkKQ7PS+edJ09yfCFk/8QRmmOs3O84ZjLl4Kb1mZkwrYvJbwJs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 45K5RPXq006111; Thu, 20 Jun 2024 06:56:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= message-id:date:subject:from:to:cc:references:in-reply-to :content-type:content-transfer-encoding:mime-version; s=pp1; bh= kGYrvYKkmuoIp29xwlTWCb98i9AENSh24rNy36fzDMs=; b=AbPPsCR1Bzry/H5z IdVSE1XPba/bpaX52w6sVdGboDG7v9ZWCrxFykKexF7XJ+dJioNdlc+e0dAKyJ/m WhxRYqhmTYdAuKSpa3/RLvNmbLDTd4fhXQI1r62X8aOTmvisTuEEedAOJzFHKbtk mnQ3GNKcoiz9QZRoa13kJ7P/ScTvuarYhuF2mXDwKW78mZ/CWaFlpAz+gKqn07jD tia78UDFdKTcoUsTQ3YTl6GvaUagI/Si26aXIN4YFUm/N9MvENIb4u4iGMKAyhsj zVmfpBLmaB3jRvxAZzNVJMqEI6G8xi8O0AaZ9Dl1Q65FGa+A/t8mzdCWRCcB95Oo EhEOjA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3yvdv6r986-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 06:56:33 +0000 (GMT) Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 45K6uWa8018670; Thu, 20 Jun 2024 06:56:32 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 3yvdv6r97y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 06:56:32 +0000 (GMT) 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 45K601pF019506; Thu, 20 Jun 2024 06:56:30 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ysnp1km10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 20 Jun 2024 06:56:30 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 45K6uOLW17236246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jun 2024 06:56:26 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7E7EC2004B; Thu, 20 Jun 2024 06:56:24 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ECE2D20040; Thu, 20 Jun 2024 06:56:21 +0000 (GMT) Received: from [9.200.103.244] (unknown [9.200.103.244]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 20 Jun 2024 06:56:21 +0000 (GMT) Message-ID: <3498fd39-79f3-475b-acda-3b79d8f552c8@linux.ibm.com> Date: Thu, 20 Jun 2024 14:56:20 +0800 User-Agent: Mozilla Thunderbird Subject: Ping [PATCH-1v3] Value Range: Add range op for builtin isinf From: HAO CHEN GUI To: gcc-patches Cc: Segher Boessenkool , David , "Kewen.Lin" , Peter Bergner , Mikael Morin , "MacLeod, Andrew" , Aldy Hernandez , Jakub Jelinek , Richard Sandiford References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: w1MTAehITRdmJq749dwn_4T2C_SGe5up X-Proofpoint-ORIG-GUID: G6ll4_zh_rHB_fmwqx3MqW7IaqSudbNH 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.680,FMLib:17.12.28.16 definitions=2024-06-20_04,2024-06-19_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1011 impostorscore=0 phishscore=0 bulkscore=0 mlxscore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2405170001 definitions=main-2406200048 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_MSPIKE_H3,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, Gently ping it. https://gcc.gnu.org/pipermail/gcc-patches/2024-May/653096.html Thanks Gui Haochen 在 2024/5/30 10:46, HAO CHEN GUI 写道: > Hi, > The builtin isinf is not folded at front end if the corresponding optab > exists. It causes the range evaluation failed on the targets which has > optab_isinf. For instance, range-sincos.c will fail on the targets which > has optab_isinf as it calls builtin_isinf. > > This patch fixed the problem by adding range op for builtin isinf. > > Compared with previous version, the main change is to set the range to > 1 if it's infinite number otherwise to 0. > https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652219.html > > Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no > regressions. Is it OK for the trunk? > > Thanks > Gui Haochen > > > ChangeLog > Value Range: Add range op for builtin isinf > > The builtin isinf is not folded at front end if the corresponding optab > exists. So the range op for isinf is needed for value range analysis. > This patch adds range op for builtin isinf. > > gcc/ > * gimple-range-op.cc (class cfn_isinf): New. > (op_cfn_isinf): New variables. > (gimple_range_op_handler::maybe_builtin_call): Handle > CASE_FLT_FN (BUILT_IN_ISINF). > > gcc/testsuite/ > * gcc/testsuite/gcc.dg/tree-ssa/range-isinf.c: New test. > > patch.diff > diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc > index 55dfbb23ce2..4e60a42eaac 100644 > --- a/gcc/gimple-range-op.cc > +++ b/gcc/gimple-range-op.cc > @@ -1175,6 +1175,63 @@ private: > bool m_is_pos; > } op_cfn_goacc_dim_size (false), op_cfn_goacc_dim_pos (true); > > +// Implement range operator for CFN_BUILT_IN_ISINF > +class cfn_isinf : public range_operator > +{ > +public: > + using range_operator::fold_range; > + using range_operator::op1_range; > + virtual bool fold_range (irange &r, tree type, const frange &op1, > + const irange &, relation_trio) const override > + { > + if (op1.undefined_p ()) > + return false; > + > + if (op1.known_isinf ()) > + { > + wide_int one = wi::one (TYPE_PRECISION (type)); > + r.set (type, one, one); > + return true; > + } > + > + if (op1.known_isnan () > + || (!real_isinf (&op1.lower_bound ()) > + && !real_isinf (&op1.upper_bound ()))) > + { > + r.set_zero (type); > + return true; > + } > + > + r.set_varying (type); > + return true; > + } > + virtual bool op1_range (frange &r, tree type, const irange &lhs, > + const frange &, relation_trio) const override > + { > + if (lhs.undefined_p ()) > + return false; > + > + if (lhs.zero_p ()) > + { > + nan_state nan (true); > + r.set (type, real_min_representable (type), > + real_max_representable (type), nan); > + return true; > + } > + > + if (!range_includes_zero_p (lhs)) > + { > + // The range is [-INF,-INF][+INF,+INF], but it can't be represented. > + // Set range to [-INF,+INF] > + r.set_varying (type); > + r.clear_nan (); > + return true; > + } > + > + r.set_varying (type); > + return true; > + } > +} op_cfn_isinf; > > // Implement range operator for CFN_BUILT_IN_ > class cfn_parity : public range_operator > @@ -1268,6 +1325,11 @@ gimple_range_op_handler::maybe_builtin_call () > m_operator = &op_cfn_signbit; > break; > > + CASE_FLT_FN (BUILT_IN_ISINF): > + m_op1 = gimple_call_arg (call, 0); > + m_operator = &op_cfn_isinf; > + break; > + > CASE_CFN_COPYSIGN_ALL: > m_op1 = gimple_call_arg (call, 0); > m_op2 = gimple_call_arg (call, 1); > diff --git a/gcc/testsuite/gcc.dg/tree-ssa/range-isinf.c b/gcc/testsuite/gcc.dg/tree-ssa/range-isinf.c > new file mode 100644 > index 00000000000..468f1bcf5c7 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/tree-ssa/range-isinf.c > @@ -0,0 +1,44 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-evrp" } */ > + > +#include > +void link_error(); > + > +void > +test1 (double x) > +{ > + if (x > __DBL_MAX__ && !__builtin_isinf (x)) > + link_error (); > + if (x < -__DBL_MAX__ && !__builtin_isinf (x)) > + link_error (); > +} > + > +void > +test2 (float x) > +{ > + if (x > __FLT_MAX__ && !__builtin_isinf (x)) > + link_error (); > + if (x < -__FLT_MAX__ && !__builtin_isinf (x)) > + link_error (); > +} > + > +void > +test3 (double x) > +{ > + if (!__builtin_isinf (x) && !__builtin_isnan (x) && x > __DBL_MAX__) > + link_error (); > + if (!__builtin_isinf (x) && !__builtin_isnan (x) && x < -__DBL_MAX__) > + link_error (); > +} > + > +void > +test4 (float x) > +{ > + if (!__builtin_isinf (x) && !__builtin_isnan (x) && x > __FLT_MAX__) > + link_error (); > + if (!__builtin_isinf (x) && !__builtin_isnan (x) && x < -__FLT_MAX__) > + link_error (); > +} > + > +/* { dg-final { scan-tree-dump-not "link_error" "evrp" } } */ > +