From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id C6124385702B for ; Fri, 17 Sep 2021 08:16:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C6124385702B Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id B07E0223D3; Fri, 17 Sep 2021 08:16:16 +0000 (UTC) Received: from murzim.suse.de (murzim.suse.de [10.160.4.192]) (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 83342A3BA8; Fri, 17 Sep 2021 08:16:16 +0000 (UTC) Date: Fri, 17 Sep 2021 10:16:16 +0200 (CEST) From: Richard Biener To: Jiufu Guo cc: gcc-patches@gcc.gnu.org, amker.cheng@gmail.com, wschmidt@linux.ibm.com, segher@kernel.crashing.org, dje.gcc@gmail.com, jlaw@tachyum.com Subject: Re: [PATCH V2] Set bound/cmp/control for until wrap loop. In-Reply-To: <7epmtri1il.fsf_-_@pike.rch.stglabs.ibm.com> Message-ID: References: <20210830061535.146396-1-guojiufu@linux.ibm.com> <70ea087486feb85536100fa538c877f4@imap.linux.ibm.com> <7epmtri1il.fsf_-_@pike.rch.stglabs.ibm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Fri, 17 Sep 2021 08:16:19 -0000 On Thu, 2 Sep 2021, Jiufu Guo wrote: > > Changes on V1: > * Add more test case > * Add comment for exit-condition transform > * Removing duplicate setting on niter->control > > This patch reset niter->control, niter->bound and niter->cmp in > number_of_iterations_until_wrap. > > Bootstrap and test pass on ppc64 and x86, and pass the test cases > in PR. Is this ok for trunk? OK. Thanks, Richard. > One thing, in this patch, the IVbase is still keep as biasing by 1 step. > > > BR. > Jiufu Guo > > gcc/ChangeLog: > > 2021-09-02 Jiufu Guo > > PR tree-optimization/102087 > * tree-ssa-loop-niter.c (number_of_iterations_until_wrap): > Update bound/cmp/control for niter. > > gcc/testsuite/ChangeLog: > > 2021-09-02 Jiufu Guo > > PR tree-optimization/102087 > * gcc.dg/pr102087.c: New test. > > --- > gcc/tree-ssa-loop-niter.c | 16 ++++++++++++++- > gcc/testsuite/gcc.dg/pr102087.c | 35 +++++++++++++++++++++++++++++++++ > 2 files changed, 50 insertions(+), 1 deletion(-) > create mode 100644 gcc/testsuite/gcc.dg/pr102087.c > > diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c > index 7af92d1c893..75109407124 100644 > --- a/gcc/tree-ssa-loop-niter.c > +++ b/gcc/tree-ssa-loop-niter.c > @@ -1482,7 +1482,7 @@ number_of_iterations_until_wrap (class loop *, tree type, affine_iv *iv0, > affine_iv *iv1, class tree_niter_desc *niter) > { > tree niter_type = unsigned_type_for (type); > - tree step, num, assumptions, may_be_zero; > + tree step, num, assumptions, may_be_zero, span; > wide_int high, low, max, min; > > may_be_zero = fold_build2 (LE_EXPR, boolean_type_node, iv1->base, iv0->base); > @@ -1557,6 +1557,20 @@ number_of_iterations_until_wrap (class loop *, tree type, affine_iv *iv0, > > niter->control.no_overflow = false; > > + /* Update bound and exit condition as: > + bound = niter * STEP + (IVbase - STEP). > + { IVbase - STEP, +, STEP } != bound > + Here, biasing IVbase by 1 step makes 'bound' be the value before wrap. > + */ > + niter->control.base = fold_build2 (MINUS_EXPR, niter_type, > + niter->control.base, niter->control.step); > + span = fold_build2 (MULT_EXPR, niter_type, niter->niter, > + fold_convert (niter_type, niter->control.step)); > + niter->bound = fold_build2 (PLUS_EXPR, niter_type, span, > + fold_convert (niter_type, niter->control.base)); > + niter->bound = fold_convert (type, niter->bound); > + niter->cmp = NE_EXPR; > + > return true; > } > > diff --git a/gcc/testsuite/gcc.dg/pr102087.c b/gcc/testsuite/gcc.dg/pr102087.c > new file mode 100644 > index 00000000000..fc60cbda066 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr102087.c > @@ -0,0 +1,35 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O3" } */ > + > +unsigned __attribute__ ((noinline)) > +foo (int *__restrict__ a, int *__restrict__ b, unsigned l, unsigned n) > +{ > + while (n < ++l) > + *a++ = *b++ + 1; > + return l; > +} > + > +volatile int a[1]; > +unsigned b; > +int c; > + > +int > +check () > +{ > + int d; > + for (; b > 1; b++) > + for (c = 0; c < 2; c++) > + for (d = 0; d < 2; d++) > + a[0]; > + return 0; > +} > + > +char **Gif_ClipImage_gfi_0; > +int Gif_ClipImage_y, Gif_ClipImage_shift; > +void > +Gif_ClipImage () > +{ > + for (; Gif_ClipImage_y >= Gif_ClipImage_shift; Gif_ClipImage_y++) > + Gif_ClipImage_gfi_0[Gif_ClipImage_shift] > + = Gif_ClipImage_gfi_0[Gif_ClipImage_y]; > +} > -- Richard Biener SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)