From: Rong Xu <xur@google.com>
To: Dehao Chen <dehao@google.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [google] revert r185948
Date: Wed, 04 Apr 2012 00:42:00 -0000 [thread overview]
Message-ID: <CAF1bQ=TgYqTPTjDoJM1640RAqXG7+B7Md3KnuPc+7MSCbqzt1w@mail.gmail.com> (raw)
In-Reply-To: <CAO2gOZW9OiCw3vZPOcOmJwsPU+CX73MndEso44+w5RC6JuBNPA@mail.gmail.com>
OK for google-4_6 branch.
-Rong
On Tue, Apr 3, 2012 at 5:30 PM, Dehao Chen <dehao@google.com> wrote:
>
> Revert r185948, which causes regression to major applications.
>
> Bootstrapped.
>
> OK for google-4_6?
>
> Thanks,
> Dehao
>
> Index: gcc/testsuite/gcc.dg/predict-3.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/predict-3.c (revision 186128)
> +++ gcc/testsuite/gcc.dg/predict-3.c (working copy)
> @@ -10,16 +10,10 @@
> int i, ret = 0;
> for (i = 0; i <= bound; i++)
> {
> - if (i < bound - 2)
> - global += bar (i);
> - if (i <= bound)
> - global += bar (i);
> - if (i + 1 < bound)
> - global += bar (i);
> if (i != bound)
> global += bar (i);
> }
> }
>
> -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics:
> 100.0%" 4 "profile_estimate"} } */
> +/* { dg-final { scan-tree-dump "loop iv compare heuristics"
> "profile_estimate"} } */
> /* { dg-final { cleanup-tree-dump "profile_estimate" } } */
> Index: gcc/testsuite/gcc.dg/predict-4.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/predict-4.c (revision 186128)
> +++ gcc/testsuite/gcc.dg/predict-4.c (working copy)
> @@ -15,5 +15,5 @@
> }
> }
>
> -/* { dg-final { scan-tree-dump "loop iv compare heuristics: 50.0%"
> "profile_estimate"} } */
> +/* { dg-final { scan-tree-dump "loop iv compare heuristics"
> "profile_estimate"} } */
> /* { dg-final { cleanup-tree-dump "profile_estimate" } } */
> Index: gcc/testsuite/gcc.dg/predict-1.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/predict-1.c (revision 186128)
> +++ gcc/testsuite/gcc.dg/predict-1.c (working copy)
> @@ -10,18 +10,10 @@
> int i, ret = 0;
> for (i = 0; i < bound; i++)
> {
> - if (i > bound)
> - global += bar (i);
> - if (i >= bound + 2)
> - global += bar (i);
> if (i > bound - 2)
> global += bar (i);
> - if (i + 2 > bound)
> - global += bar (i);
> - if (i == 10)
> - global += bar (i);
> }
> }
>
> -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics:
> 0.0%" 5 "profile_estimate"} } */
> +/* { dg-final { scan-tree-dump "loop iv compare heuristics"
> "profile_estimate"} } */
> /* { dg-final { cleanup-tree-dump "profile_estimate" } } */
> Index: gcc/testsuite/gcc.dg/predict-5.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/predict-5.c (revision 186128)
> +++ gcc/testsuite/gcc.dg/predict-5.c (working copy)
> @@ -1,25 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
> -
> -extern int global;
> -
> -int bar (int);
> -
> -void foo (int base, int bound)
> -{
> - int i, ret = 0;
> - for (i = base; i <= bound; i++)
> - {
> - if (i > base)
> - global += bar (i);
> - if (i > base + 1)
> - global += bar (i);
> - if (i >= base + 3)
> - global += bar (i);
> - if (i - 2 >= base)
> - global += bar (i);
> - }
> -}
> -
> -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics:
> 100.0%" 4 "profile_estimate"} } */
> -/* { dg-final { cleanup-tree-dump "profile_estimate" } } */
> Index: gcc/testsuite/gcc.dg/predict-2.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/predict-2.c (revision 186128)
> +++ gcc/testsuite/gcc.dg/predict-2.c (working copy)
> @@ -5,20 +5,12 @@
>
> int bar(int);
>
> -void foo (int base, int bound)
> +void foo (int bound)
> {
> int i, ret = 0;
> - for (i = base; i < bound; i++)
> + for (i = 0; i < bound; i++)
> {
> - if (i > bound * bound)
> - global += bar (i);
> - if (i > bound + 10)
> - global += bar (i);
> - if (i <= bound + 10)
> - global += bar (i);
> - if (i > base + 10)
> - global += bar (i);
> - if (i < base - 10)
> + if (i > bound * bound )
> global += bar (i);
> }
> }
> Index: gcc/testsuite/gcc.dg/predict-6.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/predict-6.c (revision 186128)
> +++ gcc/testsuite/gcc.dg/predict-6.c (working copy)
> @@ -1,25 +0,0 @@
> -/* { dg-do compile } */
> -/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
> -
> -extern int global;
> -
> -int bar (int);
> -
> -void foo (int base, int bound)
> -{
> - int i, ret = 0;
> - for (i = base; i <= bound; i++)
> - {
> - if (i < base)
> - global += bar (i);
> - if (i < base + 1)
> - global += bar (i);
> - if (i <= base + 3)
> - global += bar (i);
> - if (i - 1 < base)
> - global += bar (i);
> - }
> -}
> -
> -/* { dg-final { scan-tree-dump-times "loop iv compare heuristics:
> 0.0%" 4 "profile_estimate"} } */
> -/* { dg-final { cleanup-tree-dump "profile_estimate" } } */
> Index: gcc/predict.c
> ===================================================================
> --- gcc/predict.c (revision 186128)
> +++ gcc/predict.c (working copy)
> @@ -1070,10 +1070,6 @@
> bound = get_base_value (bound);
> if (!bound)
> return false;
> - if (TREE_CODE (base) != INTEGER_CST)
> - base = get_base_value (base);
> - if (!base)
> - return false;
>
> *loop_invariant = bound;
> *compare_code = code;
> @@ -1189,7 +1185,8 @@
> return;
> }
>
> - if (!expr_coherent_p(loop_iv_base_var, compare_base))
> + if (!expr_coherent_p (loop_bound_var, compare_var)
> + || loop_iv_base_var != compare_base)
> return;
>
> /* If loop bound, base and compare bound are all constents, we can
> @@ -1233,52 +1230,34 @@
> return;
> }
>
> - if (expr_coherent_p (loop_bound_var, compare_var))
> - {
> - if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR)
> - && (compare_code == LT_EXPR || compare_code == LE_EXPR))
> - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> - else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR)
> - && (compare_code == GT_EXPR || compare_code == GE_EXPR))
> - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> - else if (loop_bound_code == NE_EXPR)
> - {
> - /* If the loop backedge condition is "(i != bound)", we do
> - the comparison based on the step of IV:
> - * step < 0 : backedge condition is like (i > bound)
> - * step > 0 : backedge condition is like (i < bound) */
> - gcc_assert (loop_bound_step != 0);
> - if (loop_bound_step > 0
> - && (compare_code == LT_EXPR
> - || compare_code == LE_EXPR))
> - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> - else if (loop_bound_step < 0
> - && (compare_code == GT_EXPR
> - || compare_code == GE_EXPR))
> - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> - else
> - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN);
> - }
> - else
> - /* The branch is predicted not-taken if loop_bound_code is
> - opposite with compare_code. */
> - predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN);
> - }
> - else if (expr_coherent_p (loop_iv_base_var, compare_var))
> - {
> - /* For cases like:
> - for (i = s; i < h; i++)
> - if (i > s + 2) ....
> - The branch should be predicted taken. */
> + if ((loop_bound_code == LT_EXPR || loop_bound_code == LE_EXPR)
> + && (compare_code == LT_EXPR || compare_code == LE_EXPR))
> + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> + else if ((loop_bound_code == GT_EXPR || loop_bound_code == GE_EXPR)
> + && (compare_code == GT_EXPR || compare_code == GE_EXPR))
> + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> + else if (loop_bound_code == NE_EXPR)
> + {
> + /* If the loop backedge condition is "(i != bound)", we do
> + the comparison based on the step of IV:
> + * step < 0 : backedge condition is like (i > bound)
> + * step > 0 : backedge condition is like (i < bound) */
> + gcc_assert (loop_bound_step != 0);
> if (loop_bound_step > 0
> - && (compare_code == GT_EXPR || compare_code == GE_EXPR))
> + && (compare_code == LT_EXPR
> + || compare_code == LE_EXPR))
> predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> else if (loop_bound_step < 0
> - && (compare_code == LT_EXPR || compare_code == LE_EXPR))
> + && (compare_code == GT_EXPR
> + || compare_code == GE_EXPR))
> predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, TAKEN);
> else
> predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN);
> }
> + else
> + /* The branch is predicted not-taken if loop_bound_code is
> + opposite with compare_code. */
> + predict_edge_def (then_edge, PRED_LOOP_IV_COMPARE, NOT_TAKEN);
> }
>
> /* Predict edge probabilities by exploiting loop structure. */
prev parent reply other threads:[~2012-04-04 0:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-04 0:31 Dehao Chen
2012-04-04 0:42 ` Rong Xu [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='CAF1bQ=TgYqTPTjDoJM1640RAqXG7+B7Md3KnuPc+7MSCbqzt1w@mail.gmail.com' \
--to=xur@google.com \
--cc=dehao@google.com \
--cc=gcc-patches@gcc.gnu.org \
/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).