Message ID | 20230919052353.3208707-1-guojiufu@linux.ibm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3144139vqi; Mon, 18 Sep 2023 22:24:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHpoGDTORILztasoKXxLTdLI9ciNs593np7eEWvCe2eE0SDFKqFhfS7Ci3z5cXyxQkp121t X-Received: by 2002:a05:6402:206d:b0:530:f880:ca74 with SMTP id bd13-20020a056402206d00b00530f880ca74mr4620487edb.28.1695101099357; Mon, 18 Sep 2023 22:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695101099; cv=none; d=google.com; s=arc-20160816; b=v0Xo3kVMl56068bP+fLqBLuW5dN/dOvdVkXpIlrKMdbWLsNKvGKuM9EQSt/3uUPsqs neVPmsG8wSCQqNY8GDHm1YDclABVZwSHSJWgCEVzaaXE24KuP/Bi0PIdSoc6F0D3mVqJ 06t7+WzWkqkLS8DuSpovGIFDDroEopNMubqPUTwxDFZ38AfXB7ifT2EKxw9bjmPx9DUF NiU3RoHdxpSDixjISVsoqC63XipO6x48/TfBELqjh7nMKQaYt67qo5GlFnH1pfCBbY1j PQ9oNouWSEUd9ColFSeVIyphBUQJCDlJj3KTYbIagHBr4OBpZass3NKQVhtPQ6Pl3Z4o kjgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=2aMN5/hbA6R/U4XYoCD8X/fh2SRIBjZR94YkIrG1BPw=; fh=ubhnvD1eb9ooX1g6ne78Ef1gTG7etK1Vzknl0mcjRqY=; b=PwrFErV9KTbEkhclZwRBWeiHrwvW2srCItuTWz3M3KOW0H8Bsr8YVzKqps2NOiXkCe wvfnIvqrh7RAaJy+Y+HeMsAv7d1s6/dyvxSFavhTsFgopj7Moq/KFjWPCB7vMcJ/ooBW DmWNJ/Czdw46MrUKbKnFyJA/q5Gb9+kvbCbZ27cmUhF00ejUe+Amuxbvz8hIXHi5UdFL py1OLSwu5ITfqgESp4z9dGyvfU7rgpAatjD5bTdZ8AJ5hA9jsIC4w5XKihc4KXqttPLU y9dcuf9WLNP4jqyshZ/mWCTzLojF9sftIu+WLWyMtQ5vZAABi2wyAP6MYyNjgVAW6lcF B4bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XXX36Bmy; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d9-20020a056402400900b005304fc45adfsi9006784eda.223.2023.09.18.22.24.59 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 22:24:59 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=XXX36Bmy; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 85E033857009 for <ouuuleilei@gmail.com>; Tue, 19 Sep 2023 05:24:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85E033857009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695101087; bh=2aMN5/hbA6R/U4XYoCD8X/fh2SRIBjZR94YkIrG1BPw=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=XXX36BmyfUPgMM85oLd4odwK1RHZOuvz9NnmIsy791RXt+ddH1qhDqrb3H5hizdY/ tus6Uqjl3ysuq9f0mNx8jrs/xt0g8ZGXFEtwfnJsI+kG0LkGgMCEyqTp8R/9gXjuo2 G6XLMFFnqc2/Kh71HwMKYK0sQvCqljlwQ96YZhCA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 070143858D39; Tue, 19 Sep 2023 05:24:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 070143858D39 Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38J5HKea027992; Tue, 19 Sep 2023 05:24:01 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3t71fecm9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Sep 2023 05:24:00 +0000 Received: from m0356516.ppops.net (m0356516.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 38J57c4B029587; Tue, 19 Sep 2023 05:24:00 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 3t71fecm9d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Sep 2023 05:24:00 +0000 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 38J3OsLK005540; Tue, 19 Sep 2023 05:23:59 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3t5q2yhdye-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 19 Sep 2023 05:23:59 +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 38J5NuCG26149548 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Sep 2023 05:23:56 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E34720043; Tue, 19 Sep 2023 05:23:56 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 122A320040; Tue, 19 Sep 2023 05:23:54 +0000 (GMT) Received: from genoa.aus.stglabs.ibm.com (unknown [9.40.192.157]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 19 Sep 2023 05:23:53 +0000 (GMT) To: gcc-patches@gcc.gnu.org Cc: rguenther@suse.de, jeffreyalaw@gmail.com, richard.sandiford@arm.com, segher@kernel.crashing.org, dje.gcc@gmail.com, linkw@gcc.gnu.org, bergner@linux.ibm.com, guojiufu@linux.ibm.com, amacleod@redhat.com, aldyh@redhat.com Subject: [PATCH 1/2] using overflow_free_p to simplify pattern Date: Tue, 19 Sep 2023 13:23:52 +0800 Message-Id: <20230919052353.3208707-1-guojiufu@linux.ibm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: ZyWXKLm2-LoRlwYyLkoHh9WDw1E_RoC_ X-Proofpoint-GUID: pPl8f8ze0xZylx8DAvT9oYJ7cX7s_mkn 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-18_11,2023-09-18_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309190043 X-Spam-Status: No, score=-10.8 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jiufu Guo via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jiufu Guo <guojiufu@linux.ibm.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777442330446747643 X-GMAIL-MSGID: 1777442330446747643 |
Series |
[1/2] using overflow_free_p to simplify pattern
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jiufu Guo
Sept. 19, 2023, 5:23 a.m. UTC
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(-)
Comments
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? OK with omitting. Richard. > + && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1)) > + @0)) > #endif > )))) > >
Hi, Richard Biener <rguenther@suse.de> 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 >> )))) >> >>
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 () + && range_op_handler (MULT_EXPR).overflow_free_p (vr0, vr1)) + @0)) #endif ))))