public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Call estimate_numbers_of_iterations after insert_range_assertions (PR tree-optimization/49419)
Date: Thu, 16 Jun 2011 07:45:00 -0000	[thread overview]
Message-ID: <BANLkTinYKQOqp+Ju1VR5yenjS97hFs91xA@mail.gmail.com> (raw)
In-Reply-To: <20110615185701.GL17079@tyan-ft48-01.lab.bos.redhat.com>

On Wed, Jun 15, 2011 at 8:57 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> The following testcase is miscompiled e.g. on powerpc (not on x86_64/i686
> due to different ivopts choices), because estimate_numbers_of_iterations
> was called before assert_exprs are added to the IL and gets info cached
> until adjust_range_with_scev, where using the original SSA_NAMEs leads
> to problems where VR changes might not be propagated properly.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk/4.6?  I'll work on followup improvements for the trunk
> afterwards.

Ok.

Thanks,
Richard.

> 2011-06-15  Jakub Jelinek  <jakub@redhat.com>
>
>        PR tree-optimization/49419
>        * tree-vrp.c (execute_vrp): Call init_range_assertions
>        before estimate_numbers_of_iterations, call
>        free_number_of_iterations_estimates before calling
>        remove_range_assertions.
>
>        * gcc.c-torture/execute/pr49419.c: New test.
>
> --- gcc/tree-vrp.c.jj   2011-05-31 08:03:10.000000000 +0200
> +++ gcc/tree-vrp.c      2011-06-15 17:25:32.000000000 +0200
> @@ -7730,14 +7730,14 @@ execute_vrp (void)
>   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
>   scev_initialize ();
>
> +  insert_range_assertions ();
> +
>   /* Estimate number of iterations - but do not use undefined behavior
>      for this.  We can't do this lazily as other functions may compute
>      this using undefined behavior.  */
>   free_numbers_of_iterations_estimates ();
>   estimate_numbers_of_iterations (false);
>
> -  insert_range_assertions ();
> -
>   to_remove_edges = VEC_alloc (edge, heap, 10);
>   to_update_switch_stmts = VEC_alloc (switch_update, heap, 5);
>   threadedge_initialize_values ();
> @@ -7746,6 +7746,8 @@ execute_vrp (void)
>   ssa_propagate (vrp_visit_stmt, vrp_visit_phi_node);
>   vrp_finalize ();
>
> +  free_numbers_of_iterations_estimates ();
> +
>   /* ASSERT_EXPRs must be removed before finalizing jump threads
>      as finalizing jump threads calls the CFG cleanup code which
>      does not properly handle ASSERT_EXPRs.  */
> --- gcc/testsuite/gcc.c-torture/execute/pr49419.c.jj    2011-06-15 18:06:43.000000000 +0200
> +++ gcc/testsuite/gcc.c-torture/execute/pr49419.c       2011-06-15 18:05:18.000000000 +0200
> @@ -0,0 +1,38 @@
> +/* PR tree-optimization/49419 */
> +
> +extern void abort (void);
> +
> +struct S { int w, x, y; } *t;
> +
> +int
> +foo (int n, int f, int *s, int m)
> +{
> +  int x, i, a;
> +  if (n == -1)
> +    return 0;
> +  for (x = n, i = 0; t[x].w == f && i < m; i++)
> +    x = t[x].x;
> +  if (i == m)
> +    abort ();
> +  a = i + 1;
> +  for (x = n; i > 0; i--)
> +    {
> +      s[i] = t[x].y;
> +      x = t[x].x;
> +    }
> +  s[0] = x;
> +  return a;
> +}
> +
> +int
> +main (void)
> +{
> +  int s[3], i;
> +  struct S buf[3] = { { 1, 1, 2 }, { 0, 0, 0 }, { 0, 0, 0 } };
> +  t = buf;
> +  if (foo (0, 1, s, 3) != 2)
> +    abort ();
> +  if (s[0] != 1 || s[1] != 2)
> +    abort ();
> +  return 0;
> +}
>
>        Jakub
>

      reply	other threads:[~2011-06-16  7:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-15 20:40 Jakub Jelinek
2011-06-16  7:45 ` Richard Guenther [this message]

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=BANLkTinYKQOqp+Ju1VR5yenjS97hFs91xA@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).