public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiufu Guo <guojiufu@linux.ibm.com>
To: Richard Biener <rguenther@suse.de>, amker.cheng@gmail.com
Cc: gcc-patches@gcc.gnu.org, 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.
Date: Wed, 15 Sep 2021 16:50:40 +0800	[thread overview]
Message-ID: <7ek0jii5nj.fsf@pike.rch.stglabs.ibm.com> (raw)
In-Reply-To: <7epmtri1il.fsf_-_@pike.rch.stglabs.ibm.com> (Jiufu Guo's message of "Thu, 02 Sep 2021 20:51:30 +0800")

Jiufu Guo <guojiufu@linux.ibm.com> writes:

I may want to have a gentle ping on this.
https://gcc.gnu.org/pipermail/gcc-patches/2021-September/578680.html

BR,
Jiufu

> 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?
>
> 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  <guojiufu@linux.ibm.com>
>
>         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  <guojiufu@linux.ibm.com>
>
>         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];
> +}

  reply	other threads:[~2021-09-15  8:50 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30  6:15 [PATCH] " Jiufu Guo
2021-08-30  6:36 ` guojiufu
2021-08-30 12:02   ` Richard Biener
2021-08-31  3:12     ` guojiufu
2021-08-31 13:37       ` Richard Biener
2021-09-01  3:30         ` Jiufu Guo
2021-09-01  5:22           ` Jiufu Guo
2021-09-02  9:13         ` Jiufu Guo
2021-09-02 12:51         ` [PATCH V2] " Jiufu Guo
2021-09-15  8:50           ` Jiufu Guo [this message]
2021-09-17  8:16           ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7ek0jii5nj.fsf@pike.rch.stglabs.ibm.com \
    --to=guojiufu@linux.ibm.com \
    --cc=amker.cheng@gmail.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jlaw@tachyum.com \
    --cc=rguenther@suse.de \
    --cc=segher@kernel.crashing.org \
    --cc=wschmidt@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).