From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id C77F03858C52; Thu, 21 Sep 2023 05:22:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C77F03858C52 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 Received: from pps.filterd (m0353723.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38L5E0TA023592; Thu, 21 Sep 2023 05:22:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=E8ZNxQI0MOvR4JnMPJnZ8frTs57HiDXfYbVhtoY9ePs=; b=OBIjZw+vtZsUdouCiLsLS8JLtpCoIx1KXSTAcVq5ty7v93hx6nlfiRAIzs6uXw+QQxPN 9Rvm3tyebLWVRfPM0153uVfgFMsql2fpo53BE6gw3r4tGON4/y4ZuCnjO2t6ciDXNJoR pJUHRLw07ZZy6IdaBljJDriOb1uHEnU9fM4mnswDCtZTMhyoy14OFikb2v8H9pr8BQqd ILlCSPmGXbc6RiCXp36k5YApa/GNPTCxJUCw4L+pDFEEq2ES6xP2tl+BdKsVs+eQpG1R W9PZFB/TK68jVeaNYjCdKFO/N4/O83krjWCgpF/Yp3lGxYA7hDxZzsuv52rovjh7XBDq Tw== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t816px4nw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 05:22:45 +0000 Received: from m0353723.ppops.net (m0353723.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 38L5Hw93001771; Thu, 21 Sep 2023 05:22:45 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t816px4nc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 05:22:45 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38L3oJoj031222; Thu, 21 Sep 2023 05:22:44 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3t5r6m4ne5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Sep 2023 05:22:44 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 38L5MhDl1639082 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 21 Sep 2023 05:22:43 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16F2F58052; Thu, 21 Sep 2023 05:22:43 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6AF3058045; Thu, 21 Sep 2023 05:22:42 +0000 (GMT) Received: from genoa (unknown [9.40.192.157]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTPS; Thu, 21 Sep 2023 05:22:42 +0000 (GMT) From: Jiufu Guo To: Richard Biener Cc: gcc-patches@gcc.gnu.org, jeffreyalaw@gmail.com, richard.sandiford@arm.com, segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, amacleod@redhat.com, aldyh@redhat.com Subject: Re: [PATCH 1/2] using overflow_free_p to simplify pattern References: <20230919052353.3208707-1-guojiufu@linux.ibm.com> Date: Thu, 21 Sep 2023 13:22:39 +0800 In-Reply-To: (Richard Biener's message of "Tue, 19 Sep 2023 12:50:56 +0000 (UTC)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: g1bXZ0y51pGOdCFDZIwASCPBbxa0FI9k X-Proofpoint-ORIG-GUID: GuiFN_HTtAbXXzunp_n4jvhrg7NOmkXe X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-21_03,2023-09-20_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 mlxscore=0 malwarescore=0 lowpriorityscore=0 adultscore=0 suspectscore=0 phishscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309210043 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: Hi, Richard Biener writes: > On Tue, 19 Sep 2023, Jiufu Guo wrote: > >> Hi, >> >> In r14-3582, an "overflow_free_p" interface is added. >> The pattern of "(t * 2) / 2" in match.pd can be simplified >> by using this interface. >> >> Bootstrap & regtest pass on ppc64{,le} and x86_64. >> Is this ok for trunk? >> >> BR, >> Jeff (Jiufu) >> >> gcc/ChangeLog: >> >> * match.pd ((t * 2) / 2): Update to use overflow_free_p. >> >> --- >> gcc/match.pd | 37 +++++++------------------------------ >> 1 file changed, 7 insertions(+), 30 deletions(-) >> >> diff --git a/gcc/match.pd b/gcc/match.pd >> index 87edf0e75c3..8bba7056000 100644 >> --- a/gcc/match.pd >> +++ b/gcc/match.pd >> @@ -926,36 +926,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) >> (if (TYPE_OVERFLOW_UNDEFINED (type)) >> @0 >> #if GIMPLE >> - (with >> - { >> - bool overflowed = true; >> - value_range vr0, vr1; >> - if (INTEGRAL_TYPE_P (type) >> - && get_range_query (cfun)->range_of_expr (vr0, @0) >> - && get_range_query (cfun)->range_of_expr (vr1, @1) >> - && !vr0.varying_p () && !vr0.undefined_p () >> - && !vr1.varying_p () && !vr1.undefined_p ()) >> - { >> - wide_int wmin0 = vr0.lower_bound (); >> - wide_int wmax0 = vr0.upper_bound (); >> - wide_int wmin1 = vr1.lower_bound (); >> - wide_int wmax1 = vr1.upper_bound (); >> - /* If the multiplication can't overflow/wrap around, then >> - it can be optimized too. */ >> - wi::overflow_type min_ovf, max_ovf; >> - wi::mul (wmin0, wmin1, TYPE_SIGN (type), &min_ovf); >> - wi::mul (wmax0, wmax1, TYPE_SIGN (type), &max_ovf); >> - if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE) >> - { >> - wi::mul (wmin0, wmax1, TYPE_SIGN (type), &min_ovf); >> - wi::mul (wmax0, wmin1, TYPE_SIGN (type), &max_ovf); >> - if (min_ovf == wi::OVF_NONE && max_ovf == wi::OVF_NONE) >> - overflowed = false; >> - } >> - } >> - } >> - (if (!overflowed) >> - @0)) >> + (with {value_range vr0, vr1;} >> + (if (INTEGRAL_TYPE_P (type) >> + && get_range_query (cfun)->range_of_expr (vr0, @0) >> + && get_range_query (cfun)->range_of_expr (vr1, @1) >> + && !vr0.varying_p () && !vr1.varying_p () > > From your other uses checking !varying_p doesn't seem necessary? Thanks for pointing out this!! Yes, !varying_p is not needed, overflow_free_p could cover it. Committed via r14-4191. BR, Jeff (Jiufu Guo) > > OK with omitting. > > Richard. > >> + && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1)) >> + @0)) >> #endif >> )))) >> >>