This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[cfg-branch] bb-reorder.c bug fix
- From: Josef Zlomek <zlomj9am at artax dot karlin dot mff dot cuni dot cz>
- To: gcc-pdo at atrey dot karlin dot mff dot cuni dot cz, gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Feb 2002 21:18:41 +0100
- Subject: [cfg-branch] bb-reorder.c bug fix
Hi,
this patch fixes the bug in bb-reorder.c
The code for optimizing
if (A) B;
C;
is now run only if the best_edge->dest has not been visited yet.
Bootstrapped on i686.
Joe
Mon Feb 18 21:16:44 CET 2002 Josef Zlomek <zlomek@matfyz.cz>
bb-reorder.c (find_traces_1_round): Bug fix in optimization of simple branches.
*** gcc-old/gcc/bb-reorder.c Mon Feb 18 08:53:02 2002
--- gcc-new/gcc/bb-reorder.c Mon Feb 18 19:39:28 2002
*************** find_traces_1_round (branch_th, exec_th,
*** 320,364 ****
if (best_edge) /* Found suitable successor. */
{
- /* Check for a situation
-
- A
- /|
- B |
- \|
- C
-
- where
- EDGE_FREQUENCY (AB) + EDGE_FREQUENCY (BC) >= EDGE_FREQUENCY (AC).
- (i.e. 2 * B->frequency >= EDGE_FREQUENCY (AC) )
- Best ordering is then A B C.
-
- This situation is created for example by:
-
- if (A) B;
- C;
-
- */
-
- for (e = bb->succ; e; e = e->succ_next)
- if (e != best_edge && (e->flags & EDGE_CAN_FALLTHRU)
- && !(e->flags & EDGE_COMPLEX)
- && !RBI (e->dest)->visited
- && !e->dest->pred->pred_next
- && e->dest->succ
- && (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
- && !(e->dest->succ->flags & EDGE_COMPLEX)
- && !e->dest->succ->succ_next
- && e->dest->succ->dest == best_edge->dest
- && 2 * e->dest->frequency >= EDGE_FREQUENCY (best_edge))
- {
- best_edge = e;
- if (rtl_dump_file)
- fprintf (rtl_dump_file, "Selecting BB %d\n",
- best_edge->dest->index);
- break;
- }
-
if (RBI (best_edge->dest)->visited == *n_traces)
{
if (bb != best_edge->dest)
--- 320,325 ----
*************** find_traces_1_round (branch_th, exec_th,
*** 439,444 ****
--- 400,446 ----
}
else
{
+ /* Check for a situation
+
+ A
+ /|
+ B |
+ \|
+ C
+
+ where
+ EDGE_FREQUENCY (AB) + EDGE_FREQUENCY (BC)
+ >= EDGE_FREQUENCY (AC).
+ (i.e. 2 * B->frequency >= EDGE_FREQUENCY (AC) )
+ Best ordering is then A B C.
+
+ This situation is created for example by:
+
+ if (A) B;
+ C;
+
+ */
+
+ for (e = bb->succ; e; e = e->succ_next)
+ if (e != best_edge
+ && (e->flags & EDGE_CAN_FALLTHRU)
+ && !(e->flags & EDGE_COMPLEX)
+ && !RBI (e->dest)->visited
+ && !e->dest->pred->pred_next
+ && e->dest->succ
+ && (e->dest->succ->flags & EDGE_CAN_FALLTHRU)
+ && !(e->dest->succ->flags & EDGE_COMPLEX)
+ && !e->dest->succ->succ_next
+ && e->dest->succ->dest == best_edge->dest
+ && 2 * e->dest->frequency >= EDGE_FREQUENCY (best_edge))
+ {
+ best_edge = e;
+ if (rtl_dump_file)
+ fprintf (rtl_dump_file, "Selecting BB %d\n",
+ best_edge->dest->index);
+ break;
+ }
+
RBI (bb)->next = best_edge->dest;
bb = best_edge->dest;
}