From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id CE4AD3858D39; Tue, 19 Sep 2023 12:50:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CE4AD3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 03AC81FEEF; Tue, 19 Sep 2023 12:50:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695127857; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YI7j1PGueoB7nMsvpT9CV8AtNjBovD82LNIeN7F33xM=; b=WvZsUR32p62ijTLXt6+t9LGj2Jy/vQ1nTwBeUX970YiLdSn6C34PbdMbwfe+r0adWQwtVg leuwvCEx+SV3gfUw95F81CBaOXgD9/k2Cjrjv2USEhiQci1w3EwQEQSbSQqqrb+6BuMUKo XZ9n34JHm27nEUPmKkQNt9FidKs9EtA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695127857; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YI7j1PGueoB7nMsvpT9CV8AtNjBovD82LNIeN7F33xM=; b=HqqPJU2B421aeqU9yXhAfPUjeg9QAX30i8rLuYjFUkWqYjgLyMHWAkZNHBNIHWlap+P/m7 dtl37avm92x5KyCg== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 93C822C142; Tue, 19 Sep 2023 12:50:56 +0000 (UTC) Date: Tue, 19 Sep 2023 12:50:56 +0000 (UTC) From: Richard Biener To: Jiufu Guo 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 In-Reply-To: <20230919052353.3208707-1-guojiufu@linux.ibm.com> Message-ID: References: <20230919052353.3208707-1-guojiufu@linux.ibm.com> User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: 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 > )))) > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)