* [PATCH] Remove basic_block->loop_depth
@ 2012-08-13 13:02 Richard Guenther
2012-08-14 10:16 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Richard Guenther @ 2012-08-13 13:02 UTC (permalink / raw)
To: gcc-patches
Accessing loop_depth (bb->loop_father) isn't very expensive. The
following removes the duplicate info in basic-blocks which is not
properly kept up-to-date at the moment.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard.
2012-08-13 Richard Guenther <rguenther@suse.de>
* basic-block.h (struct basic_block): Remove loop_depth
member, move flags and index members next to each other.
* cfgloop.h (bb_loop_depth): New inline function.
* cfghooks.c (split_block): Do not set loop_depth.
(duplicate_block): Likewise.
* cfgloop.c (flow_loop_nodes_find): Likewise.
(flow_loops_find): Likewise.
(add_bb_to_loop): Likewise.
(remove_bb_from_loops): Likewise.
* cfgrtl.c (force_nonfallthru_and_redirect): Likewise.
* gimple-streamer-in.c (input_bb): Do not stream loop_depth.
* gimple-streamer-out.c (output_bb): Likewise.
* bt-load.c: Include cfgloop.h.
(migrate_btr_defs): Use bb_loop_depth.
* cfg.c (dump_bb_info): Likewise.
* final.c (compute_alignments): Likewise.
* ira.c (update_equiv_regs): Likewise.
* tree-ssa-copy.c (init_copy_prop): Likewise.
* tree-ssa-dom.c (loop_depth_of_name): Likewise.
* tree-ssa-forwprop.c: Include cfgloop.h.
(forward_propagate_addr_expr): Use bb_loop_depth.
* tree-ssa-pre.c (insert_into_preds_of_block): Likewise.
* tree-ssa-sink.c (select_best_block): Likewise.
* ipa-inline-analysis.c: Include cfgloop.h.
(estimate_function_body_sizes): Use bb_loop_depth.
* Makefile.in (tree-ssa-forwprop.o): Depend on $(CFGLOOP_H).
(ipa-inline-analysis.o): Likewise.
(bt-load.o): Likewise.
Index: trunk/gcc/basic-block.h
===================================================================
*** trunk.orig/gcc/basic-block.h 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/basic-block.h 2012-08-13 14:03:09.438889233 +0200
*************** struct GTY((chain_next ("%h.next_bb"), c
*** 160,173 ****
} GTY ((tag ("1"))) x;
} GTY ((desc ("((%1.flags & BB_RTL) != 0)"))) il;
! /* Expected number of executions: calculated in profile.c. */
! gcov_type count;
/* The index of this block. */
int index;
! /* The loop depth of this block. */
! int loop_depth;
/* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
int frequency;
--- 160,173 ----
} GTY ((tag ("1"))) x;
} GTY ((desc ("((%1.flags & BB_RTL) != 0)"))) il;
! /* Various flags. See cfg-flags.def. */
! int flags;
/* The index of this block. */
int index;
! /* Expected number of executions: calculated in profile.c. */
! gcov_type count;
/* Expected frequency. Normalized to be in range 0 to BB_FREQ_MAX. */
int frequency;
*************** struct GTY((chain_next ("%h.next_bb"), c
*** 176,184 ****
among several basic blocks that share a common locus, allowing for
more accurate sample-based profiling. */
int discriminator;
-
- /* Various flags. See cfg-flags.def. */
- int flags;
};
/* This ensures that struct gimple_bb_info is smaller than
--- 176,181 ----
Index: trunk/gcc/cfghooks.c
===================================================================
*** trunk.orig/gcc/cfghooks.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/cfghooks.c 2012-08-13 14:03:09.438889233 +0200
*************** split_block (basic_block bb, void *i)
*** 462,468 ****
new_bb->count = bb->count;
new_bb->frequency = bb->frequency;
- new_bb->loop_depth = bb->loop_depth;
new_bb->discriminator = bb->discriminator;
if (dom_info_available_p (CDI_DOMINATORS))
--- 462,467 ----
*************** duplicate_block (basic_block bb, edge e,
*** 985,991 ****
if (after)
move_block_after (new_bb, after);
- new_bb->loop_depth = bb->loop_depth;
new_bb->flags = bb->flags;
FOR_EACH_EDGE (s, ei, bb->succs)
{
--- 984,989 ----
Index: trunk/gcc/cfgloop.c
===================================================================
*** trunk.orig/gcc/cfgloop.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/cfgloop.c 2012-08-13 14:11:57.325870997 +0200
*************** flow_loop_nodes_find (basic_block header
*** 229,238 ****
int num_nodes = 1;
edge latch;
edge_iterator latch_ei;
- unsigned depth = loop_depth (loop);
header->loop_father = loop;
- header->loop_depth = depth;
FOR_EACH_EDGE (latch, latch_ei, loop->header->preds)
{
--- 229,236 ----
*************** flow_loop_nodes_find (basic_block header
*** 243,249 ****
num_nodes++;
VEC_safe_push (basic_block, heap, stack, latch->src);
latch->src->loop_father = loop;
- latch->src->loop_depth = depth;
while (!VEC_empty (basic_block, stack))
{
--- 241,246 ----
*************** flow_loop_nodes_find (basic_block header
*** 260,266 ****
if (ancestor->loop_father != loop)
{
ancestor->loop_father = loop;
- ancestor->loop_depth = depth;
num_nodes++;
VEC_safe_push (basic_block, heap, stack, ancestor);
}
--- 257,262 ----
*************** path_without_edge_flags (basic_block fro
*** 419,425 ****
}
/* Find all the natural loops in the function and save in LOOPS structure and
! recalculate loop_depth information in basic block structures.
Return the number of natural loops found. */
int
--- 415,421 ----
}
/* Find all the natural loops in the function and save in LOOPS structure and
! recalculate loop_father information in basic block structures.
Return the number of natural loops found. */
int
*************** flow_loops_find (struct loops *loops)
*** 458,465 ****
{
edge_iterator ei;
- header->loop_depth = 0;
-
/* If we have an abnormal predecessor, do not consider the
loop (not worth the problems). */
if (bb_has_abnormal_pred (header))
--- 454,459 ----
*************** add_bb_to_loop (basic_block bb, struct l
*** 1243,1249 ****
gcc_assert (bb->loop_father == NULL);
bb->loop_father = loop;
- bb->loop_depth = loop_depth (loop);
loop->num_nodes++;
FOR_EACH_VEC_ELT (loop_p, loop->superloops, i, ploop)
ploop->num_nodes++;
--- 1237,1242 ----
*************** remove_bb_from_loops (basic_block bb)
*** 1273,1279 ****
FOR_EACH_VEC_ELT (loop_p, loop->superloops, i, ploop)
ploop->num_nodes--;
bb->loop_father = NULL;
- bb->loop_depth = 0;
FOR_EACH_EDGE (e, ei, bb->succs)
{
--- 1266,1271 ----
Index: trunk/gcc/cfgrtl.c
===================================================================
*** trunk.orig/gcc/cfgrtl.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/cfgrtl.c 2012-08-13 14:03:09.440889233 +0200
*************** force_nonfallthru_and_redirect (edge e,
*** 1438,1444 ****
jump_block = create_basic_block (note, NULL, e->src);
jump_block->count = count;
jump_block->frequency = EDGE_FREQUENCY (e);
- jump_block->loop_depth = target->loop_depth;
/* Make sure new block ends up in correct hot/cold section. */
--- 1438,1443 ----
Index: trunk/gcc/gimple-streamer-in.c
===================================================================
*** trunk.orig/gcc/gimple-streamer-in.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/gimple-streamer-in.c 2012-08-13 14:03:09.441889233 +0200
*************** input_bb (struct lto_input_block *ib, en
*** 296,302 ****
bb->count = (streamer_read_hwi (ib) * count_materialization_scale
+ REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
- bb->loop_depth = streamer_read_hwi (ib);
bb->frequency = streamer_read_hwi (ib);
bb->flags = streamer_read_hwi (ib);
--- 296,301 ----
Index: trunk/gcc/bt-load.c
===================================================================
*** trunk.orig/gcc/bt-load.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/bt-load.c 2012-08-13 14:03:09.442889232 +0200
*************** along with GCC; see the file COPYING3.
*** 37,42 ****
--- 37,43 ----
#include "tree-pass.h"
#include "recog.h"
#include "df.h"
+ #include "cfgloop.h"
/* Target register optimizations - these are performed after reload. */
*************** migrate_btr_defs (enum reg_class btr_cla
*** 1408,1414 ****
fprintf(dump_file,
"Basic block %d: count = " HOST_WIDEST_INT_PRINT_DEC
" loop-depth = %d idom = %d\n",
! i, (HOST_WIDEST_INT) bb->count, bb->loop_depth,
get_immediate_dominator (CDI_DOMINATORS, bb)->index);
}
}
--- 1409,1415 ----
fprintf(dump_file,
"Basic block %d: count = " HOST_WIDEST_INT_PRINT_DEC
" loop-depth = %d idom = %d\n",
! i, (HOST_WIDEST_INT) bb->count, bb_loop_depth (bb),
get_immediate_dominator (CDI_DOMINATORS, bb)->index);
}
}
Index: trunk/gcc/cfg.c
===================================================================
*** trunk.orig/gcc/cfg.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/cfg.c 2012-08-13 14:03:09.442889232 +0200
*************** dump_bb_info (FILE *outf, basic_block bb
*** 698,704 ****
if (flags & TDF_COMMENT)
fputs (";; ", outf);
fprintf (outf, "%sbasic block %d, loop depth %d",
! s_indent, bb->index, bb->loop_depth);
if (flags & TDF_DETAILS)
{
fprintf (outf, ", count " HOST_WIDEST_INT_PRINT_DEC,
--- 698,704 ----
if (flags & TDF_COMMENT)
fputs (";; ", outf);
fprintf (outf, "%sbasic block %d, loop depth %d",
! s_indent, bb->index, bb_loop_depth (bb));
if (flags & TDF_DETAILS)
{
fprintf (outf, ", count " HOST_WIDEST_INT_PRINT_DEC,
Index: trunk/gcc/final.c
===================================================================
*** trunk.orig/gcc/final.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/final.c 2012-08-13 14:03:09.442889232 +0200
*************** compute_alignments (void)
*** 739,745 ****
{
if (dump_file)
fprintf(dump_file, "BB %4i freq %4i loop %2i loop_depth %2i skipped.\n",
! bb->index, bb->frequency, bb->loop_father->num, bb->loop_depth);
continue;
}
max_log = LABEL_ALIGN (label);
--- 739,746 ----
{
if (dump_file)
fprintf(dump_file, "BB %4i freq %4i loop %2i loop_depth %2i skipped.\n",
! bb->index, bb->frequency, bb->loop_father->num,
! bb_loop_depth (bb));
continue;
}
max_log = LABEL_ALIGN (label);
*************** compute_alignments (void)
*** 756,762 ****
{
fprintf(dump_file, "BB %4i freq %4i loop %2i loop_depth %2i fall %4i branch %4i",
bb->index, bb->frequency, bb->loop_father->num,
! bb->loop_depth,
fallthru_frequency, branch_frequency);
if (!bb->loop_father->inner && bb->loop_father->num)
fprintf (dump_file, " inner_loop");
--- 757,763 ----
{
fprintf(dump_file, "BB %4i freq %4i loop %2i loop_depth %2i fall %4i branch %4i",
bb->index, bb->frequency, bb->loop_father->num,
! bb_loop_depth (bb),
fallthru_frequency, branch_frequency);
if (!bb->loop_father->inner && bb->loop_father->num)
fprintf (dump_file, " inner_loop");
Index: trunk/gcc/gimple-streamer-out.c
===================================================================
*** trunk.orig/gcc/gimple-streamer-out.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/gimple-streamer-out.c 2012-08-13 14:03:09.443889232 +0200
*************** output_bb (struct output_block *ob, basi
*** 176,182 ****
streamer_write_uhwi (ob, bb->index);
streamer_write_hwi (ob, bb->count);
- streamer_write_hwi (ob, bb->loop_depth);
streamer_write_hwi (ob, bb->frequency);
streamer_write_hwi (ob, bb->flags);
--- 176,181 ----
Index: trunk/gcc/ira.c
===================================================================
*** trunk.orig/gcc/ira.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/ira.c 2012-08-13 14:03:09.443889232 +0200
*************** update_equiv_regs (void)
*** 2777,2783 ****
a register can be set below its use. */
FOR_EACH_BB (bb)
{
! loop_depth = bb->loop_depth;
for (insn = BB_HEAD (bb);
insn != NEXT_INSN (BB_END (bb));
--- 2777,2783 ----
a register can be set below its use. */
FOR_EACH_BB (bb)
{
! loop_depth = bb_loop_depth (bb);
for (insn = BB_HEAD (bb);
insn != NEXT_INSN (BB_END (bb));
*************** update_equiv_regs (void)
*** 3053,3059 ****
basic block. */
FOR_EACH_BB_REVERSE (bb)
{
! loop_depth = bb->loop_depth;
for (insn = BB_END (bb);
insn != PREV_INSN (BB_HEAD (bb));
insn = PREV_INSN (insn))
--- 3053,3059 ----
basic block. */
FOR_EACH_BB_REVERSE (bb)
{
! loop_depth = bb_loop_depth (bb);
for (insn = BB_END (bb);
insn != PREV_INSN (BB_HEAD (bb));
insn = PREV_INSN (insn))
Index: trunk/gcc/tree-ssa-copy.c
===================================================================
*** trunk.orig/gcc/tree-ssa-copy.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/tree-ssa-copy.c 2012-08-13 14:03:09.443889232 +0200
*************** init_copy_prop (void)
*** 670,676 ****
FOR_EACH_BB (bb)
{
gimple_stmt_iterator si;
! int depth = bb->loop_depth;
for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
{
--- 670,676 ----
FOR_EACH_BB (bb)
{
gimple_stmt_iterator si;
! int depth = bb_loop_depth (bb);
for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
{
Index: trunk/gcc/tree-ssa-dom.c
===================================================================
*** trunk.orig/gcc/tree-ssa-dom.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/tree-ssa-dom.c 2012-08-13 14:03:09.444889232 +0200
*************** loop_depth_of_name (tree x)
*** 1391,1397 ****
if (!defbb)
return 0;
! return defbb->loop_depth;
}
/* Record that X is equal to Y in const_and_copies. Record undo
--- 1391,1397 ----
if (!defbb)
return 0;
! return bb_loop_depth (defbb);
}
/* Record that X is equal to Y in const_and_copies. Record undo
Index: trunk/gcc/tree-ssa-forwprop.c
===================================================================
*** trunk.orig/gcc/tree-ssa-forwprop.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/tree-ssa-forwprop.c 2012-08-13 14:03:09.444889232 +0200
*************** along with GCC; see the file COPYING3.
*** 32,37 ****
--- 32,38 ----
#include "flags.h"
#include "gimple.h"
#include "expr.h"
+ #include "cfgloop.h"
/* This pass propagates the RHS of assignment statements into use
sites of the LHS of the assignment. It's basically a specialized
*************** forward_propagate_addr_expr_1 (tree name
*** 1002,1008 ****
static bool
forward_propagate_addr_expr (tree name, tree rhs)
{
! int stmt_loop_depth = gimple_bb (SSA_NAME_DEF_STMT (name))->loop_depth;
imm_use_iterator iter;
gimple use_stmt;
bool all = true;
--- 1003,1009 ----
static bool
forward_propagate_addr_expr (tree name, tree rhs)
{
! int stmt_loop_depth = bb_loop_depth (gimple_bb (SSA_NAME_DEF_STMT (name)));
imm_use_iterator iter;
gimple use_stmt;
bool all = true;
*************** forward_propagate_addr_expr (tree name,
*** 1025,1031 ****
/* If the use is in a deeper loop nest, then we do not want
to propagate non-invariant ADDR_EXPRs into the loop as that
is likely adding expression evaluations into the loop. */
! if (gimple_bb (use_stmt)->loop_depth > stmt_loop_depth
&& !is_gimple_min_invariant (rhs))
{
all = false;
--- 1026,1032 ----
/* If the use is in a deeper loop nest, then we do not want
to propagate non-invariant ADDR_EXPRs into the loop as that
is likely adding expression evaluations into the loop. */
! if (bb_loop_depth (gimple_bb (use_stmt)) > stmt_loop_depth
&& !is_gimple_min_invariant (rhs))
{
all = false;
Index: trunk/gcc/tree-ssa-pre.c
===================================================================
*** trunk.orig/gcc/tree-ssa-pre.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/tree-ssa-pre.c 2012-08-13 14:03:09.445889232 +0200
*************** insert_into_preds_of_block (basic_block
*** 3204,3210 ****
gimple phi;
/* Make sure we aren't creating an induction variable. */
! if (block->loop_depth > 0 && EDGE_COUNT (block->preds) == 2)
{
bool firstinsideloop = false;
bool secondinsideloop = false;
--- 3204,3210 ----
gimple phi;
/* Make sure we aren't creating an induction variable. */
! if (bb_loop_depth (block) > 0 && EDGE_COUNT (block->preds) == 2)
{
bool firstinsideloop = false;
bool secondinsideloop = false;
Index: trunk/gcc/tree-ssa-sink.c
===================================================================
*** trunk.orig/gcc/tree-ssa-sink.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/tree-ssa-sink.c 2012-08-13 14:03:09.445889232 +0200
*************** select_best_block (basic_block early_bb,
*** 212,218 ****
{
/* If we've moved into a lower loop nest, then that becomes
our best block. */
! if (temp_bb->loop_depth < best_bb->loop_depth)
best_bb = temp_bb;
/* Walk up the dominator tree, hopefully we'll find a shallower
--- 212,218 ----
{
/* If we've moved into a lower loop nest, then that becomes
our best block. */
! if (bb_loop_depth (temp_bb) < bb_loop_depth (best_bb))
best_bb = temp_bb;
/* Walk up the dominator tree, hopefully we'll find a shallower
*************** select_best_block (basic_block early_bb,
*** 223,229 ****
/* If we found a shallower loop nest, then we always consider that
a win. This will always give us the most control dependent block
within that loop nest. */
! if (best_bb->loop_depth < early_bb->loop_depth)
return best_bb;
/* Get the sinking threshold. If the statement to be moved has memory
--- 223,229 ----
/* If we found a shallower loop nest, then we always consider that
a win. This will always give us the most control dependent block
within that loop nest. */
! if (bb_loop_depth (best_bb) < bb_loop_depth (early_bb))
return best_bb;
/* Get the sinking threshold. If the statement to be moved has memory
*************** select_best_block (basic_block early_bb,
*** 239,245 ****
/* If BEST_BB is at the same nesting level, then require it to have
significantly lower execution frequency to avoid gratutious movement. */
! if (best_bb->loop_depth == early_bb->loop_depth
&& best_bb->frequency < (early_bb->frequency * threshold / 100.0))
return best_bb;
--- 239,245 ----
/* If BEST_BB is at the same nesting level, then require it to have
significantly lower execution frequency to avoid gratutious movement. */
! if (bb_loop_depth (best_bb) == bb_loop_depth (early_bb)
&& best_bb->frequency < (early_bb->frequency * threshold / 100.0))
return best_bb;
Index: trunk/gcc/Makefile.in
===================================================================
*** trunk.orig/gcc/Makefile.in 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/Makefile.in 2012-08-13 14:03:09.446889232 +0200
*************** tree-ssa-dse.o : tree-ssa-dse.c $(CONFIG
*** 2271,2277 ****
$(TREE_FLOW_H) $(TREE_PASS_H) domwalk.h $(FLAGS_H) \
$(GIMPLE_PRETTY_PRINT_H) langhooks.h
tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
! $(TM_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) \
$(TREE_FLOW_H) $(TREE_PASS_H) $(DIAGNOSTIC_H) \
langhooks.h $(FLAGS_H) $(GIMPLE_H) $(GIMPLE_PRETTY_PRINT_H) $(EXPR_H)
tree-ssa-phiprop.o : tree-ssa-phiprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
--- 2271,2277 ----
$(TREE_FLOW_H) $(TREE_PASS_H) domwalk.h $(FLAGS_H) \
$(GIMPLE_PRETTY_PRINT_H) langhooks.h
tree-ssa-forwprop.o : tree-ssa-forwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
! $(TM_H) $(TREE_H) $(TM_P_H) $(BASIC_BLOCK_H) $(CFGLOOP_H) \
$(TREE_FLOW_H) $(TREE_PASS_H) $(DIAGNOSTIC_H) \
langhooks.h $(FLAGS_H) $(GIMPLE_H) $(GIMPLE_PRETTY_PRINT_H) $(EXPR_H)
tree-ssa-phiprop.o : tree-ssa-phiprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
*************** ipa-inline.o : ipa-inline.c $(CONFIG_H)
*** 2899,2905 ****
$(EXCEPT_H) $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(TARGET_H) $(IPA_UTILS_H)
ipa-inline-analysis.o : ipa-inline-analysis.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
! $(DIAGNOSTIC_H) $(PARAMS_H) $(TREE_PASS_H) \
$(HASHTAB_H) $(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(IPA_PROP_H) \
$(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(LTO_STREAMER_H) $(DATA_STREAMER_H) \
$(TREE_STREAMER_H)
--- 2899,2905 ----
$(EXCEPT_H) $(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(TARGET_H) $(IPA_UTILS_H)
ipa-inline-analysis.o : ipa-inline-analysis.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) langhooks.h $(TREE_INLINE_H) $(FLAGS_H) $(CGRAPH_H) intl.h \
! $(DIAGNOSTIC_H) $(PARAMS_H) $(TREE_PASS_H) $(CFGLOOP_H) \
$(HASHTAB_H) $(COVERAGE_H) $(GGC_H) $(TREE_FLOW_H) $(IPA_PROP_H) \
$(GIMPLE_PRETTY_PRINT_H) ipa-inline.h $(LTO_STREAMER_H) $(DATA_STREAMER_H) \
$(TREE_STREAMER_H)
*************** caller-save.o : caller-save.c $(CONFIG_H
*** 3183,3189 ****
bt-load.o : bt-load.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(EXCEPT_H) \
$(RTL_H) hard-reg-set.h $(REGS_H) $(TM_P_H) $(FIBHEAP_H) $(EXPR_H) \
$(TARGET_H) $(FLAGS_H) $(INSN_ATTR_H) $(FUNCTION_H) $(TREE_PASS_H) \
! $(DIAGNOSTIC_CORE_H) $(DF_H) vecprim.h $(RECOG_H)
reorg.o : reorg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
conditions.h hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) insn-config.h \
$(INSN_ATTR_H) $(EXCEPT_H) $(RECOG_H) $(FUNCTION_H) $(FLAGS_H) output.h \
--- 3183,3189 ----
bt-load.o : bt-load.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(EXCEPT_H) \
$(RTL_H) hard-reg-set.h $(REGS_H) $(TM_P_H) $(FIBHEAP_H) $(EXPR_H) \
$(TARGET_H) $(FLAGS_H) $(INSN_ATTR_H) $(FUNCTION_H) $(TREE_PASS_H) \
! $(DIAGNOSTIC_CORE_H) $(DF_H) vecprim.h $(RECOG_H) $(CFGLOOP_H)
reorg.o : reorg.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
conditions.h hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) insn-config.h \
$(INSN_ATTR_H) $(EXCEPT_H) $(RECOG_H) $(FUNCTION_H) $(FLAGS_H) output.h \
Index: trunk/gcc/cfgloop.h
===================================================================
*** trunk.orig/gcc/cfgloop.h 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/cfgloop.h 2012-08-13 14:03:23.524888740 +0200
*************** loop_depth (const struct loop *loop)
*** 445,450 ****
--- 445,458 ----
return VEC_length (loop_p, loop->superloops);
}
+ /* Returns the loop depth of the loop BB belongs to. */
+
+ static inline int
+ bb_loop_depth (const_basic_block bb)
+ {
+ return bb->loop_father ? loop_depth (bb->loop_father) : 0;
+ }
+
/* Returns the immediate superloop of LOOP, or NULL if LOOP is the outermost
loop. */
Index: trunk/gcc/ipa-inline-analysis.c
===================================================================
*** trunk.orig/gcc/ipa-inline-analysis.c 2012-08-13 13:58:13.000000000 +0200
--- trunk/gcc/ipa-inline-analysis.c 2012-08-13 14:03:09.446889232 +0200
*************** along with GCC; see the file COPYING3.
*** 87,92 ****
--- 87,93 ----
#include "tree-streamer.h"
#include "ipa-inline.h"
#include "alloc-pool.h"
+ #include "cfgloop.h"
/* Estimate runtime of function can easilly run into huge numbers with many
nested loops. Be sure we can compute time * INLINE_SIZE_SCALE * 2 in an
*************** estimate_function_body_sizes (struct cgr
*** 2088,2094 ****
es->call_stmt_size = this_size;
es->call_stmt_time = this_time;
! es->loop_depth = bb->loop_depth;
edge_set_predicate (edge, &bb_predicate);
}
--- 2089,2095 ----
es->call_stmt_size = this_size;
es->call_stmt_time = this_time;
! es->loop_depth = bb_loop_depth (bb);
edge_set_predicate (edge, &bb_predicate);
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove basic_block->loop_depth
2012-08-13 13:02 [PATCH] Remove basic_block->loop_depth Richard Guenther
@ 2012-08-14 10:16 ` Ulrich Weigand
2012-08-14 10:51 ` Richard Guenther
0 siblings, 1 reply; 8+ messages in thread
From: Ulrich Weigand @ 2012-08-14 10:16 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
Richard Guenther wrote:
> Accessing loop_depth (bb->loop_father) isn't very expensive. The
> following removes the duplicate info in basic-blocks which is not
> properly kept up-to-date at the moment.
Looks like this broke SPU build, since spu_machine_dependent_reorg
accesses ->loop_depth. According to comments in the code, this
was done because of concerns that loop_father may no longer be set up
this late in compilation, so I'm wondering whether just replacing
this by loop_depth (bb->loop_father) would work here ...
/* If this branch is a loop exit then propagate to previous
fallthru block. This catches the cases when it is a simple
loop or when there is an initial branch into the loop. */
if (prev && (loop_exit || simple_loop)
&& prev->loop_depth <= bb->loop_depth)
prop = prev;
/* If there is only one adjacent predecessor. Don't propagate
outside this loop. This loop_depth test isn't perfect, but
I'm not sure the loop_father member is valid at this point. */
else if (prev && single_pred_p (bb)
&& prev->loop_depth == bb->loop_depth)
prop = prev;
Any suggestions?
Thanks,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove basic_block->loop_depth
2012-08-14 10:16 ` Ulrich Weigand
@ 2012-08-14 10:51 ` Richard Guenther
2012-08-14 11:00 ` Steven Bosscher
2012-08-15 12:04 ` [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth) Ulrich Weigand
0 siblings, 2 replies; 8+ messages in thread
From: Richard Guenther @ 2012-08-14 10:51 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gcc-patches
On Tue, 14 Aug 2012, Ulrich Weigand wrote:
> Richard Guenther wrote:
>
> > Accessing loop_depth (bb->loop_father) isn't very expensive. The
> > following removes the duplicate info in basic-blocks which is not
> > properly kept up-to-date at the moment.
>
> Looks like this broke SPU build, since spu_machine_dependent_reorg
> accesses ->loop_depth. According to comments in the code, this
> was done because of concerns that loop_father may no longer be set up
> this late in compilation, so I'm wondering whether just replacing
> this by loop_depth (bb->loop_father) would work here ...
Well, if loops are no longer set up (thus ->loop_father is NULL) then
the loop_depth information was stale and possibly wrong.
> /* If this branch is a loop exit then propagate to previous
> fallthru block. This catches the cases when it is a simple
> loop or when there is an initial branch into the loop. */
> if (prev && (loop_exit || simple_loop)
> && prev->loop_depth <= bb->loop_depth)
> prop = prev;
>
> /* If there is only one adjacent predecessor. Don't propagate
> outside this loop. This loop_depth test isn't perfect, but
> I'm not sure the loop_father member is valid at this point. */
> else if (prev && single_pred_p (bb)
> && prev->loop_depth == bb->loop_depth)
> prop = prev;
>
> Any suggestions?
If SPU md reorg would like to look at loop structures it should
compute them. Simply call flow_loops_find, which hopefully works
in CFG RTL mode (which I think is the mode available from md reorg?).
I was simply throwing away loops after RTL loop optimizers not only
because IRA for some weird reason decides to re-compute them in
non-standard ways and because loop verification fails between
ira / reload passes. So the other way would be to preserve loops
for a longer period.
Richard.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove basic_block->loop_depth
2012-08-14 10:51 ` Richard Guenther
@ 2012-08-14 11:00 ` Steven Bosscher
2012-08-14 11:01 ` Richard Guenther
2012-08-15 12:04 ` [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth) Ulrich Weigand
1 sibling, 1 reply; 8+ messages in thread
From: Steven Bosscher @ 2012-08-14 11:00 UTC (permalink / raw)
To: Richard Guenther; +Cc: Ulrich Weigand, gcc-patches
On Tue, Aug 14, 2012 at 12:48 PM, Richard Guenther <rguenther@suse.de> wrote:
> If SPU md reorg would like to look at loop structures it should
> compute them. Simply call flow_loops_find, which hopefully works
> in CFG RTL mode (which I think is the mode available from md reorg?).
No, the CFG is destroyed just before MD reorg, because most MD reorgs
are not CFG aware.
But some back-ends re-surrect it (bfin, ia64, c6x, etc...), and do
compute loops (c6x at least).
Ciao!
Steven
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Remove basic_block->loop_depth
2012-08-14 11:00 ` Steven Bosscher
@ 2012-08-14 11:01 ` Richard Guenther
0 siblings, 0 replies; 8+ messages in thread
From: Richard Guenther @ 2012-08-14 11:01 UTC (permalink / raw)
To: Steven Bosscher; +Cc: Ulrich Weigand, gcc-patches
On Tue, 14 Aug 2012, Steven Bosscher wrote:
> On Tue, Aug 14, 2012 at 12:48 PM, Richard Guenther <rguenther@suse.de> wrote:
> > If SPU md reorg would like to look at loop structures it should
> > compute them. Simply call flow_loops_find, which hopefully works
> > in CFG RTL mode (which I think is the mode available from md reorg?).
>
> No, the CFG is destroyed just before MD reorg, because most MD reorgs
> are not CFG aware.
>
> But some back-ends re-surrect it (bfin, ia64, c6x, etc...), and do
> compute loops (c6x at least).
I suppose we could push down freeing the CFG to the individual MD
reorgs and make the default MD reorg simply free the CFG ...
Richard.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth)
2012-08-14 10:51 ` Richard Guenther
2012-08-14 11:00 ` Steven Bosscher
@ 2012-08-15 12:04 ` Ulrich Weigand
2012-08-15 12:07 ` Richard Guenther
1 sibling, 1 reply; 8+ messages in thread
From: Ulrich Weigand @ 2012-08-15 12:04 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
Richard Guenther wrote:
> On Tue, 14 Aug 2012, Ulrich Weigand wrote:
> > Looks like this broke SPU build, since spu_machine_dependent_reorg
> > accesses ->loop_depth. According to comments in the code, this
> > was done because of concerns that loop_father may no longer be set up
> > this late in compilation, so I'm wondering whether just replacing
> > this by loop_depth (bb->loop_father) would work here ...
> If SPU md reorg would like to look at loop structures it should
> compute them. Simply call flow_loops_find, which hopefully works
> in CFG RTL mode (which I think is the mode available from md reorg?).
It seems flow_loops_find by itself is not quite enough, but everything
necessary to use the loop structures seems to be encapsulated in
loop_optimizer_init / loop_optimizer_finalize, which are already called
by a number of optimization passes. When I do the same in the SPU
md-reorg pass, loop_father seems to be set up OK.
Does this look reasonable?
Thanks,
Ulrich
ChangeLog:
* config/spu/spu.c: Include "cfgloop.h".
(spu_machine_dependent_reorg): Call loop_optimizer_init and
loop_optimizer_finalize. Use loop_father instead of loop_depth.
* config/spu/t-spu-elf (spu.o): Update dependencies.
Index: gcc/config/spu/spu.c
===================================================================
*** gcc/config/spu/spu.c (revision 190390)
--- gcc/config/spu/spu.c (working copy)
***************
*** 53,58 ****
--- 53,59 ----
#include "timevar.h"
#include "df.h"
#include "dumpfile.h"
+ #include "cfgloop.h"
/* Builtin types, data and prototypes. */
*************** spu_machine_dependent_reorg (void)
*** 2458,2463 ****
--- 2459,2468 ----
in_spu_reorg = 1;
compute_bb_for_insn ();
+ /* (Re-)discover loops so that bb->loop_father can be used
+ in the analysis below. */
+ loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
+
compact_blocks ();
spu_bb_info =
*************** spu_machine_dependent_reorg (void)
*** 2562,2575 ****
fallthru block. This catches the cases when it is a simple
loop or when there is an initial branch into the loop. */
if (prev && (loop_exit || simple_loop)
! && prev->loop_depth <= bb->loop_depth)
prop = prev;
/* If there is only one adjacent predecessor. Don't propagate
! outside this loop. This loop_depth test isn't perfect, but
! I'm not sure the loop_father member is valid at this point. */
else if (prev && single_pred_p (bb)
! && prev->loop_depth == bb->loop_depth)
prop = prev;
/* If this is the JOIN block of a simple IF-THEN then
--- 2567,2580 ----
fallthru block. This catches the cases when it is a simple
loop or when there is an initial branch into the loop. */
if (prev && (loop_exit || simple_loop)
! && (loop_depth (prev->loop_father)
! <= loop_depth (bb->loop_father)))
prop = prev;
/* If there is only one adjacent predecessor. Don't propagate
! outside this loop. */
else if (prev && single_pred_p (bb)
! && prev->loop_father == bb->loop_father)
prop = prev;
/* If this is the JOIN block of a simple IF-THEN then
*************** spu_machine_dependent_reorg (void)
*** 2578,2584 ****
&& EDGE_COUNT (bb->preds) == 2
&& EDGE_COUNT (prev->preds) == 1
&& EDGE_PRED (prev, 0)->src == prev2
! && prev2->loop_depth == bb->loop_depth
&& GET_CODE (branch_target) != REG)
prop = prev;
--- 2583,2589 ----
&& EDGE_COUNT (bb->preds) == 2
&& EDGE_COUNT (prev->preds) == 1
&& EDGE_PRED (prev, 0)->src == prev2
! && prev2->loop_father == bb->loop_father
&& GET_CODE (branch_target) != REG)
prop = prev;
*************** spu_machine_dependent_reorg (void)
*** 2600,2606 ****
if (dump_file)
fprintf (dump_file, "propagate from %i to %i (loop depth %i) "
"for %i (loop_exit %i simple_loop %i dist %i)\n",
! bb->index, prop->index, bb->loop_depth,
INSN_UID (branch), loop_exit, simple_loop,
branch_addr - INSN_ADDRESSES (INSN_UID (bbend)));
--- 2605,2611 ----
if (dump_file)
fprintf (dump_file, "propagate from %i to %i (loop depth %i) "
"for %i (loop_exit %i simple_loop %i dist %i)\n",
! bb->index, prop->index, loop_depth (bb->loop_father),
INSN_UID (branch), loop_exit, simple_loop,
branch_addr - INSN_ADDRESSES (INSN_UID (bbend)));
*************** spu_machine_dependent_reorg (void)
*** 2657,2662 ****
--- 2662,2669 ----
spu_var_tracking ();
+ loop_optimizer_finalize ();
+
free_bb_for_insn ();
in_spu_reorg = 0;
Index: gcc/config/spu/t-spu-elf
===================================================================
*** gcc/config/spu/t-spu-elf (revision 190390)
--- gcc/config/spu/t-spu-elf (working copy)
*************** spu.o: $(CONFIG_H) $(SYSTEM_H) coretypes
*** 23,29 ****
real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
$(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
output.h $(BASIC_BLOCK_H) $(GGC_H) $(HASHTAB_H) \
! $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h \
$(srcdir)/config/spu/spu-protos.h \
$(srcdir)/config/spu/spu-builtins.def
--- 23,29 ----
real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
$(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
output.h $(BASIC_BLOCK_H) $(GGC_H) $(HASHTAB_H) \
! $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h $(CFGLOOP_H) \
$(srcdir)/config/spu/spu-protos.h \
$(srcdir)/config/spu/spu-builtins.def
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth)
2012-08-15 12:04 ` [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth) Ulrich Weigand
@ 2012-08-15 12:07 ` Richard Guenther
2012-08-15 22:18 ` Ulrich Weigand
0 siblings, 1 reply; 8+ messages in thread
From: Richard Guenther @ 2012-08-15 12:07 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: gcc-patches
On Wed, 15 Aug 2012, Ulrich Weigand wrote:
> Richard Guenther wrote:
> > On Tue, 14 Aug 2012, Ulrich Weigand wrote:
> > > Looks like this broke SPU build, since spu_machine_dependent_reorg
> > > accesses ->loop_depth. According to comments in the code, this
> > > was done because of concerns that loop_father may no longer be set up
> > > this late in compilation, so I'm wondering whether just replacing
> > > this by loop_depth (bb->loop_father) would work here ...
>
> > If SPU md reorg would like to look at loop structures it should
> > compute them. Simply call flow_loops_find, which hopefully works
> > in CFG RTL mode (which I think is the mode available from md reorg?).
>
> It seems flow_loops_find by itself is not quite enough, but everything
> necessary to use the loop structures seems to be encapsulated in
> loop_optimizer_init / loop_optimizer_finalize, which are already called
> by a number of optimization passes. When I do the same in the SPU
> md-reorg pass, loop_father seems to be set up OK.
>
> Does this look reasonable?
Yes. You can use bb_loop_depth instead of loop_depth (bb->loop_father).
Richard.
> Thanks,
> Ulrich
>
>
> ChangeLog:
>
> * config/spu/spu.c: Include "cfgloop.h".
> (spu_machine_dependent_reorg): Call loop_optimizer_init and
> loop_optimizer_finalize. Use loop_father instead of loop_depth.
> * config/spu/t-spu-elf (spu.o): Update dependencies.
>
> Index: gcc/config/spu/spu.c
> ===================================================================
> *** gcc/config/spu/spu.c (revision 190390)
> --- gcc/config/spu/spu.c (working copy)
> ***************
> *** 53,58 ****
> --- 53,59 ----
> #include "timevar.h"
> #include "df.h"
> #include "dumpfile.h"
> + #include "cfgloop.h"
>
> /* Builtin types, data and prototypes. */
>
> *************** spu_machine_dependent_reorg (void)
> *** 2458,2463 ****
> --- 2459,2468 ----
> in_spu_reorg = 1;
> compute_bb_for_insn ();
>
> + /* (Re-)discover loops so that bb->loop_father can be used
> + in the analysis below. */
> + loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
> +
> compact_blocks ();
>
> spu_bb_info =
> *************** spu_machine_dependent_reorg (void)
> *** 2562,2575 ****
> fallthru block. This catches the cases when it is a simple
> loop or when there is an initial branch into the loop. */
> if (prev && (loop_exit || simple_loop)
> ! && prev->loop_depth <= bb->loop_depth)
> prop = prev;
>
> /* If there is only one adjacent predecessor. Don't propagate
> ! outside this loop. This loop_depth test isn't perfect, but
> ! I'm not sure the loop_father member is valid at this point. */
> else if (prev && single_pred_p (bb)
> ! && prev->loop_depth == bb->loop_depth)
> prop = prev;
>
> /* If this is the JOIN block of a simple IF-THEN then
> --- 2567,2580 ----
> fallthru block. This catches the cases when it is a simple
> loop or when there is an initial branch into the loop. */
> if (prev && (loop_exit || simple_loop)
> ! && (loop_depth (prev->loop_father)
> ! <= loop_depth (bb->loop_father)))
> prop = prev;
>
> /* If there is only one adjacent predecessor. Don't propagate
> ! outside this loop. */
> else if (prev && single_pred_p (bb)
> ! && prev->loop_father == bb->loop_father)
> prop = prev;
>
> /* If this is the JOIN block of a simple IF-THEN then
> *************** spu_machine_dependent_reorg (void)
> *** 2578,2584 ****
> && EDGE_COUNT (bb->preds) == 2
> && EDGE_COUNT (prev->preds) == 1
> && EDGE_PRED (prev, 0)->src == prev2
> ! && prev2->loop_depth == bb->loop_depth
> && GET_CODE (branch_target) != REG)
> prop = prev;
>
> --- 2583,2589 ----
> && EDGE_COUNT (bb->preds) == 2
> && EDGE_COUNT (prev->preds) == 1
> && EDGE_PRED (prev, 0)->src == prev2
> ! && prev2->loop_father == bb->loop_father
> && GET_CODE (branch_target) != REG)
> prop = prev;
>
> *************** spu_machine_dependent_reorg (void)
> *** 2600,2606 ****
> if (dump_file)
> fprintf (dump_file, "propagate from %i to %i (loop depth %i) "
> "for %i (loop_exit %i simple_loop %i dist %i)\n",
> ! bb->index, prop->index, bb->loop_depth,
> INSN_UID (branch), loop_exit, simple_loop,
> branch_addr - INSN_ADDRESSES (INSN_UID (bbend)));
>
> --- 2605,2611 ----
> if (dump_file)
> fprintf (dump_file, "propagate from %i to %i (loop depth %i) "
> "for %i (loop_exit %i simple_loop %i dist %i)\n",
> ! bb->index, prop->index, loop_depth (bb->loop_father),
> INSN_UID (branch), loop_exit, simple_loop,
> branch_addr - INSN_ADDRESSES (INSN_UID (bbend)));
>
> *************** spu_machine_dependent_reorg (void)
> *** 2657,2662 ****
> --- 2662,2669 ----
>
> spu_var_tracking ();
>
> + loop_optimizer_finalize ();
> +
> free_bb_for_insn ();
>
> in_spu_reorg = 0;
> Index: gcc/config/spu/t-spu-elf
> ===================================================================
> *** gcc/config/spu/t-spu-elf (revision 190390)
> --- gcc/config/spu/t-spu-elf (working copy)
> *************** spu.o: $(CONFIG_H) $(SYSTEM_H) coretypes
> *** 23,29 ****
> real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
> $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
> output.h $(BASIC_BLOCK_H) $(GGC_H) $(HASHTAB_H) \
> ! $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h \
> $(srcdir)/config/spu/spu-protos.h \
> $(srcdir)/config/spu/spu-builtins.def
>
> --- 23,29 ----
> real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
> $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
> output.h $(BASIC_BLOCK_H) $(GGC_H) $(HASHTAB_H) \
> ! $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h $(CFGLOOP_H) \
> $(srcdir)/config/spu/spu-protos.h \
> $(srcdir)/config/spu/spu-builtins.def
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth)
2012-08-15 12:07 ` Richard Guenther
@ 2012-08-15 22:18 ` Ulrich Weigand
0 siblings, 0 replies; 8+ messages in thread
From: Ulrich Weigand @ 2012-08-15 22:18 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
Richard Guenther wrote:
> On Wed, 15 Aug 2012, Ulrich Weigand wrote:
> > It seems flow_loops_find by itself is not quite enough, but everything
> > necessary to use the loop structures seems to be encapsulated in
> > loop_optimizer_init / loop_optimizer_finalize, which are already called
> > by a number of optimization passes. When I do the same in the SPU
> > md-reorg pass, loop_father seems to be set up OK.
> >
> > Does this look reasonable?
>
> Yes. You can use bb_loop_depth instead of loop_depth (bb->loop_father).
Ah, good point. Below the version I committed. Tested on spu-elf.
Thanks,
Ulrich
ChangeLog:
* config/spu/spu.c: Include "cfgloop.h".
(spu_machine_dependent_reorg): Call loop_optimizer_init and
loop_optimizer_finalize. Use bb_loop_depth instead of loop_depth.
Directly compare loop_father values where appropriate.
* config/spu/t-spu-elf (spu.o): Update dependencies.
Index: gcc/config/spu/spu.c
===================================================================
*** gcc/config/spu/spu.c (revision 190390)
--- gcc/config/spu/spu.c (working copy)
***************
*** 53,58 ****
--- 53,59 ----
#include "timevar.h"
#include "df.h"
#include "dumpfile.h"
+ #include "cfgloop.h"
/* Builtin types, data and prototypes. */
*************** spu_machine_dependent_reorg (void)
*** 2458,2463 ****
--- 2459,2468 ----
in_spu_reorg = 1;
compute_bb_for_insn ();
+ /* (Re-)discover loops so that bb->loop_father can be used
+ in the analysis below. */
+ loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
+
compact_blocks ();
spu_bb_info =
*************** spu_machine_dependent_reorg (void)
*** 2562,2575 ****
fallthru block. This catches the cases when it is a simple
loop or when there is an initial branch into the loop. */
if (prev && (loop_exit || simple_loop)
! && prev->loop_depth <= bb->loop_depth)
prop = prev;
/* If there is only one adjacent predecessor. Don't propagate
! outside this loop. This loop_depth test isn't perfect, but
! I'm not sure the loop_father member is valid at this point. */
else if (prev && single_pred_p (bb)
! && prev->loop_depth == bb->loop_depth)
prop = prev;
/* If this is the JOIN block of a simple IF-THEN then
--- 2567,2579 ----
fallthru block. This catches the cases when it is a simple
loop or when there is an initial branch into the loop. */
if (prev && (loop_exit || simple_loop)
! && bb_loop_depth (prev) <= bb_loop_depth (bb))
prop = prev;
/* If there is only one adjacent predecessor. Don't propagate
! outside this loop. */
else if (prev && single_pred_p (bb)
! && prev->loop_father == bb->loop_father)
prop = prev;
/* If this is the JOIN block of a simple IF-THEN then
*************** spu_machine_dependent_reorg (void)
*** 2578,2584 ****
&& EDGE_COUNT (bb->preds) == 2
&& EDGE_COUNT (prev->preds) == 1
&& EDGE_PRED (prev, 0)->src == prev2
! && prev2->loop_depth == bb->loop_depth
&& GET_CODE (branch_target) != REG)
prop = prev;
--- 2582,2588 ----
&& EDGE_COUNT (bb->preds) == 2
&& EDGE_COUNT (prev->preds) == 1
&& EDGE_PRED (prev, 0)->src == prev2
! && prev2->loop_father == bb->loop_father
&& GET_CODE (branch_target) != REG)
prop = prev;
*************** spu_machine_dependent_reorg (void)
*** 2600,2606 ****
if (dump_file)
fprintf (dump_file, "propagate from %i to %i (loop depth %i) "
"for %i (loop_exit %i simple_loop %i dist %i)\n",
! bb->index, prop->index, bb->loop_depth,
INSN_UID (branch), loop_exit, simple_loop,
branch_addr - INSN_ADDRESSES (INSN_UID (bbend)));
--- 2604,2610 ----
if (dump_file)
fprintf (dump_file, "propagate from %i to %i (loop depth %i) "
"for %i (loop_exit %i simple_loop %i dist %i)\n",
! bb->index, prop->index, bb_loop_depth (bb),
INSN_UID (branch), loop_exit, simple_loop,
branch_addr - INSN_ADDRESSES (INSN_UID (bbend)));
*************** spu_machine_dependent_reorg (void)
*** 2657,2662 ****
--- 2661,2668 ----
spu_var_tracking ();
+ loop_optimizer_finalize ();
+
free_bb_for_insn ();
in_spu_reorg = 0;
Index: gcc/config/spu/t-spu-elf
===================================================================
*** gcc/config/spu/t-spu-elf (revision 190390)
--- gcc/config/spu/t-spu-elf (working copy)
*************** spu.o: $(CONFIG_H) $(SYSTEM_H) coretypes
*** 23,29 ****
real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
$(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
output.h $(BASIC_BLOCK_H) $(GGC_H) $(HASHTAB_H) \
! $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h \
$(srcdir)/config/spu/spu-protos.h \
$(srcdir)/config/spu/spu-builtins.def
--- 23,29 ----
real.h insn-config.h conditions.h insn-attr.h flags.h $(RECOG_H) \
$(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
output.h $(BASIC_BLOCK_H) $(GGC_H) $(HASHTAB_H) \
! $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h $(CFGLOOP_H) \
$(srcdir)/config/spu/spu-protos.h \
$(srcdir)/config/spu/spu-builtins.def
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-15 22:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-13 13:02 [PATCH] Remove basic_block->loop_depth Richard Guenther
2012-08-14 10:16 ` Ulrich Weigand
2012-08-14 10:51 ` Richard Guenther
2012-08-14 11:00 ` Steven Bosscher
2012-08-14 11:01 ` Richard Guenther
2012-08-15 12:04 ` [rfc] Fix SPU build (Re: [PATCH] Remove basic_block->loop_depth) Ulrich Weigand
2012-08-15 12:07 ` Richard Guenther
2012-08-15 22:18 ` Ulrich Weigand
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).