This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: use type-safe vectors for basic block edges


The following jumbo patch converts all of the basic block edge lists
to use Nathan Sidwell's type-safe vector API.  This patch is a
invasive change that will make it easy to improve accesses to in-edges
for phi node arguments.  (Let's change one thing at a time. :-)

The patch has been verified to have no effect on generated code or
compile-time performance.  It has been bootstrap and regression tested
on the following native configurations:

  i686-pc-linux-gnu
  powerpc-unknown-linux-gnu
  powerpc-ibm-aix5.1
  amd64-unknown-linux-gnu

It has also been regression tested on the following configurations
(native and cross, respectively) due to changes to backends in these
targets:

  ia64-unknown-linux-gnu
  frv-elf

Okay to commit?
Ben

2004-09-13  Ben Elliston  <bje@au.ibm.com>

	* basic-block.h: Include vec.h, errors.h. Instantiate a VEC(edge).
	(struct edge_def): Remove pred_next, succ_next members.
	(struct edge_stack): New.
	(struct basic_block_def): Remove pred, succ members. Add preds and
	succs members of type VEC(edge).
	(FALLTHRU_EDGE): Redefine using EDGE_SUCC.
	(BRANCH_EDGE): Likewise.
	(EDGE_CRITICAL_P): Redefine using EDGE_COUNT.
	(EDGE_COUNT, EDGE_I, EDGE_PRED, EDGE_SUCC): New.
	(FOR_EACH_EDGE, END_FOR_EACH_EDGE): New.
	* bb-reorder.c (find_traces): Use FOR_EACH_EDGE and EDGE accessor
	macros where applicable.
	(rotate_loop): Likewise.
	(find_traces_1_round): Likewise.
	(bb_to_key): Likewise.
	(connect_traces): Likewise.
	(copy_bb_p): Likewise.
	(find_rarely_executed_basic_blocks_and_crossing_edges): Likewise.
	(add_labels_and_missing_jumps): Likewise.
	(fix_up_fall_thru_edges): Likewise.
	(find_jump_block): Likewise.
	(find_crossing_conditional_branches): Likewise.
	(fix_crossing_conditional_branches): Likewise.
	(fix_crossing_unconditional_branches): Likewise.
	(add_reg_corssing_jump_notes): Likewise.
	* bt-load.c (augment_live_range): Likewise.
	* cfg.c (clear_edges): Likewise.
	(unchecked_make_edge): Likewise.
	(cached_make_edge): Likewise.
	(make_single_succ_edge): Likewise.
	(remove_edge): Likewise.
	(redirect_edge_succ_nodup): Likewise.
	(check_bb_profile): Likewise.
	(dump_flow_info): Likewise.
	(alloc_aux_for_edges): Likewise.
	(clear_aux_for_edges): Likewise.
	(dump_cfg_bb_info): Likewise.
	* cfganal.c (forwarder_block_p): Likewise.
	(can_fallthru): Likewise.
	(could_fall_through): Likewise.
	(mark_dfs_back_edges): Likewise.
	(set_edge_can_fallthru_flag): Likewise.
	(find_unreachable_blocks): Likewise.
	(create_edge_list): Likewise.
	(verify_edge_list): Likewise.
	(find_edge): Likewise.
	(remove_fake_predecessors): Likewise.
	(add_noreturn_fake_exit_edges): Likewise.
	(connect_infinite_loops_to_exit): Likewise.
	(flow_reverse_top_sort_order_compute): Likewise.
	(flow_depth_first_order_compute): Likewise.
	(flow_preorder_transversal_compute): Likewise.
	(flow_dfs_compute_reverse_execute): Likewise.
	(dfs_enumerate_from): Likewise.
	(compute_dominance_frontiers_1): Likewise.
	(compute_dominance_frontiers): Likewise.
	* cfgbuild.c (make_edges): Likewise.
	(compute_outgoing_frequencies): Likewise.
	(find_many_sub_basic_blocks): Likewise.
	(find_sub_basic_blocks): Likewise.
	* cfgcleanup.c (try_simplify_condjump): Likewise.
	(thread_jump): Likewise.
	(try_forward_edges): Likewise.
	(merge_blocks_move): Likewise.
	(outgoing_edges_match): Likewise.
	(try_crossjump_to_edge): Likewise.
	(try_crossjump_bb): Likewise.
	(try_optimize_cfg): Likewise.
	(merge_seq_blocks): Likewise.
	* cfgexpand.c (expand_gimple_tailcall): Likewise.
	(expand_gimple_basic_block): Likewise.
	(construct_exit_block): Likewise.
	* cfghooks.c (verify_flow_info): Likewise.
	(dump_bb): Likewise.
	(delete_basic_block): Likewise.
	(split_edge): Likewise.
	(merge_blocks): Likewise.
	(make_forwarder_block): Likewise.
	(tidy_fallthru_edges): Likewise.
	(can_duplicate_block_p): Likewise.
	(duplicate_block): Likewise.
	* cfglayout.c (fixup_reorder_chain): Likewise.
	(fixup_fallthru_exit_predecessor): Likewise.
	(can_copy_bbs_p): Likewise.
	(copy_bbs): Likewise.
	* cfgloop.c (flow_loops_cfg_dump): Likewise.
	(flow_loop_entry_edges_find): Likewise.
	(flow_loop_exit_edges_find): Likewise.
	(flow_loop_nodes_find): Likewise.
	(mark_single_exit_loops): Likewise.
	(flow_loop_pre_header_scan): Likewise.
	(flow_loop_pre_header_find): Likewise.
	(update_latch_info): Likewise.
	(canonicalize_loop_headers): Likewise.
	(flow_loops_find): Likewise.
	(get_loop_body_in_bfs_order): Likewise.
	(get_loop_exit_edges): Likewise.
	(get_num_loop_branches): Likewise.
	(verify_loop_structure): Likewise.
	(loop_latch_edge): Likewise.
	(loop_preheader_edge): Likewise.
	* cfgloopanal.c (mark_irreducible_loops): Likewise.
	(expected_loop_iterations): Likewise.
	* cfgloopmanip.c (remove_bbs): Likewise.
	(fix_bb_placement): Likewise.
	(fix_bb_placements): Likewise.
	(fix_irreducible_loops): Likewise.
	(remove_path): Likewise.
	(scale_bbs_frequencies): Likewise.
	(loopify): Likewise.
	(unloop): Likewise.
	(fix_loop_placement): Likewise.
	(loop_delete_branch_edge): Likewise.
	(duplicate_loop_to_header_edge): Likewise.
	(mfb_keep_just): Likewise.
	(create_preheader): Likewise.
	(force_single_succ_latches): Likewise.
	(loop_split_edge_with): Likewise.
	(create_loop_notes): Likewise.
	* cfgrtl.c (rtl_split_block): Likewise.
	(rtl_can_merge_blocks): Likewise.
	(try_redirect_by_replacing_jump): Likewise.
	(force_nonfallthru_and_redirect): Likewise.
	(rtl_tidy_fallthru_edge): Likewise.
	(rtl_split_edge): Likewise.
	(commit_one_edge_insertion): Likewise.
	(commit_edge_insertions): Likewise.
	(commit_edge_insertions_watch_calls): Likewise.
	(rtl_verify_flow_info_1): Likewise.
	(rtl_verify_flow_info): Likewise.
	(purge_dead_edges): Likewise.
	(cfg_layout_redirect_edge_and_branch): Likewise.
	(cfg_layout_can_merge_blocks_p): Likewise.
	(cfg_layout_merge_blocks): Likewise.
	(rtl_flow_call_edges_add): Likewise.
	* cse.c (cse_cc_succs): Likewise.
	* df.c (hybrid_search): Likewise.
	* dominance.c (calc_dfs_tree_nonrec): Likewise.
	(calc_dfs_tree): Likewise.
	(calc_idoms): Likewise.
	(recount_dominator): Likewise.
	* domwalk.c (walk_dominator_tree): Likewise.
	* except.c (emit_to_new_bb_before): Likewise.
	(connect_post_landing_pads): Likewise.
	(sjlj_emit_function_enter): Likewise.
	(sjlj_emit_function_exit): Likewise.
	(finish_eh_generation): Likewise.
	* final.c (compute_alignments):	Likewise.
	* flow.c (calculate_global_regs_live): Likewise.
	(initialize_uninitialized_subregs): Likewise.
	(init_propagate_block_info): Likewise.
	* function.c (thread_prologue_and_epilogue_insns): Likewise.
	* gcse.c (find_implicit_sets): Likewise.
	(bypass_block): Likewise.
	(bypass_conditional_jumps): Likewise.
	(compute_pre_data): Likewise.
	(pre_expr_reaches_here_p_work): Likewise.
	(insert_insn_end_bb): Likewise.
	(hoist_expr_reaches_here_p): Likewise.
	(insert_store): Likewise.
	(remove_reachable_equiv_notes): Likewise.
	* global.c (global_conflicts): Likewise.
	(calculate_reg_pav): Likewise.
	* graph.c (print_rtl_graph_with_bb): Likewise.
	* ifcvt.c (mark_loop_exit_edges): Likewise.
	(block_fallthru): Likewise.
	(merge_if_block): Likewise.
	(find_if_header): Likewise.
	(block_jumps_and_fallthru_p): Likewise.
	(find_if_block): Likewise.
	(find_cond_trap): Likewise.
	(block_has_only_trap): Likewise.
	(find_if_case_1): Likewise.
	(find_if_case_2): Likewise.
	* lambda-code.c (lambda_loopnest_to_gcc_loopnest): Likewise.
	* lcm.c (compute_antinout_edge): Likewise.
	(compute_laterin): Likewise.
	(compute_available): Likewise.
	(compute_nearerout): Likewise.
	(make_preds_opaque): Likewise.
	* loop-doloop.c (doloop_modify): Likewise.
	* loop-init.c (loop_optimizer_init): Likewise.
	* loop-invariant.c (find_exits): Likewise.
	* loop-iv.c (simplify_using_initial_values): Likewise.
	(check_simple_exit): Likewise.
	(find_simple_exit): Likewise.
	* loop-unroll.c (unroll_loop_constant_iterations): Likewise.
	(unroll_loop_runtime_iterations): Likewise.
	* loop-unswitch.c (may_unswitch_on): Likewise.
	(unswitch_loop): Likewise.
	* modulo-sched.c (generate_prolog_epilog): Likewise.
	(sms_schedule): Likewise.
	* postreload-gcse.c (bb_has_well_behaved_predecessors): Likewise.
	(eliminate_partially_redundant_load): Likewise.
	* predict.c (can_predict_insn_p): Likewise.
	(set_even_probabilities): Likewise.
	(combine_predictions_for_insn): Likewise.
	(combine_predictions_for_bb): Likewise.
	(predict_loops): Likewise.
	(estimate_probability): Likewise.
	(tree_predict_by_opcode): Likewise.
	(tree_estimate_probability): Likewise.
	(last_basic_block_p): Likewise.
	(propagate_freq): Likewise.
	(estimate_loops_at_level): Likewise.
	(estimate_bb_frequencies): Likewise.
	* profile.c (instrument_edges): Likewise.
	(get_exec_counts): Likewise.
	(compute_branch_probabilities): Likewise.
	(branch_prob): Likewise.
	* ra-build.c (live_in): Likewise.
	* ra-rewrite.c (rewrite_program2): Likewise.
	* ra.c (reg_alloc): Likewise.
	* recog.c (peephole2_optimize): Likewise.
	* reg-stack.c (reg_to_stack): Likewise.
	(convert_regs_entry): Likewise.
	(compensate_edge): Likewise.
	(convert_regs_1): Likewise.
	(convert_regs_2): Likewise.
	(convert_regs): Likewise.
	* regrename.c (copyprop_hardreg_forward): Likewise.
	* reload1.c (fixup_abnormal_edges): Likewise.
	* sbitmap.c (sbitmap_intersection_of_succs): Likewise.
	(sbitmap_intersection_of_preds): Likewise.
	(sbitmap_union_of_succs): Likewise.
	(sbitmap_union_of_preds): Likewise.
	* sched-ebb.c (compute_jump_reg_dependencies): Likewise.
	(fix_basic_block_boundaries): Likewise.
	(schedule_ebbs): Likewise.
	* sched-rgn.c (build_control_flow): Likewise.
	(find_rgns): Likewise.
	* tracer.c (find_best_successor): Likewise.
	(find_best_predecessor): Likewise.
	(tail_duplicate): Likewise.
	(layout_superblocks): Likewise.
	* tree-cfg.c (make_edges): Likewise.
	(make_ctrl_stmt_edges): Likewise.
	(make_goto_expr_edges): Likewise.
	(tree_can_merge_blocks_p): Likewise.
	(tree_merge_blocks): Likewise.
	(cfg_remove_useless_stmts_bb): Likewise.
	(remove_phi_nodes_and_edges_for_unreachable_block): Likewise.
	(tree_block_forwards_to): Likewise.
	(cleanup_control_expr_graph): Likewise.
	(find_taken_edge): Likewise.
	(dump_cfg_stats): Likewise.
	(tree_cfg2vcg): Likewise.
	(disband_implicit_edges): Likewise.
	(tree_find_edge_insert_loc): Likewise.
	(bsi_commit_edge_inserts): Likewise.
	(tree_split_edge): Likewise.
	(tree_verify_flow_info): Likewise.
	(tree_make_forwarder_block): Likewise.
	(tree_forwarder_block_p): Likewise.
	(thread_jumps): Likewise.
	(tree_try_redirect_by_replacing_jump): Likewise.
	(tree_split_block): Likewise.
	(dump_function_to_file): Likewise.
	(print_loop): Likewise.
	(tree_flow_call_edges_add): Likewise.
	(split_critical_edges): Likewise.
	(execute_warn_function_return): Likewise.
	(extract_true_false_edges_from_block): Likewise.
	* tree-if-conv.c (tree_if_conversion): Likewise.
	(if_convertable_bb_p): Likewise.
	(if_convertable_loop_p): Likewise.
	(find_phi_replacement_condition): Likewise.
	(combine_blocks): Likewise.
	(bb_with_exit_edge_p): Likewise.
	* tree-into-ssa.c (compute_global_livein): Likewise.
	(ssa_mark_phi_uses): Likewise.
	(ssa_rewrite_initialize_block): Likewise.
	(rewrite_add_phi_arguments): Likewise.
	(ssa_rewrite_phi_arguments): Likewise.
	(insert_phi_nodes_for): Likewise.
	(rewrite_into_ssa): Likewise.
	(rewrite_ssa_into_ssa): Likewise.
	* tree-mudflap.c (md_build_check_statement_for): Likewise.
	* tree-outof-ssa.c (coalesce_abnormal_edges): Likewise.
	(rewrite_trees): Likewise.
	* tree-pretty-print.c (dump_bb_header): Likewise.
	(dump_bb_end): Likewise.
	(dump_implicit_edges): Likewise.
	* tree-sra.c (insert_edge_copies): Likewise.
	* tree-ssa-dce.c (find_obviously_necessary_stmts): Likewise.
	(remove_dead_stmt): Likewise.
	* tree-ssa-dom.c (thread_across_edge): Likewise.
	(dom_opt_finalize_block): Likewise.
	(single_incoming_edge_ignoring_loops_edges): Likewise.
	(record_equivalences_from_incoming_edge): Likewise.
	(cprop_into_successor_phis): Likewise.
	* tree-ssa-live.c (live_worklist): Likewise.
	(calculate_live_on_entry): Likewise.
	(calculate_live_on_exit): Likewise.
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Likewise.
	(duplicate_blocks): Likewise.
	(copy_loop_headers): Likewise.
	* tree-ssa-loop-im.c (loop_commit_inserts): Likewise.
	(fill_always_executed_in): Likewise.
	* tree-ssa-loop-ivcanon.c (create_canonical_iv): Likewise.
	* tree-ssa-loop-ivopts.c (find_interesting_uses): Likewise.
	(compute_phi_arg_on_exit): Likewise.
	* tree-ssa-loop-manip.c (add_exit_phis_edge): Likewise.
	(get_loops_exit): Likewise.
	(split_loop_exit_edge): Likewise.
	(ip_normal_pos): Likewise.
	* tree-ssa-loop-niter.c (simplify_using_initial_conditions):
	Likewise.
	* tree-ssa-phiopt.c (candidate_bb_for_phi_optimization): Likewise.
	* tree-ssa-pre.c (compute_antic_aux): Likewise.
	(insert_aux): Likewise.
	(init_pre): Likewise.
	* tree-ssa-propagate.c (simulate_stmt): Likewise.
	(simulate_block): Likewise.
	(ssa_prop_init): Likewise.
	* tree-ssa-threadupdate.c (create_block_for_threading): Likewise.
	(remove_last_stmt_and_useless_edges): Likewise.
	(thread_block): Likewise.
	* tree-ssa.c (verify_phi_args): Likewise.
	(verify_ssa): Likewise.
	* tree-tailcall.c (independent_of_stmt_p): Likewise.
	(find_tail_calls): Likewise.
	(eliminate_tail_call): Likewise.
	(tree_optimize_tail_calls_1): Likewise.
	* tree-vectorizer.c (vect_transform_loop): Likewise.
	* var-tracking.c (prologue_stack_adjust): Likewise.
	(vt_stack_adjustments): Likewise.
	(vt_find_locations): Likewise.
	* config/frv/frv.c (frv_ifcvt_modify_tests): Likewise.
	* config/i386/i386.c (ix86_pad_returns): Likewise.
	* config/ia64/ia64.c (ia64_expand_prologue): Likewise.
	* config/rs6000/rs6000.c (rs6000_emit_prologue): Likewise.

Index: gcc/basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.209
diff -u -p -w -r1.209 basic-block.h
--- gcc/basic-block.h	9 Sep 2004 12:20:38 -0000	1.209
+++ gcc/basic-block.h	13 Sep 2004 04:38:49 -0000
@@ -28,6 +28,8 @@ Software Foundation, 59 Temple Place - S
 #include "partition.h"
 #include "hard-reg-set.h"
 #include "predict.h"
+#include "vec.h"
+#include "errors.h"
 
 /* Head of register set linked list.  */
 typedef bitmap_head regset_head;
@@ -123,12 +125,8 @@ do {									\
 typedef HOST_WIDEST_INT gcov_type;
 
 /* Control flow edge information.  */
-struct edge_def GTY((chain_next ("%h.pred_next")))
+struct edge_def GTY(())
 {
-  /* Links through the predecessor and successor lists.  */
-  struct edge_def *pred_next;
-  struct edge_def *succ_next;
-
   /* The two blocks at the ends of the edge.  */
   struct basic_block_def *src;
   struct basic_block_def *dest;
@@ -152,6 +150,13 @@ struct edge_def GTY((chain_next ("%h.pre
 };
 
 typedef struct edge_def *edge;
+DEF_VEC_GC_P(edge);
+
+struct edge_stack
+{
+  VEC(edge) *ev;
+  unsigned ix;
+};
 
 #define EDGE_FALLTHRU		1	/* 'Straight line' flow */
 #define EDGE_ABNORMAL		2	/* Strange flow, like computed
@@ -226,8 +231,8 @@ struct basic_block_def GTY((chain_next (
   tree stmt_list;
 
   /* The edges into and out of the block.  */
-  edge pred;
-  edge succ;
+  VEC(edge) *preds;
+  VEC(edge) *succs;
 
   /* Liveness info.  */
 
@@ -514,12 +519,12 @@ struct edge_list
 #define NUM_EDGES(el)			((el)->num_edges)
 
 /* BB is assumed to contain conditional jump.  Return the fallthru edge.  */
-#define FALLTHRU_EDGE(bb)		((bb)->succ->flags & EDGE_FALLTHRU \
-					 ? (bb)->succ : (bb)->succ->succ_next)
+#define FALLTHRU_EDGE(bb)		(EDGE_SUCC ((bb), 0)->flags & EDGE_FALLTHRU \
+					 ? EDGE_SUCC ((bb), 0) : EDGE_SUCC ((bb), 1))
 
 /* BB is assumed to contain conditional jump.  Return the branch edge.  */
-#define BRANCH_EDGE(bb)			((bb)->succ->flags & EDGE_FALLTHRU \
-					 ? (bb)->succ->succ_next : (bb)->succ)
+#define BRANCH_EDGE(bb)			(EDGE_SUCC ((bb), 0)->flags & EDGE_FALLTHRU \
+					 ? EDGE_SUCC ((bb), 1) : EDGE_SUCC ((bb), 0))
 
 /* Return expected execution frequency of the edge E.  */
 #define EDGE_FREQUENCY(e)		(((e)->src->frequency \
@@ -528,8 +533,49 @@ struct edge_list
 					 / REG_BR_PROB_BASE)
 
 /* Return nonzero if edge is critical.  */
-#define EDGE_CRITICAL_P(e)		((e)->src->succ->succ_next \
-					 && (e)->dest->pred->pred_next)
+#define EDGE_CRITICAL_P(e)		(EDGE_COUNT ((e)->src->succs) >= 2 \
+					 && EDGE_COUNT ((e)->dest->preds) >= 2)
+
+#if defined ENABLE_CHECKING
+#define ENABLE_VEC_CHECKING 1
+#else
+#define ENABLE_VEC_CHECKING 0
+#endif
+
+#define EDGE_COUNT(ev)			VEC_length (edge, (ev))
+#define EDGE_I(ev,i)			VEC_index  (edge, (ev), (i))
+#define EDGE_PRED(bb,i)			VEC_index  (edge, (bb)->preds, (i))
+#define EDGE_SUCC(bb,i)			VEC_index  (edge, (bb)->succs, (i))
+
+#define FOR_EACH_EDGE(EDGE,EDGE_VEC)					\
+do {									\
+  VEC(edge) *__ev = (EDGE_VEC);						\
+  edge __check_edge;							\
+  unsigned int __ix;							\
+  unsigned int  __num_edges = EDGE_COUNT (__ev);			\
+  (EDGE) = NULL;							\
+  for (__ix = 0; VEC_iterate (edge, __ev, __ix, (EDGE)); __ix++)	\
+    {									\
+      if (ENABLE_VEC_CHECKING)						\
+	__check_edge = (EDGE);
+
+#define END_FOR_EACH_EDGE						\
+      if (ENABLE_VEC_CHECKING						\
+	&& (__ix >= EDGE_COUNT (__ev)					\
+	    || EDGE_I (__ev, __ix) != __check_edge))			\
+	internal_error ("edge modified in FOR_EACH_EDGE: %s:%s",	\
+			__FILE__, __FUNCTION__);			\
+    }									\
+  if (ENABLE_VEC_CHECKING						\
+	  && __num_edges > EDGE_COUNT (__ev))				\
+	internal_error ("insufficient edges FOR_EACH_EDGE: %s:%s", 	\
+			__FILE__, __FUNCTION__);			\
+  if (ENABLE_VEC_CHECKING						\
+          && __num_edges < EDGE_COUNT (__ev))				\
+  	internal_error ("excess edges FOR_EACH_EDGE: %s:%s",		\
+			__FILE__, __FUNCTION__);			\
+}									\
+while (0)
 
 struct edge_list * create_edge_list (void);
 void free_edge_list (struct edge_list *);
Index: gcc/bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.83
diff -u -p -w -r1.83 bb-reorder.c
--- gcc/bb-reorder.c	10 Sep 2004 15:09:34 -0000	1.83
+++ gcc/bb-reorder.c	13 Sep 2004 04:38:50 -0000
@@ -243,7 +243,7 @@ find_traces (int *n_traces, struct trace
   heap = fibheap_new ();
   max_entry_frequency = 0;
   max_entry_count = 0;
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
     {
       bbd[e->dest->index].heap = heap;
       bbd[e->dest->index].node = fibheap_insert (heap, bb_to_key (e->dest),
@@ -253,6 +253,7 @@ find_traces (int *n_traces, struct trace
       if (e->dest->count > max_entry_count)
 	max_entry_count = e->dest->count;
     }
+  END_FOR_EACH_EDGE;
 
   /* Find the traces.  */
   for (i = 0; i < number_of_rounds; i++)
@@ -311,7 +312,8 @@ rotate_loop (edge back_edge, struct trac
   do
     {
       edge e;
-      for (e = bb->succ; e; e = e->succ_next)
+
+      FOR_EACH_EDGE (e, bb->succs)
 	if (e->dest != EXIT_BLOCK_PTR
 	    && e->dest->rbi->visited != trace_n
 	    && (e->flags & EDGE_CAN_FALLTHRU)
@@ -359,6 +361,7 @@ rotate_loop (edge back_edge, struct trac
 		}
 	    }
 	}
+      END_FOR_EACH_EDGE;
       bb = bb->rbi->next;
     }
   while (bb != back_edge->dest);
@@ -382,9 +385,9 @@ rotate_loop (edge back_edge, struct trac
 	  prev_bb->rbi->next = best_bb->rbi->next;
 
 	  /* Try to get rid of uncond jump to cond jump.  */
-	  if (prev_bb->succ && !prev_bb->succ->succ_next)
+	  if (EDGE_COUNT (prev_bb->succs) == 1)
 	    {
-	      basic_block header = prev_bb->succ->dest;
+	      basic_block header = EDGE_SUCC (prev_bb, 0)->dest;
 
 	      /* Duplicate HEADER if it is a small block containing cond jump
 		 in the end.  */
@@ -392,7 +395,7 @@ rotate_loop (edge back_edge, struct trac
 		  && !find_reg_note (BB_END (header), REG_CROSSING_JUMP, 
 				     NULL_RTX))
 		{
-		  copy_bb (header, prev_bb->succ, prev_bb, trace_n);
+		  copy_bb (header, EDGE_SUCC (prev_bb, 0), prev_bb, trace_n);
 		}
 	    }
 	}
@@ -498,7 +501,7 @@ find_traces_1_round (int branch_th, int 
 		     bb->index, *n_traces - 1);
 
 	  /* Select the successor that will be placed after BB.  */
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      gcc_assert (!(e->flags & EDGE_FAKE));
 
@@ -533,16 +536,17 @@ find_traces_1_round (int branch_th, int 
 		  best_freq = freq;
 		}
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  /* If the best destination has multiple predecessors, and can be
 	     duplicated cheaper than a jump, don't allow it to be added
 	     to a trace.  We'll duplicate it when connecting traces.  */
-	  if (best_edge && best_edge->dest->pred->pred_next
+	  if (best_edge && EDGE_COUNT (best_edge->dest->preds) >= 2
 	      && copy_bb_p (best_edge->dest, 0))
 	    best_edge = NULL;
 
 	  /* Add all non-selected successors to the heaps.  */
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      if (e == best_edge
 		  || e->dest == EXIT_BLOCK_PTR
@@ -601,9 +605,9 @@ find_traces_1_round (int branch_th, int 
 			       (which_heap == new_heap) ? "next" : "this",
 			       e->dest->index, (long) key);
 		    }
-
 		}
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  if (best_edge) /* Suitable successor was found.  */
 	    {
@@ -637,11 +641,12 @@ find_traces_1_round (int branch_th, int 
 
 			  /* Check whether there is another edge from BB.  */
 			  edge another_edge;
-			  for (another_edge = bb->succ;
-			       another_edge;
-			       another_edge = another_edge->succ_next)
+			  FOR_EACH_EDGE (another_edge, bb->succs)
+			    {
 			    if (another_edge != best_edge)
 			      break;
+			    }
+			  END_FOR_EACH_EDGE;
 
 			  if (!another_edge && copy_bb_p (best_edge->dest,
 							  !optimize_size))
@@ -678,18 +683,18 @@ find_traces_1_round (int branch_th, int 
 
 		  */
 
-		  for (e = bb->succ; e; e = e->succ_next)
+		  FOR_EACH_EDGE (e, bb->succs)
+		    {
 		    if (e != best_edge
 			&& (e->flags & EDGE_CAN_FALLTHRU)
 			&& !(e->flags & EDGE_COMPLEX)
 			&& !e->dest->rbi->visited
-			&& !e->dest->pred->pred_next
+			  && EDGE_COUNT (e->dest->preds) == 1
 			&& !(e->flags & EDGE_CROSSING)
-			&& 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
+			  && EDGE_COUNT (e->dest->succs) == 1
+			  && (EDGE_SUCC (e->dest, 0)->flags & EDGE_CAN_FALLTHRU)
+			  && !(EDGE_SUCC (e->dest, 0)->flags & EDGE_COMPLEX)
+			  && EDGE_SUCC (e->dest, 0)->dest == best_edge->dest
 			&& 2 * e->dest->frequency >= EDGE_FREQUENCY (best_edge))
 		      {
 			best_edge = e;
@@ -698,6 +703,8 @@ find_traces_1_round (int branch_th, int 
 				   best_edge->dest->index);
 			break;
 		      }
+		    }
+		  END_FOR_EACH_EDGE;
 
 		  bb->rbi->next = best_edge->dest;
 		  bb = best_edge->dest;
@@ -712,7 +719,7 @@ find_traces_1_round (int branch_th, int 
       /* The trace is terminated so we have to recount the keys in heap
 	 (some block can have a lower key because now one of its predecessors
 	 is an end of the trace).  */
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (e->dest == EXIT_BLOCK_PTR
 	      || e->dest->rbi->visited)
@@ -736,6 +743,7 @@ find_traces_1_round (int branch_th, int 
 		}
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   fibheap_delete (*heap);
@@ -812,7 +820,7 @@ bb_to_key (basic_block bb)
 
   /* Prefer blocks whose predecessor is an end of some trace
      or whose predecessor edge is EDGE_DFS_BACK.  */
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     {
       if ((e->src != ENTRY_BLOCK_PTR && bbd[e->src->index].end_of_trace >= 0)
 	  || (e->flags & EDGE_DFS_BACK))
@@ -823,6 +831,7 @@ bb_to_key (basic_block bb)
 	    priority = edge_freq;
 	}
     }
+  END_FOR_EACH_EDGE;
 
   if (priority)
     /* The block with priority should have significantly lower key.  */
@@ -971,7 +980,7 @@ connect_traces (int n_traces, struct tra
 	{
 	  best = NULL;
 	  best_len = 0;
-	  for (e = traces[t2].first->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, traces[t2].first->preds)
 	    {
 	      int si = e->src->index;
 
@@ -989,6 +998,8 @@ connect_traces (int n_traces, struct tra
 		  best_len = traces[bbd[si].end_of_trace].length;
 		}
 	    }
+	  END_FOR_EACH_EDGE;
+
 	  if (best)
 	    {
 	      best->src->rbi->next = best->dest;
@@ -1018,7 +1029,7 @@ connect_traces (int n_traces, struct tra
 	  /* Find the continuation of the chain.  */
 	  best = NULL;
 	  best_len = 0;
-	  for (e = traces[t].last->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, traces[t].last->succs)
 	    {
 	      int di = e->dest->index;
 
@@ -1036,6 +1047,7 @@ connect_traces (int n_traces, struct tra
 		  best_len = traces[bbd[di].start_of_trace].length;
 		}
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  if (best)
 	    {
@@ -1058,7 +1070,8 @@ connect_traces (int n_traces, struct tra
 	      basic_block next_bb = NULL;
 	      bool try_copy = false;
 
-	      for (e = traces[t].last->succ; e; e = e->succ_next)
+	      FOR_EACH_EDGE (e, traces[t].last->succs)
+		{
 		if (e->dest != EXIT_BLOCK_PTR
 		    && (e->flags & EDGE_CAN_FALLTHRU)
 		    && !(e->flags & EDGE_COMPLEX)
@@ -1079,7 +1092,7 @@ connect_traces (int n_traces, struct tra
 			continue;
 		      }
 
-		    for (e2 = e->dest->succ; e2; e2 = e2->succ_next)
+		      FOR_EACH_EDGE (e2, e->dest->succs)
 		      {
 			int di = e2->dest->index;
 
@@ -1106,7 +1119,10 @@ connect_traces (int n_traces, struct tra
 			    try_copy = true;
 			  }
 		      }
+		      END_FOR_EACH_EDGE;
 		  }
+		}
+	      END_FOR_EACH_EDGE;
 
 	      if (flag_reorder_blocks_and_partition)
 		try_copy = false;
@@ -1177,24 +1193,17 @@ copy_bb_p (basic_block bb, int code_may_
   int size = 0;
   int max_size = uncond_jump_length;
   rtx insn;
-  int n_succ;
-  edge e;
 
   if (!bb->frequency)
     return false;
-  if (!bb->pred || !bb->pred->pred_next)
+  if (EDGE_COUNT (bb->preds) < 2)
     return false;
   if (!can_duplicate_block_p (bb))
     return false;
 
   /* Avoid duplicating blocks which have many successors (PR/13430).  */
-  n_succ = 0;
-  for (e = bb->succ; e; e = e->succ_next)
-    {
-      n_succ++;
-      if (n_succ > 8)
+  if (EDGE_COUNT (bb->succs) > 8)
 	return false;
-    }
 
   if (code_may_grow && maybe_hot_bb_p (bb))
     max_size *= 8;
@@ -1281,12 +1290,13 @@ find_rarely_executed_basic_blocks_and_cr
      the hot partition (if there is one).  */
   
   if (has_hot_blocks)
-    for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
       if (e->dest->index >= 0)
 	{
 	  BB_SET_PARTITION (e->dest, BB_HOT_PARTITION);
 	  break;
 	}
+    END_FOR_EACH_EDGE;
 
   /* Mark every edge that crosses between sections.  */
 
@@ -1294,7 +1304,7 @@ find_rarely_executed_basic_blocks_and_cr
   if (targetm.have_named_sections)
     {
       FOR_EACH_BB (bb)
-	for (e = bb->succ; e; e = e->succ_next)
+        FOR_EACH_EDGE (e, bb->succs)
 	  {
 	    if (e->src != ENTRY_BLOCK_PTR
 		&& e->dest != EXIT_BLOCK_PTR
@@ -1312,6 +1322,7 @@ find_rarely_executed_basic_blocks_and_cr
 	    else
 	      e->flags &= ~EDGE_CROSSING;
 	  }
+      END_FOR_EACH_EDGE;
     }
   *n_crossing_edges = i;
 }
@@ -1383,8 +1394,8 @@ add_labels_and_missing_jumps (edge *cros
 		  if (!JUMP_P (BB_END (src)))
  		    /* bb just falls through.  */
  		    {
- 		      /* make sure there's only one successor */
-		      gcc_assert (src->succ && !src->succ->succ_next);
+ 		      /* Make sure there's only one successor.  */
+		      gcc_assert (EDGE_COUNT (src->succs) == 1);
 		      
 		      /* Find label in dest block.  */
 		      label = block_label (dest);
@@ -1432,9 +1443,13 @@ fix_up_fall_thru_edges (void)
   FOR_EACH_BB (cur_bb)
     {
       fall_thru = NULL;
-      succ1 = cur_bb->succ;
-      if (succ1)
-  	succ2 = succ1->succ_next;
+      if (EDGE_COUNT (cur_bb->succs) > 0)
+	succ1 = EDGE_SUCC (cur_bb, 0);
+      else
+	succ1 = NULL;
+
+      if (EDGE_COUNT (cur_bb->succs) > 1)
+  	succ2 = EDGE_SUCC (cur_bb, 1);
       else
   	succ2 = NULL;
       
@@ -1522,7 +1537,7 @@ fix_up_fall_thru_edges (void)
 			 partition as bb it's falling through from.  */
 
 		      BB_COPY_PARTITION (new_bb, cur_bb);
-		      new_bb->succ->flags |= EDGE_CROSSING;
+		      EDGE_SUCC (new_bb, 0)->flags |= EDGE_CROSSING;
  		    }
 		  
  		  /* Add barrier after new jump */
@@ -1558,7 +1573,7 @@ find_jump_block (basic_block jump_dest) 
   edge e;
   rtx insn;
 
-  for (e = jump_dest->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, jump_dest->preds)
     if (e->flags & EDGE_CROSSING)
       {
 	basic_block src = e->src;
@@ -1585,7 +1600,7 @@ find_jump_block (basic_block jump_dest) 
 	if (source_bb)
 	  break;
       }
-
+  END_FOR_EACH_EDGE;
   return source_bb;
 }
 
@@ -1619,9 +1634,13 @@ fix_crossing_conditional_branches (void)
   FOR_EACH_BB (cur_bb)
     {
       crossing_edge = NULL;
-      succ1 = cur_bb->succ;
-      if (succ1)
- 	succ2 = succ1->succ_next;
+      if (EDGE_COUNT (cur_bb->succs) > 0)
+	succ1 = EDGE_SUCC (cur_bb, 0);
+      else
+	succ1 = NULL;
+    
+      if (EDGE_COUNT (cur_bb->succs) > 1)
+	succ2 = EDGE_SUCC (cur_bb, 1);
       else
  	succ2 = NULL;
       
@@ -1738,10 +1757,10 @@ fix_crossing_conditional_branches (void)
 		 will be a successor for new_bb and a predecessor
 		 for 'dest'.  */
 	      
-	      if (!new_bb->succ)
+	      if (EDGE_COUNT (new_bb->succs) == 0)
 		new_edge = make_edge (new_bb, dest, 0);
 	      else
-		new_edge = new_bb->succ;
+		new_edge = EDGE_SUCC (new_bb, 0);
 	      
 	      crossing_edge->flags &= ~EDGE_CROSSING;
 	      new_edge->flags |= EDGE_CROSSING;
@@ -1769,7 +1788,7 @@ fix_crossing_unconditional_branches (voi
   FOR_EACH_BB (cur_bb)
     {
       last_insn = BB_END (cur_bb);
-      succ = cur_bb->succ;
+      succ = EDGE_SUCC (cur_bb, 0);
 
       /* Check to see if bb ends in a crossing (unconditional) jump.  At
          this point, no crossing jumps should be conditional.  */
@@ -1841,7 +1860,8 @@ add_reg_crossing_jump_notes (void)
   edge e;
 
   FOR_EACH_BB (bb)
-    for (e = bb->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, bb->succs)
+      {
       if ((e->flags & EDGE_CROSSING)
 	  && JUMP_P (BB_END (e->src)))
 	REG_NOTES (BB_END (e->src)) = gen_rtx_EXPR_LIST (REG_CROSSING_JUMP, 
@@ -1849,6 +1869,8 @@ add_reg_crossing_jump_notes (void)
 						         REG_NOTES (BB_END 
 								  (e->src)));
 }
+    END_FOR_EACH_EDGE;
+}
 
 /* Basic blocks containing NOTE_INSN_UNLIKELY_EXECUTED_CODE will be
    put in a separate section of the .o file, to reduce paging and
Index: gcc/bt-load.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bt-load.c,v
retrieving revision 2.24
diff -u -p -w -r2.24 bt-load.c
--- gcc/bt-load.c	30 Aug 2004 19:13:03 -0000	2.24
+++ gcc/bt-load.c	13 Sep 2004 04:38:50 -0000
@@ -899,9 +899,13 @@ augment_live_range (bitmap live_range, H
 	  dump_hard_reg_set (*btrs_live_in_range);
 	  fprintf (dump_file, "\n");
 	}
-      for (e = head_bb->pred; e; e = e->pred_next)
+
+      FOR_EACH_EDGE (e, head_bb->preds)
+	{
 	*tos++ = e->src;
     }
+      END_FOR_EACH_EDGE;
+    }
 
   while (tos != worklist)
     {
@@ -922,12 +926,13 @@ augment_live_range (bitmap live_range, H
 	      fprintf (dump_file, "\n");
 	    }
 
-	  for (e = bb->pred; e != NULL; e = e->pred_next)
+	  FOR_EACH_EDGE (e, bb->preds)
 	    {
 	      basic_block pred = e->src;
 	      if (!bitmap_bit_p (live_range, pred->index))
 		*tos++ = pred;
 	    }
+	  END_FOR_EACH_EDGE;
 	}
     }
 
Index: gcc/cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfg.c,v
retrieving revision 1.65
diff -u -p -w -r1.65 cfg.c
--- gcc/cfg.c	7 Sep 2004 15:46:46 -0000	1.65
+++ gcc/cfg.c	13 Sep 2004 04:38:50 -0000
@@ -147,31 +147,18 @@ clear_edges (void)
 
   FOR_EACH_BB (bb)
     {
-      edge e = bb->succ;
-
-      while (e)
-	{
-	  edge next = e->succ_next;
-
+      FOR_EACH_EDGE (e, bb->succs)
 	  free_edge (e);
-	  e = next;
+      END_FOR_EACH_EDGE;
+      VEC_truncate (edge, bb->succs, 0);
+      VEC_truncate (edge, bb->preds, 0);
 	}
 
-      bb->succ = NULL;
-      bb->pred = NULL;
-    }
-
-  e = ENTRY_BLOCK_PTR->succ;
-  while (e)
-    {
-      edge next = e->succ_next;
-
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
       free_edge (e);
-      e = next;
-    }
-
-  EXIT_BLOCK_PTR->pred = NULL;
-  ENTRY_BLOCK_PTR->succ = NULL;
+  END_FOR_EACH_EDGE;
+  VEC_truncate (edge, EXIT_BLOCK_PTR->preds, 0);
+  VEC_truncate (edge, ENTRY_BLOCK_PTR->succs, 0);
 
   gcc_assert (!n_edges);
 }
@@ -280,15 +267,13 @@ unchecked_make_edge (basic_block src, ba
   e = ggc_alloc_cleared (sizeof (*e));
   n_edges++;
 
-  e->succ_next = src->succ;
-  e->pred_next = dst->pred;
+  VEC_safe_push (edge, src->succs, e);
+  VEC_safe_push (edge, dst->preds, e);
+
   e->src = src;
   e->dest = dst;
   e->flags = flags;
 
-  src->succ = e;
-  dst->pred = e;
-
   return e;
 }
 
@@ -320,12 +305,15 @@ cached_make_edge (sbitmap *edge_cache, b
 
       /* Fall through.  */
     case 0:
-      for (e = src->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, src->succs)
+	{
 	if (e->dest == dst)
 	  {
 	    e->flags |= flags;
 	    return NULL;
 	  }
+	}
+      END_FOR_EACH_EDGE;
       break;
     }
 
@@ -364,30 +352,45 @@ make_single_succ_edge (basic_block src, 
 void
 remove_edge (edge e)
 {
-  edge last_pred = NULL;
-  edge last_succ = NULL;
   edge tmp;
   basic_block src, dest;
+  bool found = false;
+  unsigned ix;
 
   src = e->src;
   dest = e->dest;
-  for (tmp = src->succ; tmp && tmp != e; tmp = tmp->succ_next)
-    last_succ = tmp;
 
-  gcc_assert (tmp);
-  if (last_succ)
-    last_succ->succ_next = e->succ_next;
+  for (ix = 0; VEC_iterate (edge, src->succs, ix, tmp); )
+    {
+      if (tmp == e)
+	{
+	  VEC_unordered_remove (edge, src->succs, ix);
+	  found = true;
+	  break;
+	}
   else
-    src->succ = e->succ_next;
+	ix++;
+    }
+
+  gcc_assert (found);
 
-  for (tmp = dest->pred; tmp && tmp != e; tmp = tmp->pred_next)
-    last_pred = tmp;
+  if (!found)
+    abort ();
 
-  gcc_assert (tmp);
-  if (last_pred)
-    last_pred->pred_next = e->pred_next;
+  found = false;
+  for (ix = 0; VEC_iterate (edge, dest->preds, ix, tmp); )
+    {
+      if (tmp == e)
+	{
+	  VEC_unordered_remove (edge, dest->preds, ix);
+	  found = true;
+	  break;
+	}
   else
-    dest->pred = e->pred_next;
+	ix++;
+    }
+
+  gcc_assert (found);
 
   free_edge (e);
 }
@@ -397,16 +400,28 @@ remove_edge (edge e)
 void
 redirect_edge_succ (edge e, basic_block new_succ)
 {
-  edge *pe;
+  edge tmp;
+  unsigned ix;
+  bool found = false;
 
   /* Disconnect the edge from the old successor block.  */
-  for (pe = &e->dest->pred; *pe != e; pe = &(*pe)->pred_next)
-    continue;
-  *pe = (*pe)->pred_next;
+  for (ix = 0; VEC_iterate (edge, e->dest->preds, ix, tmp); )
+    {
+      if (tmp == e)
+	{
+	  VEC_unordered_remove (edge, e->dest->preds, ix);
+	  found = true;
+	  break;
+	}
+      else
+	ix++;
+    }
+
+  if (!found)
+    abort ();
 
   /* Reconnect the edge to the new successor block.  */
-  e->pred_next = new_succ->pred;
-  new_succ->pred = e;
+  VEC_safe_push (edge, new_succ->preds, e);
   e->dest = new_succ;
 }
 
@@ -418,9 +433,12 @@ redirect_edge_succ_nodup (edge e, basic_
   edge s;
 
   /* Check whether the edge is already present.  */
-  for (s = e->src->succ; s; s = s->succ_next)
+  FOR_EACH_EDGE (s, e->src->succs)
+    {
     if (s->dest == new_succ && s != e)
       break;
+    }
+  END_FOR_EACH_EDGE;
 
   if (s)
     {
@@ -443,17 +461,28 @@ redirect_edge_succ_nodup (edge e, basic_
 void
 redirect_edge_pred (edge e, basic_block new_pred)
 {
-  edge *pe;
+  edge tmp;
+  bool found = false;
+  unsigned ix;
 
   /* Disconnect the edge from the old predecessor block.  */
-  for (pe = &e->src->succ; *pe != e; pe = &(*pe)->succ_next)
-    continue;
+  for (ix = 0; VEC_iterate (edge, e->src->succs, ix, tmp); )
+    {
+      if (tmp == e)
+	{
+	  VEC_unordered_remove (edge, e->src->succs, ix);
+	  found = true;
+	  break;
+	}
+      else
+	ix++;
+    }
 
-  *pe = (*pe)->succ_next;
+  if (!found)
+    abort ();
 
   /* Reconnect the edge to the new predecessor block.  */
-  e->succ_next = new_pred->succ;
-  new_pred->succ = e;
+  VEC_safe_push (edge, new_pred->succs, e);
   e->src = new_pred;
 }
 
@@ -484,30 +513,35 @@ check_bb_profile (basic_block bb, FILE *
 
   if (bb != EXIT_BLOCK_PTR)
     {
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	sum += e->probability;
-      if (bb->succ && abs (sum - REG_BR_PROB_BASE) > 100)
+      END_FOR_EACH_EDGE;
+      if (EDGE_COUNT (bb->succs) && abs (sum - REG_BR_PROB_BASE) > 100)
 	fprintf (file, "Invalid sum of outgoing probabilities %.1f%%\n",
 		 sum * 100.0 / REG_BR_PROB_BASE);
       lsum = 0;
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	lsum += e->count;
-      if (bb->succ && (lsum - bb->count > 100 || lsum - bb->count < -100))
+      END_FOR_EACH_EDGE;
+      if (EDGE_COUNT (bb->succs)
+	  && (lsum - bb->count > 100 || lsum - bb->count < -100))
 	fprintf (file, "Invalid sum of outgoing counts %i, should be %i\n",
 		 (int) lsum, (int) bb->count);
     }
   if (bb != ENTRY_BLOCK_PTR)
     {
       sum = 0;
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	sum += EDGE_FREQUENCY (e);
+      END_FOR_EACH_EDGE;
       if (abs (sum - bb->frequency) > 100)
 	fprintf (file,
 		 "Invalid sum of incoming frequencies %i, should be %i\n",
 		 sum, bb->frequency);
       lsum = 0;
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	lsum += e->count;
+      END_FOR_EACH_EDGE;
       if (lsum - bb->count > 100 || lsum - bb->count < -100)
 	fprintf (file, "Invalid sum of incoming counts %i, should be %i\n",
 		 (int) lsum, (int) bb->count);
@@ -587,12 +621,14 @@ dump_flow_info (FILE *file)
       fprintf (file, ".\n");
 
       fprintf (file, "Predecessors: ");
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	dump_edge_info (file, e, 0);
+      END_FOR_EACH_EDGE;
 
       fprintf (file, "\nSuccessors: ");
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	dump_edge_info (file, e, 1);
+      END_FOR_EACH_EDGE;
 
       fprintf (file, "\nRegisters live at start:");
       dump_regset (bb->global_live_at_start, file);
@@ -785,8 +821,9 @@ alloc_aux_for_edges (int size)
 	{
 	  edge e;
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    alloc_aux_for_edge (e, size);
+	  END_FOR_EACH_EDGE;
 	}
     }
 }
@@ -801,8 +838,9 @@ clear_aux_for_edges (void)
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	e->aux = NULL;
+      END_FOR_EACH_EDGE;
     }
 }
 
@@ -863,12 +901,14 @@ dump_cfg_bb_info (FILE *file, basic_bloc
   fprintf (file, "\n");
 
   fprintf (file, "Predecessors: ");
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     dump_edge_info (file, e, 0);
+  END_FOR_EACH_EDGE;
 
   fprintf (file, "\nSuccessors: ");
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     dump_edge_info (file, e, 1);
+  END_FOR_EACH_EDGE;
   fprintf (file, "\n\n");
 }
 
Index: gcc/cfganal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfganal.c,v
retrieving revision 1.48
diff -u -p -w -r1.48 cfganal.c
--- gcc/cfganal.c	7 Sep 2004 15:46:45 -0000	1.48
+++ gcc/cfganal.c	13 Sep 2004 04:38:51 -0000
@@ -85,7 +85,7 @@ forwarder_block_p (basic_block bb)
   rtx insn;
 
   if (bb == EXIT_BLOCK_PTR || bb == ENTRY_BLOCK_PTR
-      || !bb->succ || bb->succ->succ_next)
+      || EDGE_COUNT (bb->succs) != 1)
     return false;
 
   for (insn = BB_HEAD (bb); insn != BB_END (bb); insn = NEXT_INSN (insn))
@@ -110,10 +110,12 @@ can_fallthru (basic_block src, basic_blo
     return true;
   if (src->next_bb != target)
     return 0;
-  for (e = src->succ; e; e = e->succ_next)
-    if (e->dest == EXIT_BLOCK_PTR
-	&& e->flags & EDGE_FALLTHRU)
+  FOR_EACH_EDGE (e, src->succs)
+    {
+      if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
     return 0;
+    }
+  END_FOR_EACH_EDGE;
 
   insn2 = BB_HEAD (target);
   if (insn2 && !active_insn_p (insn2))
@@ -133,10 +135,12 @@ could_fall_through (basic_block src, bas
 
   if (target == EXIT_BLOCK_PTR)
     return true;
-  for (e = src->succ; e; e = e->succ_next)
-    if (e->dest == EXIT_BLOCK_PTR
-	&& e->flags & EDGE_FALLTHRU)
+  FOR_EACH_EDGE (e, src->succs)
+    {
+      if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
     return 0;
+    }
+  END_FOR_EACH_EDGE;
   return true;
 }
 
@@ -153,7 +157,7 @@ could_fall_through (basic_block src, bas
 bool
 mark_dfs_back_edges (void)
 {
-  edge *stack;
+  struct edge_stack *stack;
   int *pre;
   int *post;
   int sp;
@@ -167,7 +171,7 @@ mark_dfs_back_edges (void)
   post = xcalloc (last_basic_block, sizeof (int));
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
+  stack = xmalloc ((n_basic_blocks + 1) * sizeof (struct edge_stack));
   sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
@@ -177,19 +181,22 @@ mark_dfs_back_edges (void)
   sbitmap_zero (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ENTRY_BLOCK_PTR->succ;
+  stack[sp].ev = ENTRY_BLOCK_PTR->succs;
+  stack[sp++].ix = 0;
 
   while (sp)
     {
-      edge e;
+      VEC(edge) *ev;
       basic_block src;
       basic_block dest;
+      unsigned ix;
 
       /* Look at the edge on the top of the stack.  */
-      e = stack[sp - 1];
-      src = e->src;
-      dest = e->dest;
-      e->flags &= ~EDGE_DFS_BACK;
+      ev = stack[sp - 1].ev;
+      ix = stack[sp - 1].ix;
+      src = EDGE_I (ev, ix)->src;
+      dest = EDGE_I (ev, ix)->dest;
+      EDGE_I (ev, ix)->flags &= ~EDGE_DFS_BACK;
 
       /* Check if the edge destination has been visited yet.  */
       if (dest != EXIT_BLOCK_PTR && ! TEST_BIT (visited, dest->index))
@@ -198,11 +205,12 @@ mark_dfs_back_edges (void)
 	  SET_BIT (visited, dest->index);
 
 	  pre[dest->index] = prenum++;
-	  if (dest->succ)
+	  if (EDGE_COUNT (dest->succs) > 0)
 	    {
 	      /* Since the DEST node has been visited for the first
 		 time, check its successors.  */
-	      stack[sp++] = dest->succ;
+	      stack[sp].ev = dest->succs;
+	      stack[sp++].ix = 0;
 	    }
 	  else
 	    post[dest->index] = postnum++;
@@ -212,13 +220,13 @@ mark_dfs_back_edges (void)
 	  if (dest != EXIT_BLOCK_PTR && src != ENTRY_BLOCK_PTR
 	      && pre[src->index] >= pre[dest->index]
 	      && post[dest->index] == 0)
-	    e->flags |= EDGE_DFS_BACK, found = true;
+	    EDGE_I (ev, ix)->flags |= EDGE_DFS_BACK, found = true;
 
-	  if (! e->succ_next && src != ENTRY_BLOCK_PTR)
+	  if (EDGE_COUNT (ev) <= (ix + 1) && src != ENTRY_BLOCK_PTR)
 	    post[src->index] = postnum++;
 
-	  if (e->succ_next)
-	    stack[sp - 1] = e->succ_next;
+	  if (EDGE_COUNT (ev) > (ix + 1))
+	    stack[sp - 1].ix++;
 	  else
 	    sp--;
 	}
@@ -243,7 +251,7 @@ set_edge_can_fallthru_flag (void)
     {
       edge e;
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  e->flags &= ~EDGE_CAN_FALLTHRU;
 
@@ -251,18 +259,19 @@ set_edge_can_fallthru_flag (void)
 	  if (e->flags & EDGE_FALLTHRU)
 	    e->flags |= EDGE_CAN_FALLTHRU;
 	}
+      END_FOR_EACH_EDGE;
 
       /* If the BB ends with an invertible condjump all (2) edges are
 	 CAN_FALLTHRU edges.  */
-      if (!bb->succ || !bb->succ->succ_next || bb->succ->succ_next->succ_next)
+      if (EDGE_COUNT (bb->succs) != 2)
 	continue;
       if (!any_condjump_p (BB_END (bb)))
 	continue;
       if (!invert_jump (BB_END (bb), JUMP_LABEL (BB_END (bb)), 0))
 	continue;
       invert_jump (BB_END (bb), JUMP_LABEL (BB_END (bb)), 0);
-      bb->succ->flags |= EDGE_CAN_FALLTHRU;
-      bb->succ->succ_next->flags |= EDGE_CAN_FALLTHRU;
+      EDGE_SUCC (bb, 0)->flags |= EDGE_CAN_FALLTHRU;
+      EDGE_SUCC (bb, 1)->flags |= EDGE_CAN_FALLTHRU;
     }
 }
 
@@ -287,13 +296,14 @@ find_unreachable_blocks (void)
      be only one.  It isn't inconceivable that we might one day directly
      support Fortran alternate entry points.  */
 
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
     {
       *tos++ = e->dest;
 
       /* Mark the block reachable.  */
       e->dest->flags |= BB_REACHABLE;
     }
+  END_FOR_EACH_EDGE;
 
   /* Iterate: find everything reachable from what we've already seen.  */
 
@@ -301,13 +311,16 @@ find_unreachable_blocks (void)
     {
       basic_block b = *--tos;
 
-      for (e = b->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, b->succs)
+	{
 	if (!(e->dest->flags & BB_REACHABLE))
 	  {
 	    *tos++ = e->dest;
 	    e->dest->flags |= BB_REACHABLE;
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 
   free (worklist);
 }
@@ -342,8 +355,7 @@ create_edge_list (void)
      edges on each basic block.  */
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
-      for (e = bb->succ; e; e = e->succ_next)
-	num_edges++;
+      num_edges += EDGE_COUNT (bb->succs);
     }
 
   elist = xmalloc (sizeof (struct edge_list));
@@ -355,9 +367,13 @@ create_edge_list (void)
 
   /* Follow successors of blocks, and register these edges.  */
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
-    for (e = bb->succ; e; e = e->succ_next)
+    {
+      FOR_EACH_EDGE (e, bb->succs)
+	{
       elist->index_to_edge[num_edges++] = e;
-
+	}
+      END_FOR_EACH_EDGE;
+    }
   return elist;
 }
 
@@ -411,7 +427,7 @@ verify_edge_list (FILE *f, struct edge_l
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  pred = e->src->index;
 	  succ = e->dest->index;
@@ -429,6 +445,7 @@ verify_edge_list (FILE *f, struct edge_l
 	    fprintf (f, "*p* Succ for index %d should be %d not %d\n",
 		     index, succ, INDEX_EDGE_SUCC_BB (elist, index)->index);
 	}
+      END_FOR_EACH_EDGE;
     }
 
   /* We've verified that all the edges are in the list, now lets make sure
@@ -439,19 +456,25 @@ verify_edge_list (FILE *f, struct edge_l
       {
 	int found_edge = 0;
 
-	for (e = p->succ; e; e = e->succ_next)
+	FOR_EACH_EDGE (e, p->succs)
+	  {
 	  if (e->dest == s)
 	    {
 	      found_edge = 1;
 	      break;
 	    }
+	  }
+	END_FOR_EACH_EDGE;
 
-	for (e = s->pred; e; e = e->pred_next)
+	FOR_EACH_EDGE (e, s->preds)
+	  {
 	  if (e->src == p)
 	    {
 	      found_edge = 1;
 	      break;
 	    }
+	  }
+	END_FOR_EACH_EDGE;
 
 	if (EDGE_INDEX (elist, p, s)
 	    == EDGE_INDEX_NO_EDGE && found_edge != 0)
@@ -472,9 +495,12 @@ find_edge (basic_block pred, basic_block
 {
   edge e;
 
-  for (e = pred->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, pred->succs)
+    {
     if (e->dest == succ)
       return e;
+    }
+  END_FOR_EACH_EDGE;
 
   return NULL;
 }
@@ -537,14 +563,14 @@ static void
 remove_fake_predecessors (basic_block bb)
 {
   edge e;
+  unsigned ix;
 
-  for (e = bb->pred; e;)
+  for (ix = 0; VEC_iterate (edge, bb->preds, ix, e); )
     {
-      edge tmp = e;
-
-      e = e->pred_next;
-      if ((tmp->flags & EDGE_FAKE) == EDGE_FAKE)
-	remove_edge (tmp);
+      if ((e->flags & EDGE_FAKE) == EDGE_FAKE)
+	remove_edge (e);
+      else
+	ix++;
     }
 }
 
@@ -580,7 +606,7 @@ add_noreturn_fake_exit_edges (void)
   basic_block bb;
 
   FOR_EACH_BB (bb)
-    if (bb->succ == NULL)
+    if (EDGE_COUNT (bb->succs) == 0)
       make_single_succ_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
 }
 
@@ -626,13 +652,13 @@ connect_infinite_loops_to_exit (void)
 void
 flow_reverse_top_sort_order_compute (int *rts_order)
 {
-  edge *stack;
+  struct edge_stack *stack;
   int sp;
   int postnum = 0;
   sbitmap visited;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
+  stack = xmalloc ((n_basic_blocks + 1) * sizeof (struct edge_stack));
   sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
@@ -642,18 +668,21 @@ flow_reverse_top_sort_order_compute (int
   sbitmap_zero (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ENTRY_BLOCK_PTR->succ;
+  stack[sp].ev = ENTRY_BLOCK_PTR->succs;
+  stack[sp++].ix = 0;
 
   while (sp)
     {
-      edge e;
+      VEC(edge) *ev;
+      unsigned ix;
       basic_block src;
       basic_block dest;
 
       /* Look at the edge on the top of the stack.  */
-      e = stack[sp - 1];
-      src = e->src;
-      dest = e->dest;
+      ev = stack[sp - 1].ev;
+      ix = stack[sp - 1].ix;
+      src = EDGE_I (ev, ix)->src;
+      dest = EDGE_I (ev, ix)->dest;
 
       /* Check if the edge destination has been visited yet.  */
       if (dest != EXIT_BLOCK_PTR && ! TEST_BIT (visited, dest->index))
@@ -661,20 +690,23 @@ flow_reverse_top_sort_order_compute (int
 	  /* Mark that we have visited the destination.  */
 	  SET_BIT (visited, dest->index);
 
-	  if (dest->succ)
+	  if (EDGE_COUNT (dest->succs) > 0)
+	    {
 	    /* Since the DEST node has been visited for the first
 	       time, check its successors.  */
-	    stack[sp++] = dest->succ;
+	      stack[sp].ev = dest->succs;
+	      stack[sp++].ix = 0;
+	    }
 	  else
 	    rts_order[postnum++] = dest->index;
 	}
       else
 	{
-	  if (! e->succ_next && src != ENTRY_BLOCK_PTR)
+	  if (EDGE_COUNT (ev) <= (ix + 1) && src != ENTRY_BLOCK_PTR)
 	   rts_order[postnum++] = src->index;
 
-	  if (e->succ_next)
-	    stack[sp - 1] = e->succ_next;
+	  if (EDGE_COUNT (ev) > (ix + 1))
+	    stack[sp - 1].ix++;
 	  else
 	    sp--;
 	}
@@ -694,14 +726,14 @@ flow_reverse_top_sort_order_compute (int
 int
 flow_depth_first_order_compute (int *dfs_order, int *rc_order)
 {
-  edge *stack;
+  struct edge_stack *stack;
   int sp;
   int dfsnum = 0;
   int rcnum = n_basic_blocks - 1;
   sbitmap visited;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
+  stack = xmalloc ((n_basic_blocks + 1) * sizeof (struct edge_stack));
   sp = 0;
 
   /* Allocate bitmap to track nodes that have been visited.  */
@@ -711,18 +743,21 @@ flow_depth_first_order_compute (int *dfs
   sbitmap_zero (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ENTRY_BLOCK_PTR->succ;
+  stack[sp].ev = ENTRY_BLOCK_PTR->succs;
+  stack[sp++].ix = 0;
 
   while (sp)
     {
-      edge e;
+      VEC(edge) *ev;
+      unsigned ix;
       basic_block src;
       basic_block dest;
 
       /* Look at the edge on the top of the stack.  */
-      e = stack[sp - 1];
-      src = e->src;
-      dest = e->dest;
+      ev = stack[sp - 1].ev;
+      ix = stack[sp - 1].ix;
+      src = EDGE_I (ev, ix)->src;
+      dest = EDGE_I (ev, ix)->dest;
 
       /* Check if the edge destination has been visited yet.  */
       if (dest != EXIT_BLOCK_PTR && ! TEST_BIT (visited, dest->index))
@@ -735,10 +770,13 @@ flow_depth_first_order_compute (int *dfs
 
 	  dfsnum++;
 
-	  if (dest->succ)
+	  if (EDGE_COUNT (dest->succs) > 0)
+	    {
 	    /* Since the DEST node has been visited for the first
 	       time, check its successors.  */
-	    stack[sp++] = dest->succ;
+	      stack[sp].ev = dest->succs;
+	      stack[sp++].ix = 0;
+	    }
 	  else if (rc_order)
 	    /* There are no successors for the DEST node so assign
 	       its reverse completion number.  */
@@ -746,14 +784,13 @@ flow_depth_first_order_compute (int *dfs
 	}
       else
 	{
-	  if (! e->succ_next && src != ENTRY_BLOCK_PTR
-	      && rc_order)
+	  if (EDGE_COUNT (ev) <= (ix + 1) && src != ENTRY_BLOCK_PTR && rc_order)
 	    /* There are no more successors for the SRC node
 	       so assign its reverse completion number.  */
 	    rc_order[rcnum--] = src->index;
 
-	  if (e->succ_next)
-	    stack[sp - 1] = e->succ_next;
+	  if (EDGE_COUNT (ev) > (ix + 1))
+	    stack[sp - 1].ix++;
 	  else
 	    sp--;
 	}
@@ -789,8 +826,8 @@ struct dfst_node
 void
 flow_preorder_transversal_compute (int *pot_order)
 {
-  edge e;
-  edge *stack;
+  VEC(edge) *ev;
+  struct edge_stack *stack;
   int i;
   int max_successors;
   int sp;
@@ -798,6 +835,7 @@ flow_preorder_transversal_compute (int *
   struct dfst_node *node;
   struct dfst_node *dfst;
   basic_block bb;
+  unsigned ix;
 
   /* Allocate stack for back-tracking up CFG.  */
   stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
@@ -808,10 +846,7 @@ flow_preorder_transversal_compute (int *
 
   FOR_EACH_BB (bb)
     {
-      max_successors = 0;
-      for (e = bb->succ; e; e = e->succ_next)
-	max_successors++;
-
+      max_successors = EDGE_COUNT (bb->succs);
       dfst[bb->index].node
 	= (max_successors
 	   ? xcalloc (max_successors, sizeof (struct dfst_node *)) : NULL);
@@ -824,7 +859,8 @@ flow_preorder_transversal_compute (int *
   sbitmap_zero (visited);
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ENTRY_BLOCK_PTR->succ;
+  stack[sp].ev = ENTRY_BLOCK_PTR->succs;
+  stack[sp++].ix = 0;
 
   while (sp)
     {
@@ -832,9 +868,10 @@ flow_preorder_transversal_compute (int *
       basic_block dest;
 
       /* Look at the edge on the top of the stack.  */
-      e = stack[sp - 1];
-      src = e->src;
-      dest = e->dest;
+      ev = stack[sp - 1].ev;
+      ix = stack[sp - 1].ix;
+      src = EDGE_I (ev, ix)->src;
+      dest = EDGE_I (ev, ix)->dest;
 
       /* Check if the edge destination has been visited yet.  */
       if (dest != EXIT_BLOCK_PTR && ! TEST_BIT (visited, dest->index))
@@ -850,14 +887,17 @@ flow_preorder_transversal_compute (int *
 	      dfst[dest->index].up = &dfst[src->index];
 	    }
 
-	  if (dest->succ)
+	  if (EDGE_COUNT (dest->succs) > 0)
+	    {
 	    /* Since the DEST node has been visited for the first
 	       time, check its successors.  */
-	    stack[sp++] = dest->succ;
+	      stack[sp].ev = dest->succs;
+	      stack[sp++].ix = 0;
+	    }
 	}
 
-      else if (e->succ_next)
-	stack[sp - 1] = e->succ_next;
+      else if (EDGE_COUNT (ev) > (ix + 1))
+	stack[sp - 1].ix++;
       else
 	sp--;
     }
@@ -966,11 +1006,14 @@ flow_dfs_compute_reverse_execute (depth_
       bb = data->stack[--data->sp];
 
       /* Perform depth-first search on adjacent vertices.  */
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (!TEST_BIT (data->visited_blocks,
 		       e->src->index - (INVALID_BLOCK + 1)))
 	  flow_dfs_compute_reverse_add_bb (data, e->src);
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Determine if there are unvisited basic blocks.  */
   FOR_BB_BETWEEN (bb, EXIT_BLOCK_PTR, NULL, prev_bb)
@@ -1010,7 +1053,8 @@ dfs_enumerate_from (basic_block bb, int 
       lbb = st[--sp];
       if (reverse)
         {
-          for (e = lbb->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, lbb->preds)
+	    {
 	    if (!(e->src->flags & BB_VISITED) && predicate (e->src, data))
 	      {
 	        gcc_assert (tv != rslt_max);
@@ -1018,9 +1062,12 @@ dfs_enumerate_from (basic_block bb, int 
 	        e->src->flags |= BB_VISITED;
 	      }
         }
+	  END_FOR_EACH_EDGE;
+        }
       else
         {
-          for (e = lbb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, lbb->succs)
+	    {
 	    if (!(e->dest->flags & BB_VISITED) && predicate (e->dest, data))
 	      {
 	        gcc_assert (tv != rslt_max);
@@ -1028,6 +1075,8 @@ dfs_enumerate_from (basic_block bb, int 
 	        e->dest->flags |= BB_VISITED;
 	      }
 	}
+	  END_FOR_EACH_EDGE;
+	}
     }
   free (st);
   for (sp = 0; sp < tv; sp++)
@@ -1072,13 +1121,14 @@ compute_dominance_frontiers_1 (bitmap *f
     }
       
   /* Find blocks conforming to rule (1) above.  */
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       if (e->dest == EXIT_BLOCK_PTR)
 	continue;
       if (get_immediate_dominator (CDI_DOMINATORS, e->dest) != bb)
 	bitmap_set_bit (frontiers[bb->index], e->dest->index);
     }
+  END_FOR_EACH_EDGE;
 
   /* Find blocks conforming to rule (2).  */
   for (c = first_dom_son (CDI_DOMINATORS, bb);
@@ -1100,15 +1150,10 @@ void
 compute_dominance_frontiers (bitmap *frontiers)
 {
   sbitmap done = sbitmap_alloc (last_basic_block);
-
   timevar_push (TV_DOM_FRONTIERS);
-
   sbitmap_zero (done);
-
-  compute_dominance_frontiers_1 (frontiers, ENTRY_BLOCK_PTR->succ->dest, done);
-
+  compute_dominance_frontiers_1 (frontiers, EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest, done);
   sbitmap_free (done);
-
   timevar_pop (TV_DOM_FRONTIERS);
 }
 
Index: gcc/cfgbuild.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgbuild.c,v
retrieving revision 1.54
diff -u -p -w -r1.54 cfgbuild.c
--- gcc/cfgbuild.c	9 Sep 2004 12:20:40 -0000	1.54
+++ gcc/cfgbuild.c	13 Sep 2004 04:38:51 -0000
@@ -252,10 +252,13 @@ make_edges (basic_block min, basic_block
 	  {
 	    edge e;
 
-	    for (e = bb->succ; e ; e = e->succ_next)
+	    FOR_EACH_EDGE (e, bb->succs)
+	      {
 	      if (e->dest != EXIT_BLOCK_PTR)
 		SET_BIT (edge_cache[bb->index], e->dest->index);
 	  }
+	    END_FOR_EACH_EDGE;
+	  }
     }
 
   /* By nature of the way these get numbered, ENTRY_BLOCK_PTR->next_bb block
@@ -388,12 +391,16 @@ make_edges (basic_block min, basic_block
 
       /* Find out if we can drop through to the next block.  */
       insn = NEXT_INSN (insn);
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
 	  {
 	    insn = 0;
 	    break;
 	  }
+	}
+      END_FOR_EACH_EDGE;
+
       while (insn
 	     && NOTE_P (insn)
 	     && NOTE_LINE_NUMBER (insn) != NOTE_INSN_BASIC_BLOCK)
@@ -641,7 +648,7 @@ compute_outgoing_frequencies (basic_bloc
 {
   edge e, f;
 
-  if (b->succ && b->succ->succ_next && !b->succ->succ_next->succ_next)
+  if (EDGE_COUNT (b->succs) == 2)
     {
       rtx note = find_reg_note (BB_END (b), REG_BR_PROB, NULL);
       int probability;
@@ -660,19 +667,22 @@ compute_outgoing_frequencies (basic_bloc
 	}
     }
 
-  if (b->succ && !b->succ->succ_next)
+  if (EDGE_COUNT (b->succs) == 1)
     {
-      e = b->succ;
+      e = EDGE_SUCC (b, 0);
       e->probability = REG_BR_PROB_BASE;
       e->count = b->count;
       return;
     }
   guess_outgoing_edge_probabilities (b);
   if (b->count)
-    for (e = b->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, b->succs)
+      {
       e->count = ((b->count * e->probability + REG_BR_PROB_BASE / 2)
 		  / REG_BR_PROB_BASE);
 }
+    END_FOR_EACH_EDGE;
+}
 
 /* Assume that someone emitted code with control flow instructions to the
    basic block.  Update the data structure.  */
@@ -716,11 +726,12 @@ find_many_sub_basic_blocks (sbitmap bloc
 	  {
 	    bb->count = 0;
 	    bb->frequency = 0;
-	    for (e = bb->pred; e; e = e->pred_next)
+	    FOR_EACH_EDGE (e, bb->preds)
 	      {
 		bb->count += e->count;
 		bb->frequency += EDGE_FREQUENCY (e);
 	      }
+	    END_FOR_EACH_EDGE;
 	  }
 
 	compute_outgoing_frequencies (bb);
@@ -756,11 +767,12 @@ find_sub_basic_blocks (basic_block bb)
 	{
 	  b->count = 0;
 	  b->frequency = 0;
-	  for (e = b->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, b->preds)
 	    {
 	      b->count += e->count;
 	      b->frequency += EDGE_FREQUENCY (e);
 	    }
+	  END_FOR_EACH_EDGE;
 	}
 
       compute_outgoing_frequencies (b);
Index: gcc/cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.129
diff -u -p -w -r1.129 cfgcleanup.c
--- gcc/cfgcleanup.c	7 Sep 2004 15:46:46 -0000	1.129
+++ gcc/cfgcleanup.c	13 Sep 2004 04:38:52 -0000
@@ -124,9 +124,7 @@ try_simplify_condjump (basic_block cbran
   rtx cbranch_insn;
 
   /* Verify that there are exactly two successors.  */
-  if (!cbranch_block->succ
-      || !cbranch_block->succ->succ_next
-      || cbranch_block->succ->succ_next->succ_next)
+  if (EDGE_COUNT (cbranch_block->succs) != 2)
     return false;
 
   /* Verify that we've got a normal conditional branch at the end
@@ -142,11 +140,11 @@ try_simplify_condjump (basic_block cbran
      be the last block in the function, and must contain just the
      unconditional jump.  */
   jump_block = cbranch_fallthru_edge->dest;
-  if (jump_block->pred->pred_next
+  if (EDGE_COUNT (jump_block->preds) >= 2
       || jump_block->next_bb == EXIT_BLOCK_PTR
       || !FORWARDER_BLOCK_P (jump_block))
     return false;
-  jump_dest_block = jump_block->succ->dest;
+  jump_dest_block = EDGE_SUCC (jump_block, 0)->dest;
 
   /* If we are partitioning hot/cold basic blocks, we don't want to
      mess up unconditional or indirect jumps that cross between hot
@@ -290,9 +288,9 @@ thread_jump (int mode, edge e, basic_blo
 
   /* At the moment, we do handle only conditional jumps, but later we may
      want to extend this code to tablejumps and others.  */
-  if (!e->src->succ->succ_next || e->src->succ->succ_next->succ_next)
+  if (EDGE_COUNT (e->src->succs) != 2)
     return NULL;
-  if (!b->succ || !b->succ->succ_next || b->succ->succ_next->succ_next)
+  if (EDGE_COUNT (b->succs) != 2)
     {
       BB_SET_FLAG (b, BB_NONTHREADABLE_BLOCK);
       return NULL;
@@ -421,7 +419,8 @@ static bool
 try_forward_edges (int mode, basic_block b)
 {
   bool changed = false;
-  edge e, next, *threaded_edges = NULL;
+  edge e, *threaded_edges = NULL;
+  unsigned ix;
 
   /* If we are partitioning hot/cold basic blocks, we don't want to
      mess up unconditional or indirect jumps that cross between hot
@@ -437,7 +436,7 @@ try_forward_edges (int mode, basic_block
       && find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX))
     return false;
 
-  for (e = b->succ; e; e = next)
+  for (ix = 0; VEC_iterate (edge, b->succs, ix, e); )
     {
       basic_block target, first;
       int counter;
@@ -445,15 +444,16 @@ try_forward_edges (int mode, basic_block
       int nthreaded_edges = 0;
       bool may_thread = first_pass | (b->flags & BB_DIRTY);
 
-      next = e->succ_next;
-
       /* Skip complex edges because we don't know how to update them.
 
          Still handle fallthru edges, as we can succeed to forward fallthru
          edge to the same place as the branch edge of conditional branch
          and turn conditional branch to an unconditional branch.  */
       if (e->flags & EDGE_COMPLEX)
+	{
+	  ix++;
 	continue;
+	}
 
       target = first = e->dest;
       counter = 0;
@@ -480,13 +480,13 @@ try_forward_edges (int mode, basic_block
 	  may_thread |= target->flags & BB_DIRTY;
 
 	  if (FORWARDER_BLOCK_P (target)
-	      && !(target->succ->flags & EDGE_CROSSING)
-	      && target->succ->dest != EXIT_BLOCK_PTR)
+  	      && !(EDGE_SUCC (target, 0)->flags & EDGE_CROSSING)
+	      && EDGE_SUCC (target, 0)->dest != EXIT_BLOCK_PTR)
 	    {
 	      /* Bypass trivial infinite loops.  */
-	      if (target == target->succ->dest)
+	      if (target == EDGE_SUCC (target, 0)->dest)
 		counter = n_basic_blocks;
-	      new_target = target->succ->dest;
+	      new_target = EDGE_SUCC (target, 0)->dest;
 	    }
 
 	  /* Allow to thread only over one edge at time to simplify updating
@@ -538,7 +538,7 @@ try_forward_edges (int mode, basic_block
 	     it must appear before the JUMP_INSN.  */
 	  if ((mode & CLEANUP_PRE_LOOP) && optimize)
 	    {
-	      rtx insn = (target->succ->flags & EDGE_FALLTHRU
+	      rtx insn = (EDGE_SUCC (target, 0)->flags & EDGE_FALLTHRU
 			  ? BB_HEAD (target) : prev_nonnote_insn (BB_END (target)));
 
 	      if (!NOTE_P (insn))
@@ -597,6 +597,7 @@ try_forward_edges (int mode, basic_block
 		fprintf (dump_file,
 			 "Forwarding edge %i->%i to %i failed.\n",
 			 b->index, e->dest->index, target->index);
+	      ix++;
 	      continue;
 	    }
 
@@ -620,7 +621,7 @@ try_forward_edges (int mode, basic_block
 	      first->frequency -= edge_frequency;
 	      if (first->frequency < 0)
 		first->frequency = 0;
-	      if (first->succ->succ_next)
+	      if (EDGE_COUNT (first->succs) > 1)
 		{
 		  edge e;
 		  int prob;
@@ -638,13 +639,18 @@ try_forward_edges (int mode, basic_block
 		  prob = REG_BR_PROB_BASE - prob;
 		  if (prob <= 0)
 		    {
-		      first->succ->probability = REG_BR_PROB_BASE;
-		      first->succ->succ_next->probability = 0;
+		      EDGE_SUCC (first, 0)->probability = REG_BR_PROB_BASE;
+		      EDGE_SUCC (first, 1)->probability = 0;
 		    }
 		  else
-		    for (e = first->succ; e; e = e->succ_next)
+		    {
+		      FOR_EACH_EDGE (e, first->succs)
+			{
 		      e->probability = ((e->probability * REG_BR_PROB_BASE)
 					/ (double) prob);
+			}
+		      END_FOR_EACH_EDGE;
+		    }
 		  update_br_prob_note (first);
 		}
 	      else
@@ -656,7 +662,7 @@ try_forward_edges (int mode, basic_block
 		  if (n < nthreaded_edges
 		      && first == threaded_edges [n]->src)
 		    n++;
-		  t = first->succ;
+		  t = EDGE_SUCC (first, 0);
 		}
 
 	      t->count -= edge_count;
@@ -667,7 +673,9 @@ try_forward_edges (int mode, basic_block
 	  while (first != target);
 
 	  changed = true;
+	  continue;
 	}
+      ix++;
     }
 
   if (threaded_edges)
@@ -867,15 +875,21 @@ merge_blocks_move (edge e, basic_block b
 	 and loop notes.  This is done by squeezing out all the notes
 	 and leaving them there to lie.  Not ideal, but functional.  */
 
-      for (tmp_edge = c->succ; tmp_edge; tmp_edge = tmp_edge->succ_next)
+      FOR_EACH_EDGE (tmp_edge, c->succs)
+	{
 	if (tmp_edge->flags & EDGE_FALLTHRU)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
 
       c_has_outgoing_fallthru = (tmp_edge != NULL);
 
-      for (tmp_edge = b->pred; tmp_edge; tmp_edge = tmp_edge->pred_next)
+      FOR_EACH_EDGE (tmp_edge, b->preds)
+	{
 	if (tmp_edge->flags & EDGE_FALLTHRU)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
 
       b_has_incoming_fallthru = (tmp_edge != NULL);
       b_fallthru_edge = tmp_edge;
@@ -1235,18 +1249,16 @@ outgoing_edges_match (int mode, basic_bl
 
   /* If BB1 has only one successor, we may be looking at either an
      unconditional jump, or a fake edge to exit.  */
-  if (bb1->succ && !bb1->succ->succ_next
-      && (bb1->succ->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
+  if (EDGE_COUNT (bb1->succs) == 1
+      && (EDGE_SUCC (bb1, 0)->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
       && (!JUMP_P (BB_END (bb1)) || simplejump_p (BB_END (bb1))))
-    return (bb2->succ &&  !bb2->succ->succ_next
-	    && (bb2->succ->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
+    return (EDGE_COUNT (bb2->succs) == 1
+	    && (EDGE_SUCC (bb2, 0)->flags & (EDGE_COMPLEX | EDGE_FAKE)) == 0
 	    && (!JUMP_P (BB_END (bb2)) || simplejump_p (BB_END (bb2))));
 
   /* Match conditional jumps - this may get tricky when fallthru and branch
      edges are crossed.  */
-  if (bb1->succ
-      && bb1->succ->succ_next
-      && !bb1->succ->succ_next->succ_next
+  if (EDGE_COUNT (bb1->succs) == 2
       && any_condjump_p (BB_END (bb1))
       && onlyjump_p (BB_END (bb1)))
     {
@@ -1255,9 +1267,7 @@ outgoing_edges_match (int mode, basic_bl
       rtx set1, set2, cond1, cond2;
       enum rtx_code code1, code2;
 
-      if (!bb2->succ
-	  || !bb2->succ->succ_next
-	  || bb2->succ->succ_next->succ_next
+      if (EDGE_COUNT (bb2->succs) != 2
 	  || !any_condjump_p (BB_END (bb2))
 	  || !onlyjump_p (BB_END (bb2)))
 	return false;
@@ -1270,10 +1280,10 @@ outgoing_edges_match (int mode, basic_bl
       /* Get around possible forwarders on fallthru edges.  Other cases
          should be optimized out already.  */
       if (FORWARDER_BLOCK_P (f1->dest))
-	f1 = f1->dest->succ;
+	f1 = EDGE_SUCC (f1->dest, 0);
 
       if (FORWARDER_BLOCK_P (f2->dest))
-	f2 = f2->dest->succ;
+	f2 = EDGE_SUCC (f2->dest, 0);
 
       /* To simplify use of this function, return false if there are
 	 unneeded forwarder blocks.  These will get eliminated later
@@ -1443,9 +1453,14 @@ outgoing_edges_match (int mode, basic_bl
   /* Search the outgoing edges, ensure that the counts do match, find possible
      fallthru and exception handling edges since these needs more
      validation.  */
-  for (e1 = bb1->succ, e2 = bb2->succ; e1 && e2;
-       e1 = e1->succ_next, e2 = e2->succ_next)
+  if (EDGE_COUNT (bb1->succs) != EDGE_COUNT (bb2->succs))
+    return false;
+
+  FOR_EACH_EDGE (e1, bb1->succs)
     {
+      /* FIXME: Don't use private iterator. */
+      e2 = EDGE_SUCC (bb2, __ix);
+      
       if (e1->flags & EDGE_EH)
 	nehedges1++;
 
@@ -1457,10 +1472,10 @@ outgoing_edges_match (int mode, basic_bl
       if (e2->flags & EDGE_FALLTHRU)
 	fallthru2 = e2;
     }
+  END_FOR_EACH_EDGE;
 
   /* If number of edges of various types does not match, fail.  */
-  if (e1 || e2
-      || nehedges1 != nehedges2
+  if (nehedges1 != nehedges2
       || (fallthru1 != 0) != (fallthru2 != 0))
     return false;
 
@@ -1468,9 +1483,9 @@ outgoing_edges_match (int mode, basic_bl
   if (fallthru1)
     {
       basic_block d1 = (forwarder_block_p (fallthru1->dest)
-			? fallthru1->dest->succ->dest: fallthru1->dest);
+			? EDGE_SUCC (fallthru1->dest, 0)->dest: fallthru1->dest);
       basic_block d2 = (forwarder_block_p (fallthru2->dest)
-			? fallthru2->dest->succ->dest: fallthru2->dest);
+			? EDGE_SUCC (fallthru2->dest, 0)->dest: fallthru2->dest);
 
       if (d1 != d2)
 	return false;
@@ -1524,15 +1539,13 @@ try_crossjump_to_edge (int mode, edge e1
      about multiple entry or chained forwarders, as they will be optimized
      away.  We do this to look past the unconditional jump following a
      conditional jump that is required due to the current CFG shape.  */
-  if (src1->pred
-      && !src1->pred->pred_next
+  if (EDGE_COUNT (src1->preds) == 1
       && FORWARDER_BLOCK_P (src1))
-    e1 = src1->pred, src1 = e1->src;
+    e1 = EDGE_PRED (src1, 0), src1 = e1->src;
 
-  if (src2->pred
-      && !src2->pred->pred_next
+  if (EDGE_COUNT (src2->preds) == 1
       && FORWARDER_BLOCK_P (src2))
-    e2 = src2->pred, src2 = e2->src;
+    e2 = EDGE_PRED (src2, 0), src2 = e2->src;
 
   /* Nothing to do if we reach ENTRY, or a common source block.  */
   if (src1 == ENTRY_BLOCK_PTR || src2 == ENTRY_BLOCK_PTR)
@@ -1542,16 +1555,16 @@ try_crossjump_to_edge (int mode, edge e1
 
   /* Seeing more than 1 forwarder blocks would confuse us later...  */
   if (FORWARDER_BLOCK_P (e1->dest)
-      && FORWARDER_BLOCK_P (e1->dest->succ->dest))
+      && FORWARDER_BLOCK_P (EDGE_SUCC (e1->dest, 0)->dest))
     return false;
 
   if (FORWARDER_BLOCK_P (e2->dest)
-      && FORWARDER_BLOCK_P (e2->dest->succ->dest))
+      && FORWARDER_BLOCK_P (EDGE_SUCC (e2->dest, 0)->dest))
     return false;
 
   /* Likewise with dead code (possibly newly created by the other optimizations
      of cfg_cleanup).  */
-  if (!src1->pred || !src2->pred)
+  if (EDGE_COUNT (src1->preds) == 0 || EDGE_COUNT (src2->preds) == 0)
     return false;
 
   /* Look for the common insn sequence, part the first ...  */
@@ -1624,22 +1637,23 @@ try_crossjump_to_edge (int mode, edge e1
   redirect_to->flags |= BB_DIRTY;
 
   /* Recompute the frequencies and counts of outgoing edges.  */
-  for (s = redirect_to->succ; s; s = s->succ_next)
+  FOR_EACH_EDGE (s, redirect_to->succs)
     {
       edge s2;
       basic_block d = s->dest;
 
       if (FORWARDER_BLOCK_P (d))
-	d = d->succ->dest;
+	d = EDGE_SUCC (d, 0)->dest;
 
-      for (s2 = src1->succ; ; s2 = s2->succ_next)
+      FOR_EACH_EDGE (s2, src1->succs)
 	{
 	  basic_block d2 = s2->dest;
 	  if (FORWARDER_BLOCK_P (d2))
-	    d2 = d2->succ->dest;
+	    d2 = EDGE_SUCC (d2, 0)->dest;
 	  if (d == d2)
 	    break;
 	}
+      END_FOR_EACH_EDGE;
 
       s->count += s2->count;
 
@@ -1648,16 +1662,16 @@ try_crossjump_to_edge (int mode, edge e1
          into infinite loop.  */
       if (FORWARDER_BLOCK_P (s->dest))
 	{
-	  s->dest->succ->count += s2->count;
+	  EDGE_SUCC (s->dest, 0)->count += s2->count;
 	  s->dest->count += s2->count;
 	  s->dest->frequency += EDGE_FREQUENCY (s);
 	}
 
       if (FORWARDER_BLOCK_P (s2->dest))
 	{
-	  s2->dest->succ->count -= s2->count;
-	  if (s2->dest->succ->count < 0)
-	    s2->dest->succ->count = 0;
+	  EDGE_SUCC (s2->dest, 0)->count -= s2->count;
+	  if (EDGE_SUCC (s2->dest, 0)->count < 0)
+	    EDGE_SUCC (s2->dest, 0)->count = 0;
 	  s2->dest->count -= s2->count;
 	  s2->dest->frequency -= EDGE_FREQUENCY (s);
 	  if (s2->dest->frequency < 0)
@@ -1674,6 +1688,7 @@ try_crossjump_to_edge (int mode, edge e1
 	      s2->probability * src1->frequency)
 	     / (redirect_to->frequency + src1->frequency));
     }
+  END_FOR_EACH_EDGE;
 
   update_br_prob_note (redirect_to);
 
@@ -1687,9 +1702,9 @@ try_crossjump_to_edge (int mode, edge e1
     newpos1 = NEXT_INSN (newpos1);
 
   redirect_from = split_block (src1, PREV_INSN (newpos1))->src;
-  to_remove = redirect_from->succ->dest;
+  to_remove = EDGE_SUCC (redirect_from, 0)->dest;
 
-  redirect_edge_and_branch_force (redirect_from->succ, redirect_to);
+  redirect_edge_and_branch_force (EDGE_SUCC (redirect_from, 0), redirect_to);
   delete_basic_block (to_remove);
 
   update_forwarder_flag (redirect_from);
@@ -1704,12 +1719,13 @@ try_crossjump_to_edge (int mode, edge e1
 static bool
 try_crossjump_bb (int mode, basic_block bb)
 {
-  edge e, e2, nexte2, nexte, fallthru;
+  edge e, e2, fallthru;
   bool changed;
-  int n = 0, max;
+  unsigned max, ix, ix2;
+  basic_block ev, ev2;
 
   /* Nothing to do if there is not at least two incoming edges.  */
-  if (!bb->pred || !bb->pred->pred_next)
+  if (EDGE_COUNT (bb->preds) < 2)
     return false;
 
   /* If we are partitioning hot/cold basic blocks, we don't want to
@@ -1723,8 +1739,8 @@ try_crossjump_bb (int mode, basic_block 
      bb-reorder.c:partition_hot_cold_basic_blocks for complete details.  */
 
   if (flag_reorder_blocks_and_partition
-      && (BB_PARTITION (bb->pred->src) != BB_PARTITION (bb->pred->pred_next->src)
-	  || (bb->pred->flags & EDGE_CROSSING)))
+      && (BB_PARTITION (EDGE_PRED (bb, 0)->src) != BB_PARTITION (EDGE_PRED (bb, 1)->src)
+	  || (EDGE_PRED (bb, 0)->flags & EDGE_CROSSING)))
     return false;
 
   /* It is always cheapest to redirect a block that ends in a branch to
@@ -1732,18 +1748,22 @@ try_crossjump_bb (int mode, basic_block 
      program.  We'll try that combination first.  */
   fallthru = NULL;
   max = PARAM_VALUE (PARAM_MAX_CROSSJUMP_EDGES);
-  for (e = bb->pred; e ; e = e->pred_next, n++)
+
+  if (EDGE_COUNT (bb->preds) > max)
+    return false;
+
+  FOR_EACH_EDGE (e, bb->preds);
     {
       if (e->flags & EDGE_FALLTHRU)
 	fallthru = e;
-      if (n > max)
-	return false;
     }
+  END_FOR_EACH_EDGE;
 
   changed = false;
-  for (e = bb->pred; e; e = nexte)
+  for (ix = 0, ev = bb; ix < EDGE_COUNT (ev->preds); )
     {
-      nexte = e->pred_next;
+      e = EDGE_PRED (ev, ix);
+      ix++;
 
       /* As noted above, first try with the fallthru predecessor.  */
       if (fallthru)
@@ -1762,7 +1782,8 @@ try_crossjump_bb (int mode, basic_block 
 	  if (try_crossjump_to_edge (mode, e, fallthru))
 	    {
 	      changed = true;
-	      nexte = bb->pred;
+	      ix = 0;
+	      ev = bb;
 	      continue;
 	    }
 	}
@@ -1779,12 +1800,13 @@ try_crossjump_bb (int mode, basic_block 
 	 can eliminate redundant checks of crossjump(A,B) by arbitrarily
 	 choosing to do the check from the block for which the edge
 	 in question is the first successor of A.  */
-      if (e->src->succ != e)
+      if (EDGE_SUCC (e->src, 0) != e)
 	continue;
 
-      for (e2 = bb->pred; e2; e2 = nexte2)
+      for (ix2 = 0, ev2 = bb; ix2 < EDGE_COUNT (ev2->preds); )
 	{
-	  nexte2 = e2->pred_next;
+	  e2 = EDGE_PRED (ev2, ix2);
+	  ix2++;
 
 	  if (e2 == e)
 	    continue;
@@ -1810,7 +1832,8 @@ try_crossjump_bb (int mode, basic_block 
 	  if (try_crossjump_to_edge (mode, e, e2))
 	    {
 	      changed = true;
-	      nexte = bb->pred;
+	      ev2 = bb;
+	      ix = 0;
 	      break;
 	    }
 	}
@@ -1862,7 +1885,7 @@ try_optimize_cfg (int mode)
 	      bool changed_here = false;
 
 	      /* Delete trivially dead basic blocks.  */
-	      while (b->pred == NULL)
+	      while (EDGE_COUNT (b->preds) == 0)
 		{
 		  c = b->prev_bb;
 		  if (dump_file)
@@ -1876,9 +1899,9 @@ try_optimize_cfg (int mode)
 		}
 
 	      /* Remove code labels no longer used.  */
-	      if (b->pred->pred_next == NULL
-		  && (b->pred->flags & EDGE_FALLTHRU)
-		  && !(b->pred->flags & EDGE_COMPLEX)
+	      if (EDGE_COUNT (b->preds) == 1
+		  && (EDGE_PRED (b, 0)->flags & EDGE_FALLTHRU)
+		  && !(EDGE_PRED (b, 0)->flags & EDGE_COMPLEX)
 		  && LABEL_P (BB_HEAD (b))
 		  /* If the previous block ends with a branch to this
 		     block, we can't delete the label.  Normally this
@@ -1886,10 +1909,10 @@ try_optimize_cfg (int mode)
 		     if CASE_DROPS_THRU, this can be a tablejump with
 		     some element going to the same place as the
 		     default (fallthru).  */
-		  && (b->pred->src == ENTRY_BLOCK_PTR
-		      || !JUMP_P (BB_END (b->pred->src))
+		  && (EDGE_PRED (b, 0)->src == ENTRY_BLOCK_PTR
+		      || !JUMP_P (BB_END (EDGE_PRED (b, 0)->src))
 		      || ! label_is_jump_target_p (BB_HEAD (b),
-						   BB_END (b->pred->src))))
+						   BB_END (EDGE_PRED (b, 0)->src))))
 		{
 		  rtx label = BB_HEAD (b);
 
@@ -1910,13 +1933,13 @@ try_optimize_cfg (int mode)
 
 	      /* If we fall through an empty block, we can remove it.  */
 	      if (!(mode & CLEANUP_CFGLAYOUT)
-		  && b->pred->pred_next == NULL
-		  && (b->pred->flags & EDGE_FALLTHRU)
+		  && EDGE_COUNT (b->preds) == 1
+		  && (EDGE_PRED (b, 0)->flags & EDGE_FALLTHRU)
 		  && !LABEL_P (BB_HEAD (b))
 		  && FORWARDER_BLOCK_P (b)
 		  /* Note that forwarder_block_p true ensures that
 		     there is a successor for this block.  */
-		  && (b->succ->flags & EDGE_FALLTHRU)
+		  && (EDGE_SUCC (b, 0)->flags & EDGE_FALLTHRU)
 		  && n_basic_blocks > 1)
 		{
 		  if (dump_file)
@@ -1925,17 +1948,17 @@ try_optimize_cfg (int mode)
 			     b->index);
 
 		  c = b->prev_bb == ENTRY_BLOCK_PTR ? b->next_bb : b->prev_bb;
-		  redirect_edge_succ_nodup (b->pred, b->succ->dest);
+		  redirect_edge_succ_nodup (EDGE_PRED (b, 0), EDGE_SUCC (b, 0)->dest);
 		  delete_basic_block (b);
 		  changed = true;
 		  b = c;
 		}
 
-	      if ((s = b->succ) != NULL
-		  && s->succ_next == NULL
+	      if (EDGE_COUNT (b->succs) == 1
+		  && (s = EDGE_SUCC (b, 0))
 		  && !(s->flags & EDGE_COMPLEX)
 		  && (c = s->dest) != EXIT_BLOCK_PTR
-		  && c->pred->pred_next == NULL
+		  && EDGE_COUNT (c->preds) == 1
 		  && b != c)
 		{
 		  /* When not in cfg_layout mode use code aware of reordering
@@ -1977,12 +2000,11 @@ try_optimize_cfg (int mode)
 		 non-trivial jump instruction without side-effects, we
 		 can either delete the jump entirely, or replace it
 		 with a simple unconditional jump.  */
-	      if (b->succ
-		  && ! b->succ->succ_next
-		  && b->succ->dest != EXIT_BLOCK_PTR
+	      if (EDGE_COUNT (b->succs) == 1
+		  && EDGE_SUCC (b, 0)->dest != EXIT_BLOCK_PTR
 		  && onlyjump_p (BB_END (b))
 		  && !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX)
-		  && try_redirect_by_replacing_jump (b->succ, b->succ->dest,
+		  && try_redirect_by_replacing_jump (EDGE_SUCC (b, 0), EDGE_SUCC (b, 0)->dest,
 						     (mode & CLEANUP_CFGLAYOUT) != 0))
 		{
 		  update_forwarder_flag (b);
@@ -2067,12 +2089,11 @@ merge_seq_blocks (void)
 
   for (bb = ENTRY_BLOCK_PTR->next_bb; bb != EXIT_BLOCK_PTR; )
     {
-      if (bb->succ
-	  && !bb->succ->succ_next
-	  && can_merge_blocks_p (bb, bb->succ->dest))
+      if (EDGE_COUNT (bb->succs) == 1
+	  && can_merge_blocks_p (bb, EDGE_SUCC (bb, 0)->dest))
 	{
 	  /* Merge the blocks and retry.  */
-	  merge_blocks (bb, bb->succ->dest);
+	  merge_blocks (bb, EDGE_SUCC (bb, 0)->dest);
 	  changed = true;
 	  continue;
 	}
Index: gcc/cfgexpand.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgexpand.c,v
retrieving revision 2.23
diff -u -p -w -r2.23 cfgexpand.c
--- gcc/cfgexpand.c	11 Sep 2004 20:07:11 -0000	2.23
+++ gcc/cfgexpand.c	13 Sep 2004 04:38:52 -0000
@@ -878,6 +878,7 @@ expand_gimple_tailcall (basic_block bb, 
 {
   rtx last = get_last_insn ();
   edge e;
+  unsigned ix;
   int probability;
   gcov_type count;
 
@@ -902,13 +903,11 @@ expand_gimple_tailcall (basic_block bb, 
      all edges here, or redirecting the existing fallthru edge to
      the exit block.  */
 
-  e = bb->succ;
   probability = 0;
   count = 0;
-  while (e)
-    {
-      edge next = e->succ_next;
 
+  for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
+    {
       if (!(e->flags & (EDGE_ABNORMAL | EDGE_EH)))
 	{
 	  if (e->dest != EXIT_BLOCK_PTR)
@@ -924,8 +923,8 @@ expand_gimple_tailcall (basic_block bb, 
 	  probability += e->probability;
 	  remove_edge (e);
 	}
-
-      e = next;
+      else
+	ix++;
     }
 
   /* This is somewhat ugly: the call_expr expander often emits instructions
@@ -974,6 +973,7 @@ expand_gimple_basic_block (basic_block b
   tree stmt = NULL;
   rtx note, last;
   edge e;
+  unsigned ix;
 
   if (dump_file)
     {
@@ -1004,11 +1004,8 @@ expand_gimple_basic_block (basic_block b
 
   NOTE_BASIC_BLOCK (note) = bb;
 
-  e = bb->succ;
-  while (e)
+  for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
     {
-      edge next = e->succ_next;
-
       /* Clear EDGE_EXECUTABLE.  This flag is never used in the backend.  */
       e->flags &= ~EDGE_EXECUTABLE;
 
@@ -1017,8 +1014,8 @@ expand_gimple_basic_block (basic_block b
          rediscover them.  In the future we should get this fixed properly.  */
       if (e->flags & EDGE_ABNORMAL)
 	remove_edge (e);
-
-      e = next;
+      else
+	ix++;
     }
 
   for (; !bsi_end_p (bsi); bsi_next (&bsi))
@@ -1084,9 +1081,12 @@ construct_init_block (void)
   basic_block init_block, first_block;
   edge e;
 
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+    {
     if (e->dest == ENTRY_BLOCK_PTR->next_bb)
       break;
+    }
+  END_FOR_EACH_EDGE;
 
   init_block = create_basic_block (NEXT_INSN (get_insns ()),
 				   get_last_insn (),
@@ -1117,7 +1117,8 @@ construct_exit_block (void)
   rtx head = get_last_insn ();
   rtx end;
   basic_block exit_block;
-  edge e, e2, next;
+  edge e, e2;
+  unsigned ix;
 
   /* Make sure the locus is set to the end of the function, so that
      epilogue line numbers and warnings are set properly.  */
@@ -1143,22 +1144,32 @@ construct_exit_block (void)
 				   EXIT_BLOCK_PTR->prev_bb);
   exit_block->frequency = EXIT_BLOCK_PTR->frequency;
   exit_block->count = EXIT_BLOCK_PTR->count;
-  for (e = EXIT_BLOCK_PTR->pred; e; e = next)
+
+  ix = 0;
+  while (ix < EDGE_COUNT (EXIT_BLOCK_PTR->preds))
     {
-      next = e->pred_next;
+      e = EDGE_I (EXIT_BLOCK_PTR->preds, ix);
       if (!(e->flags & EDGE_ABNORMAL))
         redirect_edge_succ (e, exit_block);
+      else
+	ix++;
     }
+
   e = make_edge (exit_block, EXIT_BLOCK_PTR, EDGE_FALLTHRU);
   e->probability = REG_BR_PROB_BASE;
   e->count = EXIT_BLOCK_PTR->count;
-  for (e2 = EXIT_BLOCK_PTR->pred; e2; e2 = e2->pred_next)
+
+  FOR_EACH_EDGE (e2, EXIT_BLOCK_PTR->preds)
+    {
     if (e2 != e)
       {
         e->count -= e2->count;
 	exit_block->count -= e2->count;
 	exit_block->frequency -= EDGE_FREQUENCY (e2);
       }
+    }
+  END_FOR_EACH_EDGE;
+    
   if (e->count < 0)
     e->count = 0;
   if (exit_block->count < 0)
Index: gcc/cfghooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfghooks.c,v
retrieving revision 1.13
diff -u -p -w -r1.13 cfghooks.c
--- gcc/cfghooks.c	7 Sep 2004 15:46:47 -0000	1.13
+++ gcc/cfghooks.c	13 Sep 2004 04:38:53 -0000
@@ -119,7 +119,7 @@ verify_flow_info (void)
 	         bb->index, bb->frequency);
 	  err = 1;
 	}
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (last_visited [e->dest->index + 2] == bb)
 	    {
@@ -159,13 +159,15 @@ verify_flow_info (void)
 
 	  edge_checksum[e->dest->index + 2] += (size_t) e;
 	}
+      END_FOR_EACH_EDGE;
+
       if (n_fallthru > 1)
 	{
 	  error ("Wrong amount of branch edges after unconditional jump %i", bb->index);
 	  err = 1;
 	}
 
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  if (e->dest != bb)
 	    {
@@ -179,18 +181,25 @@ verify_flow_info (void)
 	    }
 	  edge_checksum[e->dest->index + 2] -= (size_t) e;
 	}
+      END_FOR_EACH_EDGE;
     }
 
   /* Complete edge checksumming for ENTRY and EXIT.  */
   {
     edge e;
 
-    for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
+    FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+      {
       edge_checksum[e->dest->index + 2] += (size_t) e;
+      }
+    END_FOR_EACH_EDGE;
 
-    for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next)
+    FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+      {
       edge_checksum[e->dest->index + 2] -= (size_t) e;
   }
+    END_FOR_EACH_EDGE;
+  }
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
     if (edge_checksum[bb->index + 2])
@@ -245,13 +254,19 @@ dump_bb (basic_block bb, FILE *outf, int
   putc ('\n', outf);
 
   fprintf (outf, ";;%s pred:      ", s_indent);
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
+    {
     dump_edge_info (outf, e, 0);
+    }
+  END_FOR_EACH_EDGE;
   putc ('\n', outf);
 
   fprintf (outf, ";;%s succ:      ", s_indent);
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     dump_edge_info (outf, e, 1);
+    }
+  END_FOR_EACH_EDGE;
   putc ('\n', outf);
 
   if (cfg_hooks->dump_bb)
@@ -360,13 +375,13 @@ delete_basic_block (basic_block bb)
 
   /* Remove the edges into and out of this block.  Note that there may
      indeed be edges in, if we are removing an unreachable loop.  */
-  while (bb->pred != NULL)
-    remove_edge (bb->pred);
-  while (bb->succ != NULL)
-    remove_edge (bb->succ);
+  while (EDGE_COUNT (bb->preds) != 0)
+    remove_edge (EDGE_PRED (bb, 0));
+  while (EDGE_COUNT (bb->succs) != 0)
+    remove_edge (EDGE_SUCC (bb, 0));
 
-  bb->pred = NULL;
-  bb->succ = NULL;
+  VEC_truncate (edge, bb->preds, 0);
+  VEC_truncate (edge, bb->succs, 0);
 
   if (dom_computed[CDI_DOMINATORS])
     delete_from_dominance_info (CDI_DOMINATORS, bb);
@@ -393,11 +408,11 @@ split_edge (edge e)
   ret = cfg_hooks->split_edge (e);
   ret->count = count;
   ret->frequency = freq;
-  ret->succ->probability = REG_BR_PROB_BASE;
-  ret->succ->count = count;
+  EDGE_SUCC (ret, 0)->probability = REG_BR_PROB_BASE;
+  EDGE_SUCC (ret, 0)->count = count;
 
   if (dom_computed[CDI_DOMINATORS])
-    set_immediate_dominator (CDI_DOMINATORS, ret, ret->pred->src);
+    set_immediate_dominator (CDI_DOMINATORS, ret, EDGE_PRED (ret, 0)->src);
 
   if (dom_computed[CDI_DOMINATORS] >= DOM_NO_FAST_QUERY)
     {
@@ -410,21 +425,22 @@ split_edge (edge e)
 	 ret, provided that all other predecessors of e->dest are
 	 dominated by e->dest.  */
 
-      if (get_immediate_dominator (CDI_DOMINATORS, ret->succ->dest)
-	  == ret->pred->src)
+      if (get_immediate_dominator (CDI_DOMINATORS, EDGE_SUCC (ret, 0)->dest)
+	  == EDGE_PRED (ret, 0)->src)
 	{
-	  for (f = ret->succ->dest->pred; f; f = f->pred_next)
+	  FOR_EACH_EDGE (f, EDGE_SUCC (ret, 0)->dest->preds)
 	    {
-	      if (f == ret->succ)
+	      if (f == EDGE_SUCC (ret, 0))
 		continue;
 
 	      if (!dominated_by_p (CDI_DOMINATORS, f->src,
-				   ret->succ->dest))
+				   EDGE_SUCC (ret, 0)->dest))
 		break;
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  if (!f)
-	    set_immediate_dominator (CDI_DOMINATORS, ret->succ->dest, ret);
+	    set_immediate_dominator (CDI_DOMINATORS, EDGE_SUCC (ret, 0)->dest, ret);
 	}
     };
 
@@ -510,17 +526,21 @@ merge_blocks (basic_block a, basic_block
      partway though the merge of blocks for conditional_execution we'll
      be merging a TEST block with THEN and ELSE successors.  Free the
      whole lot of them and hope the caller knows what they're doing.  */
-  while (a->succ)
-    remove_edge (a->succ);
+
+  while (EDGE_COUNT (a->succs) != 0)
+   remove_edge (EDGE_SUCC (a, 0));
 
   /* Adjust the edges out of B for the new owner.  */
-  for (e = b->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, b->succs)
+    {
     e->src = a;
-  a->succ = b->succ;
+    }
+  END_FOR_EACH_EDGE;
+  a->succs = b->succs;
   a->flags |= b->flags;
 
   /* B hasn't quite yet ceased to exist.  Attempt to prevent mishap.  */
-  b->pred = b->succ = NULL;
+  b->preds = b->succs = NULL;
   a->global_live_at_end = b->global_live_at_end;
 
   if (dom_computed[CDI_DOMINATORS])
@@ -542,8 +562,9 @@ edge
 make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
 		      void (*new_bb_cbk) (basic_block))
 {
-  edge e, next_e, fallthru;
+  edge e, fallthru;
   basic_block dummy, jump;
+  unsigned ix;
 
   if (!cfg_hooks->make_forwarder_block)
     internal_error ("%s does not support make_forwarder_block.",
@@ -554,11 +575,13 @@ make_forwarder_block (basic_block bb, bo
   bb = fallthru->dest;
 
   /* Redirect back edges we want to keep.  */
-  for (e = dummy->pred; e; e = next_e)
+  for (ix = 0; VEC_iterate (edge, dummy->preds, ix, e); )
     {
-      next_e = e->pred_next;
       if (redirect_edge_p (e))
+	{
+	  ix++;
 	continue;
+	}
 
       dummy->frequency -= EDGE_FREQUENCY (e);
       dummy->count -= e->count;
@@ -630,14 +653,16 @@ tidy_fallthru_edges (void)
 	 merge the flags for the duplicate edges.  So we do not want to
 	 check that the edge is not a FALLTHRU edge.  */
 
-      if ((s = b->succ) != NULL
-	  && ! (s->flags & EDGE_COMPLEX)
-	  && s->succ_next == NULL
+      if (EDGE_COUNT (b->succs) == 1)
+	{
+	  s = EDGE_SUCC (b, 0);
+	  if (! (s->flags & EDGE_COMPLEX)
 	  && s->dest == c
 	  && !find_reg_note (BB_END (b), REG_CROSSING_JUMP, NULL_RTX))
 	tidy_fallthru_edge (s);
     }
 }
+}
 
 /* Returns true if we can duplicate basic block BB.  */
 
@@ -655,9 +680,12 @@ can_duplicate_block_p (basic_block bb)
 
   /* Duplicating fallthru block to exit would require adding a jump
      and splitting the real last BB.  */
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (e->dest == EXIT_BLOCK_PTR && e->flags & EDGE_FALLTHRU)
        return false;
+    }
+  END_FOR_EACH_EDGE;
 
   return cfg_hooks->can_duplicate_block_p (bb);
 }
@@ -678,7 +706,7 @@ duplicate_block (basic_block bb, edge e)
 
   if (bb->count < new_count)
     new_count = bb->count;
-  gcc_assert (bb->pred);
+  gcc_assert (EDGE_COUNT (bb->preds) > 0);
 #ifdef ENABLE_CHECKING
   gcc_assert (can_duplicate_block_p (bb));
 #endif
@@ -687,7 +715,7 @@ duplicate_block (basic_block bb, edge e)
 
   new_bb->loop_depth = bb->loop_depth;
   new_bb->flags = bb->flags;
-  for (s = bb->succ; s; s = s->succ_next)
+  FOR_EACH_EDGE (s, bb->succs)
     {
       /* Since we are creating edges from a new block to successors
 	 of another block (which therefore are known to be disjoint), there
@@ -704,6 +732,7 @@ duplicate_block (basic_block bb, edge e)
 	n->count = s->count;
       n->aux = s->aux;
     }
+  END_FOR_EACH_EDGE;
 
   if (e)
     {
Index: gcc/cfglayout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfglayout.c,v
retrieving revision 1.74
diff -u -p -w -r1.74 cfglayout.c
--- gcc/cfglayout.c	7 Sep 2004 15:46:47 -0000	1.74
+++ gcc/cfglayout.c	13 Sep 2004 04:38:53 -0000
@@ -633,17 +633,21 @@ fixup_reorder_chain (void)
       basic_block nb;
       basic_block old_bb;
 
-      if (bb->succ == NULL)
+      if (EDGE_COUNT (bb->succs) == 0)
 	continue;
 
       /* Find the old fallthru edge, and another non-EH edge for
 	 a taken jump.  */
       e_taken = e_fall = NULL;
-      for (e = bb->succ; e ; e = e->succ_next)
+
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (e->flags & EDGE_FALLTHRU)
 	  e_fall = e;
 	else if (! (e->flags & EDGE_EH))
 	  e_taken = e;
+	}
+      END_FOR_EACH_EDGE;
 
       bb_end_insn = BB_END (bb);
       if (JUMP_P (bb_end_insn))
@@ -790,11 +794,11 @@ fixup_reorder_chain (void)
 	  /* Make sure new bb is tagged for correct section (same as
 	     fall-thru source, since you cannot fall-throu across
 	     section boundaries).  */
-	  BB_COPY_PARTITION (e_fall->src, bb->pred->src);
+	  BB_COPY_PARTITION (e_fall->src, EDGE_PRED (bb, 0)->src);
 	  if (flag_reorder_blocks_and_partition
 	      && targetm.have_named_sections)
 	    {
-	      if (BB_PARTITION (bb->pred->src) == BB_COLD_PARTITION)
+	      if (BB_PARTITION (EDGE_PRED (bb, 0)->src) == BB_COLD_PARTITION)
 		{
 		  rtx new_note;
 		  rtx note = BB_HEAD (e_fall->src);
@@ -810,7 +814,7 @@ fixup_reorder_chain (void)
 		}
 	      if (JUMP_P (BB_END (bb))
 		  && !any_condjump_p (BB_END (bb))
-		  && (bb->succ->flags & EDGE_CROSSING))
+  		  && (EDGE_SUCC (bb, 0)->flags & EDGE_CROSSING))
 		REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
 		  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
 	    }
@@ -860,8 +864,14 @@ fixup_reorder_chain (void)
   FOR_EACH_BB (bb)
     {
       edge e;
-      for (e = bb->succ; e && !(e->flags & EDGE_FALLTHRU); e = e->succ_next)
-	continue;
+
+      FOR_EACH_EDGE (e, bb->succs)
+	{
+	  if (e->flags & EDGE_FALLTHRU)
+	    break;
+	}
+      END_FOR_EACH_EDGE;
+
       if (e && !can_fallthru (e->src, e->dest))
 	force_nonfallthru (e);
     }
@@ -923,9 +933,12 @@ fixup_fallthru_exit_predecessor (void)
      value.  */
   gcc_assert (reload_completed);
 
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     if (e->flags & EDGE_FALLTHRU)
       bb = e->src;
+    }
+  END_FOR_EACH_EDGE;
 
   if (bb && bb->rbi->next)
     {
@@ -1225,13 +1238,17 @@ can_copy_bbs_p (basic_block *bbs, unsign
   for (i = 0; i < n; i++)
     {
       /* In case we should redirect abnormal edge during duplication, fail.  */
-      for (e = bbs[i]->succ; e; e = e->succ_next)
+
+      FOR_EACH_EDGE (e, bbs[i]->succs)
+	{
 	if ((e->flags & EDGE_ABNORMAL)
 	    && e->dest->rbi->duplicated)
 	  {
 	    ret = false;
 	    goto end;
 	  }
+	}
+      END_FOR_EACH_EDGE;
 
       if (!can_duplicate_block_p (bbs[i]))
 	{
@@ -1310,7 +1327,7 @@ copy_bbs (basic_block *bbs, unsigned n, 
       new_bb = new_bbs[i];
       bb = bbs[i];
 
-      for (e = new_bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, new_bb->succs)
 	{
 	  for (j = 0; j < n_edges; j++)
 	    if (edges[j] && edges[j]->src == bb && edges[j]->dest == e->dest)
@@ -1320,6 +1337,7 @@ copy_bbs (basic_block *bbs, unsigned n, 
 	    continue;
 	  redirect_edge_and_branch_force (e, e->dest->rbi->copy);
 	}
+      END_FOR_EACH_EDGE;
     }
 
   /* Clear information about duplicates.  */
Index: gcc/cfgloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloop.c,v
retrieving revision 1.39
diff -u -p -w -r1.39 cfgloop.c
--- gcc/cfgloop.c	7 Sep 2004 15:46:48 -0000	1.39
+++ gcc/cfgloop.c	13 Sep 2004 04:38:54 -0000
@@ -66,8 +66,11 @@ flow_loops_cfg_dump (const struct loops 
       edge succ;
 
       fprintf (file, ";; %d succs { ", bb->index);
-      for (succ = bb->succ; succ; succ = succ->succ_next)
+      FOR_EACH_EDGE (succ, bb->succs)
+	{
 	fprintf (file, "%d ", succ->dest->index);
+	}
+      END_FOR_EACH_EDGE;
       fprintf (file, "}\n");
     }
 
@@ -245,22 +248,24 @@ flow_loop_entry_edges_find (struct loop 
   int num_entries;
 
   num_entries = 0;
-  for (e = loop->header->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, loop->header->preds)
     {
       if (flow_loop_outside_edge_p (loop, e))
 	num_entries++;
     }
+  END_FOR_EACH_EDGE;
 
   gcc_assert (num_entries);
 
   loop->entry_edges = xmalloc (num_entries * sizeof (edge *));
 
   num_entries = 0;
-  for (e = loop->header->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, loop->header->preds)
     {
       if (flow_loop_outside_edge_p (loop, e))
 	loop->entry_edges[num_entries++] = e;
     }
+  END_FOR_EACH_EDGE;
 
   loop->num_entries = num_entries;
 }
@@ -285,13 +290,15 @@ flow_loop_exit_edges_find (struct loop *
   for (i = 0; i < loop->num_nodes; i++)
     {
       node = bbs[i];
-      for (e = node->succ; e; e = e->succ_next)
+
+      FOR_EACH_EDGE (e, node->succs)
 	{
 	  basic_block dest = e->dest;
 
 	  if (!flow_bb_inside_loop_p (loop, dest))
 	    num_exits++;
 	}
+      END_FOR_EACH_EDGE;
     }
 
   if (! num_exits)
@@ -307,7 +314,7 @@ flow_loop_exit_edges_find (struct loop *
   for (i = 0; i < loop->num_nodes; i++)
     {
       node = bbs[i];
-      for (e = node->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, node->succs)
 	{
 	  basic_block dest = e->dest;
 
@@ -317,6 +324,7 @@ flow_loop_exit_edges_find (struct loop *
 	      loop->exit_edges[num_exits++] = e;
 	    }
       }
+      END_FOR_EACH_EDGE;
     }
   free (bbs);
   loop->num_exits = num_exits;
@@ -351,7 +359,7 @@ flow_loop_nodes_find (basic_block header
 
 	  node = stack[--sp];
 
-	  for (e = node->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, node->preds)
 	    {
 	      basic_block ancestor = e->src;
 
@@ -364,6 +372,7 @@ flow_loop_nodes_find (basic_block header
 		  stack[sp++] = ancestor;
 		}
 	    }
+	  END_FOR_EACH_EDGE;
 	}
       free (stack);
     }
@@ -392,7 +401,7 @@ mark_single_exit_loops (struct loops *lo
     {
       if (bb->loop_father == loops->tree_root)
 	continue;
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (e->dest == EXIT_BLOCK_PTR)
 	    continue;
@@ -407,11 +416,12 @@ mark_single_exit_loops (struct loops *lo
 	      /* If we have already seen an exit, mark this by the edge that
 		 surely does not occur as any exit.  */
 	      if (loop->single_exit)
-		loop->single_exit = ENTRY_BLOCK_PTR->succ;
+		loop->single_exit = EDGE_SUCC (ENTRY_BLOCK_PTR, 0);
 	      else
 		loop->single_exit = e;
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   for (i = 1; i < loops->num; i++)
@@ -420,7 +430,7 @@ mark_single_exit_loops (struct loops *lo
       if (!loop)
 	continue;
 
-      if (loop->single_exit == ENTRY_BLOCK_PTR->succ)
+      if (loop->single_exit == EDGE_SUCC (ENTRY_BLOCK_PTR, 0))
 	loop->single_exit = NULL;
     }
 
@@ -448,9 +458,10 @@ flow_loop_pre_header_scan (struct loop *
   /* Count number of edges along trace from loop header to
      root of pre-header extended basic block.  Usually this is
      only one or two edges.  */
-  for (num = 1; ebb->pred->src != ENTRY_BLOCK_PTR && ! ebb->pred->pred_next;
+  for (num = 1;
+       EDGE_PRED (ebb, 0)->src != ENTRY_BLOCK_PTR && EDGE_COUNT (ebb->preds) == 1;
        num++)
-    ebb = ebb->pred->src;
+    ebb = EDGE_PRED (ebb, 0)->src;
 
   loop->pre_header_edges = xmalloc (num * sizeof (edge));
   loop->num_pre_header_edges = num;
@@ -458,7 +469,7 @@ flow_loop_pre_header_scan (struct loop *
   /* Store edges in order that they are followed.  The source of the first edge
      is the root node of the pre-header extended basic block and the
      destination of the last last edge is the loop header.  */
-  for (e = loop->entry_edges[0]; num; e = e->src->pred)
+  for (e = loop->entry_edges[0]; num; e = EDGE_PRED (e->src, 0))
     loop->pre_header_edges[--num] = e;
 }
 
@@ -474,7 +485,7 @@ flow_loop_pre_header_find (basic_block h
   /* If block p is a predecessor of the header and is the only block
      that the header does not dominate, then it is the pre-header.  */
   pre_header = NULL;
-  for (e = header->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, header->preds)
     {
       basic_block node = e->src;
 
@@ -492,6 +503,7 @@ flow_loop_pre_header_find (basic_block h
 	    }
 	}
     }
+  END_FOR_EACH_EDGE;
 
   return pre_header;
 }
@@ -630,9 +642,9 @@ update_latch_info (basic_block jump)
 {
   alloc_aux_for_block (jump, sizeof (int));
   HEADER_BLOCK (jump) = 0;
-  alloc_aux_for_edge (jump->pred, sizeof (int));
-  LATCH_EDGE (jump->pred) = 0;
-  set_immediate_dominator (CDI_DOMINATORS, jump, jump->pred->src);
+  alloc_aux_for_edge (EDGE_PRED (jump, 0), sizeof (int));
+  LATCH_EDGE (EDGE_PRED (jump, 0)) = 0;
+  set_immediate_dominator (CDI_DOMINATORS, jump, EDGE_PRED (jump, 0)->src);
 }
 
 /* A callback for make_forwarder block, to redirect all edges except for
@@ -673,7 +685,7 @@ canonicalize_loop_headers (void)
       int num_latches = 0;
       int have_abnormal_edge = 0;
 
-      for (e = header->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, header->preds)
 	{
 	  basic_block latch = e->src;
 
@@ -687,22 +699,24 @@ canonicalize_loop_headers (void)
 	      LATCH_EDGE (e) = 1;
 	    }
 	}
+      END_FOR_EACH_EDGE;
+
       if (have_abnormal_edge)
 	HEADER_BLOCK (header) = 0;
       else
 	HEADER_BLOCK (header) = num_latches;
     }
 
-  if (HEADER_BLOCK (ENTRY_BLOCK_PTR->succ->dest))
+  if (HEADER_BLOCK (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest))
     {
       basic_block bb;
 
       /* We could not redirect edges freely here. On the other hand,
 	 we can simply split the edge from entry block.  */
-      bb = split_edge (ENTRY_BLOCK_PTR->succ);
+      bb = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
 
-      alloc_aux_for_edge (bb->succ, sizeof (int));
-      LATCH_EDGE (bb->succ) = 0;
+      alloc_aux_for_edge (EDGE_SUCC (bb, 0), sizeof (int));
+      LATCH_EDGE (EDGE_SUCC (bb, 0)) = 0;
       alloc_aux_for_block (bb, sizeof (int));
       HEADER_BLOCK (bb) = 0;
     }
@@ -719,11 +733,17 @@ canonicalize_loop_headers (void)
       is_heavy = 1;
       heavy = NULL;
       max_freq = 0;
-      for (e = header->pred; e; e = e->pred_next)
+
+      FOR_EACH_EDGE (e, header->preds)
+	{
 	if (LATCH_EDGE (e) &&
 	    EDGE_FREQUENCY (e) > max_freq)
 	  max_freq = EDGE_FREQUENCY (e);
-      for (e = header->pred; e; e = e->pred_next)
+	}
+      END_FOR_EACH_EDGE;
+
+      FOR_EACH_EDGE (e, header->preds)
+	{
 	if (LATCH_EDGE (e) &&
 	    EDGE_FREQUENCY (e) >= max_freq / HEAVY_EDGE_RATIO)
 	  {
@@ -735,6 +755,8 @@ canonicalize_loop_headers (void)
 	    else
 	      heavy = e;
 	  }
+	}
+      END_FOR_EACH_EDGE;
 
       if (is_heavy)
 	{
@@ -823,13 +845,17 @@ flow_loops_find (struct loops *loops, in
 
       /* If we have an abnormal predecessor, do not consider the
 	 loop (not worth the problems).  */
-      for (e = header->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, header->preds)
+	{
 	if (e->flags & EDGE_ABNORMAL)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
+
       if (e)
 	continue;
 
-      for (e = header->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, header->preds)
 	{
 	  basic_block latch = e->src;
 
@@ -850,6 +876,7 @@ flow_loops_find (struct loops *loops, in
 	      num_loops++;
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   /* Allocate loop structures.  */
@@ -908,7 +935,7 @@ flow_loops_find (struct loops *loops, in
 	  num_loops++;
 
 	  /* Look for the latch for this header block.  */
-	  for (e = header->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, header->preds)
 	    {
 	      basic_block latch = e->src;
 
@@ -919,6 +946,7 @@ flow_loops_find (struct loops *loops, in
 		  break;
 		}
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  flow_loop_tree_node_add (header->loop_father, loop);
 	  loop->num_nodes = flow_loop_nodes_find (loop->header, loop);
@@ -1104,7 +1132,7 @@ get_loop_body_in_bfs_order (const struct
           blocks[i++] = bb;
         }
       
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
         { 
           if (flow_bb_inside_loop_p (loop, e->dest))
             { 
@@ -1115,6 +1143,7 @@ get_loop_body_in_bfs_order (const struct
                 }
             }
         }
+      END_FOR_EACH_EDGE;
       
       gcc_assert (i >= vc);
       
@@ -1138,16 +1167,22 @@ get_loop_exit_edges (const struct loop *
   body = get_loop_body (loop);
   n = 0;
   for (i = 0; i < loop->num_nodes; i++)
-    for (e = body[i]->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, body[i]->succs)
+      {
       if (!flow_bb_inside_loop_p (loop, e->dest))
 	n++;
+      }
+    END_FOR_EACH_EDGE;
   edges = xmalloc (n * sizeof (edge));
   *n_edges = n;
   n = 0;
   for (i = 0; i < loop->num_nodes; i++)
-    for (e = body[i]->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, body[i]->succs)
+      {
       if (!flow_bb_inside_loop_p (loop, e->dest))
 	edges[n++] = e;
+      }
+    END_FOR_EACH_EDGE;
   free (body);
 
   return edges;
@@ -1166,7 +1201,7 @@ num_loop_branches (const struct loop *lo
   body = get_loop_body (loop);
   n = 0;
   for (i = 0; i < loop->num_nodes; i++)
-    if (body[i]->succ && body[i]->succ->succ_next)
+    if (EDGE_COUNT (body[i]->succs) >= 2)
       n++;
   free (body);
 
@@ -1317,21 +1352,19 @@ verify_loop_structure (struct loops *loo
 	continue;
 
       if ((loops->state & LOOPS_HAVE_PREHEADERS)
-	  && (!loop->header->pred->pred_next
-	      || loop->header->pred->pred_next->pred_next))
+	  && EDGE_COUNT (loop->header->preds) != 2)
 	{
 	  error ("Loop %d's header does not have exactly 2 entries.", i);
 	  err = 1;
 	}
       if (loops->state & LOOPS_HAVE_SIMPLE_LATCHES)
 	{
-	  if (!loop->latch->succ
-	      || loop->latch->succ->succ_next)
+	  if (EDGE_COUNT (loop->latch->succs) != 1)
 	    {
 	      error ("Loop %d's latch does not have exactly 1 successor.", i);
 	      err = 1;
 	    }
-	  if (loop->latch->succ->dest != loop->header)
+	  if (EDGE_SUCC (loop->latch, 0)->dest != loop->header)
 	    {
 	      error ("Loop %d's latch does not have header as successor.", i);
 	      err = 1;
@@ -1366,10 +1399,13 @@ verify_loop_structure (struct loops *loo
 	    SET_BIT (irreds, bb->index);
 	  else
 	    RESET_BIT (irreds, bb->index);
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->flags & EDGE_IRREDUCIBLE_LOOP)
 	      e->flags |= EDGE_ALL_FLAGS + 1;
 	}
+	  END_FOR_EACH_EDGE;
+	}
 
       /* Recount it.  */
       mark_irreducible_loops (loops);
@@ -1389,7 +1425,7 @@ verify_loop_structure (struct loops *loo
 	      error ("Basic block %d should not be marked irreducible.", bb->index);
 	      err = 1;
 	    }
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      if ((e->flags & EDGE_IRREDUCIBLE_LOOP)
 		  && !(e->flags & (EDGE_ALL_FLAGS + 1)))
@@ -1407,6 +1443,7 @@ verify_loop_structure (struct loops *loo
 		}
 	      e->flags &= ~(EDGE_ALL_FLAGS + 1);
 	    }
+	  END_FOR_EACH_EDGE;
 	}
       free (irreds);
     }
@@ -1419,7 +1456,7 @@ verify_loop_structure (struct loops *loo
 	{
 	  if (bb->loop_father == loops->tree_root)
 	    continue;
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      if (e->dest == EXIT_BLOCK_PTR)
 		continue;
@@ -1445,6 +1482,7 @@ verify_loop_structure (struct loops *loo
 		    }
 		}
 	    }
+	  END_FOR_EACH_EDGE;
 	}
 
       for (i = 1; i < loops->num; i++)
@@ -1483,8 +1521,12 @@ loop_latch_edge (const struct loop *loop
 {
   edge e;
 
-  for (e = loop->header->pred; e->src != loop->latch; e = e->pred_next)
-    continue;
+  FOR_EACH_EDGE (e, loop->header->preds)
+    {
+      if (e->src == loop->latch)
+	break;
+    }
+  END_FOR_EACH_EDGE;
 
   return e;
 }
@@ -1495,8 +1537,12 @@ loop_preheader_edge (const struct loop *
 {
   edge e;
 
-  for (e = loop->header->pred; e->src == loop->latch; e = e->pred_next)
-    continue;
+  FOR_EACH_EDGE (e, loop->header->preds)
+    {
+      if (e->src != loop->latch)
+	break;
+    }
+  END_FOR_EACH_EDGE;
 
   return e;
 }
Index: gcc/cfgloopanal.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopanal.c,v
retrieving revision 1.27
diff -u -p -w -r1.27 cfgloopanal.c
--- gcc/cfgloopanal.c	7 Sep 2004 15:46:47 -0000	1.27
+++ gcc/cfgloopanal.c	13 Sep 2004 04:38:54 -0000
@@ -278,15 +278,18 @@ mark_irreducible_loops (struct loops *lo
   FOR_BB_BETWEEN (act, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
       act->flags &= ~BB_IRREDUCIBLE_LOOP;
-      for (e = act->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, act->succs)
+	{
 	e->flags &= ~EDGE_IRREDUCIBLE_LOOP;
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Create the edge lists.  */
   g = new_graph (last_basic_block + loops->num);
 
   FOR_BB_BETWEEN (act, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
-    for (e = act->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, act->succs)
       {
         /* Ignore edges to exit.  */
         if (e->dest == EXIT_BLOCK_PTR)
@@ -325,6 +328,7 @@ mark_irreducible_loops (struct loops *lo
 
 	add_edge (g, src, dest, e);
       }
+    END_FOR_EACH_EDGE;
 
   /* Find the strongly connected components.  Use the algorithm of Tarjan --
      first determine the postorder dfs numbering in reversed graph, then
@@ -423,11 +427,14 @@ expected_loop_iterations (const struct l
       count_in = 0;
       count_latch = 0;
 
-      for (e = loop->header->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, loop->header->preds)
+	{
 	if (e->src == loop->latch)
 	  count_latch = e->count;
 	else
 	  count_in += e->count;
+	}
+      END_FOR_EACH_EDGE;
 
       if (count_in == 0)
         expected = count_latch * 2;
@@ -444,11 +451,14 @@ expected_loop_iterations (const struct l
       freq_in = 0;
       freq_latch = 0;
 
-      for (e = loop->header->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, loop->header->preds)
+	{
 	if (e->src == loop->latch)
 	  freq_latch = EDGE_FREQUENCY (e);
 	else
 	  freq_in += EDGE_FREQUENCY (e);
+	}
+      END_FOR_EACH_EDGE;
 
       if (freq_in == 0)
 	return freq_latch * 2;
Index: gcc/cfgloopmanip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloopmanip.c,v
retrieving revision 1.29
diff -u -p -w -r1.29 cfgloopmanip.c
--- gcc/cfgloopmanip.c	7 Sep 2004 15:46:48 -0000	1.29
+++ gcc/cfgloopmanip.c	13 Sep 2004 04:38:54 -0000
@@ -98,7 +98,7 @@ remove_bbs (basic_block *bbs, int nbbs)
 static int
 find_path (edge e, basic_block **bbs)
 {
-  gcc_assert (!e->dest->pred->pred_next);
+  gcc_assert (EDGE_COUNT (e->dest->preds) <= 1);
 
   /* Find bbs in the path.  */
   *bbs = xcalloc (n_basic_blocks, sizeof (basic_block));
@@ -119,7 +119,7 @@ fix_bb_placement (struct loops *loops, b
   edge e;
   struct loop *loop = loops->tree_root, *act;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       if (e->dest == EXIT_BLOCK_PTR)
 	continue;
@@ -131,6 +131,7 @@ fix_bb_placement (struct loops *loops, b
       if (flow_loop_nested_p (loop, act))
 	loop = act;
     }
+  END_FOR_EACH_EDGE;
 
   if (loop == bb->loop_father)
     return false;
@@ -202,7 +203,7 @@ fix_bb_placements (struct loops *loops, 
 	}
 
       /* Something has changed, insert predecessors into queue.  */
-      for (e = from->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, from->preds)
 	{
 	  basic_block pred = e->src;
 	  struct loop *nca;
@@ -234,6 +235,7 @@ fix_bb_placements (struct loops *loops, 
 	    qend = queue;
 	  SET_BIT (in_queue, pred->index);
 	}
+      END_FOR_EACH_EDGE;
     }
   free (in_queue);
   free (queue);
@@ -267,9 +269,12 @@ fix_irreducible_loops (basic_block from)
       bb = stack[--stack_top];
       RESET_BIT (on_stack, bb->index);
 
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (e->flags & EDGE_IRREDUCIBLE_LOOP)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
       if (e)
 	continue;
 
@@ -278,13 +283,14 @@ fix_irreducible_loops (basic_block from)
 	edges = get_loop_exit_edges (bb->loop_father, &n_edges);
       else
 	{
-	  n_edges = 0;
-	  for (e = bb->succ; e; e = e->succ_next)
-	    n_edges++;
+	  n_edges = EDGE_COUNT (bb->succs);
 	  edges = xmalloc (n_edges * sizeof (edge));
-	  n_edges = 0;
-	  for (e = bb->succ; e; e = e->succ_next)
-	    edges[n_edges++] = e;
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
+	      /* FIXME: Don't use private iterator. */
+	      edges[__ix] = e;
+	    }
+	  END_FOR_EACH_EDGE;
 	}
 
       for (i = 0; i < n_edges; i++)
@@ -331,8 +337,8 @@ remove_path (struct loops *loops, edge e
      e, but we only have basic block dominators.  This is easy to
      fix -- when e->dest has exactly one predecessor, this corresponds
      to blocks dominated by e->dest, if not, split the edge.  */
-  if (e->dest->pred->pred_next)
-    e = loop_split_edge_with (e, NULL_RTX)->pred;
+  if (EDGE_COUNT (e->dest->preds) > 1)
+    e = EDGE_PRED (loop_split_edge_with (e, NULL_RTX), 0);
 
   /* It may happen that by removing path we remove one or more loops
      we belong to.  In this case first unloop the loops, then proceed
@@ -357,13 +363,16 @@ remove_path (struct loops *loops, edge e
   for (i = 0; i < nrem; i++)
     {
       bb = rem_bbs[i];
-      for (ae = rem_bbs[i]->succ; ae; ae = ae->succ_next)
+      FOR_EACH_EDGE (ae, rem_bbs[i]->succs)
+	{
 	if (ae->dest != EXIT_BLOCK_PTR && !TEST_BIT (seen, ae->dest->index))
 	  {
 	    SET_BIT (seen, ae->dest->index);
 	    bord_bbs[n_bord_bbs++] = ae->dest;
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Remove the path.  */
   from = e->src;
@@ -461,9 +470,12 @@ scale_bbs_frequencies (basic_block *bbs,
     {
       bbs[i]->frequency = (bbs[i]->frequency * num) / den;
       bbs[i]->count = RDIV (bbs[i]->count * num, den);
-      for (e = bbs[i]->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bbs[i]->succs)
+	{
 	e->count = (e->count * num) /den;
     }
+      END_FOR_EACH_EDGE;
+    }
 }
 
 /* Multiply all frequencies in LOOP by NUM/DEN.  */
@@ -506,8 +518,8 @@ loopify (struct loops *loops, edge latch
 
   freq = EDGE_FREQUENCY (header_edge);
   cnt = header_edge->count;
-  prob = switch_bb->succ->probability;
-  tot_prob = prob + switch_bb->succ->succ_next->probability;
+  prob = EDGE_SUCC (switch_bb, 0)->probability;
+  tot_prob = prob + EDGE_SUCC (switch_bb, 1)->probability;
   if (tot_prob == 0)
     tot_prob = 1;
 
@@ -534,8 +546,11 @@ loopify (struct loops *loops, edge latch
   /* Fix frequencies.  */
   switch_bb->frequency = freq;
   switch_bb->count = cnt;
-  for (e = switch_bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, switch_bb->succs)
+    {
     e->count = (switch_bb->count * e->probability) / REG_BR_PROB_BASE;
+    }
+  END_FOR_EACH_EDGE;
   scale_loop_frequencies (loop, prob, tot_prob);
   scale_loop_frequencies (succ_bb->loop_father, tot_prob - prob, tot_prob);
 
@@ -614,7 +629,7 @@ unloop (struct loops *loops, struct loop
   loops->parray[loop->num] = NULL;
   flow_loop_free (loop);
 
-  remove_edge (latch->succ);
+  remove_edge (EDGE_SUCC (latch, 0));
   fix_bb_placements (loops, latch);
 
   /* If the loop was inside an irreducible region, we would have to somehow
@@ -643,13 +658,16 @@ fix_loop_placement (struct loop *loop)
 
   body = get_loop_body (loop);
   for (i = 0; i < loop->num_nodes; i++)
-    for (e = body[i]->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, body[i]->succs)
+      {
       if (!flow_bb_inside_loop_p (loop, e->dest))
 	{
 	  act = find_common_loop (loop, e->dest->loop_father);
 	  if (flow_loop_nested_p (father, act))
 	    father = act;
 	}
+      }
+    END_FOR_EACH_EDGE;
   free (body);
 
   if (father != loop->outer)
@@ -769,16 +787,16 @@ loop_delete_branch_edge (edge e, int rea
   int irr;
   edge snd;
 
-  gcc_assert (src->succ->succ_next);
+  gcc_assert (EDGE_COUNT (src->succs) > 1);
   
   /* Cannot handle more than two exit edges.  */
-  if (src->succ->succ_next->succ_next)
+  if (EDGE_COUNT (src->succs) > 2)
     return false;
   /* And it must be just a simple branch.  */
   if (!any_condjump_p (BB_END (src)))
     return false;
 
-  snd = e == src->succ ? src->succ->succ_next : src->succ;
+  snd = e == EDGE_SUCC (src, 0) ? EDGE_SUCC (src, 1) : EDGE_SUCC (src, 0);
   newdest = snd->dest;
   if (newdest == EXIT_BLOCK_PTR)
     return false;
@@ -792,8 +810,8 @@ loop_delete_branch_edge (edge e, int rea
 
   if (!redirect_edge_and_branch (e, newdest))
     return false;
-  src->succ->flags &= ~EDGE_IRREDUCIBLE_LOOP;
-  src->succ->flags |= irr;
+  EDGE_SUCC (src, 0)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
+  EDGE_SUCC (src, 0)->flags |= irr;
   
   return true;
 }
@@ -1002,12 +1020,15 @@ duplicate_loop_to_header_edge (struct lo
 	      if (new_bb->loop_father == target)
 		new_bb->flags |= BB_IRREDUCIBLE_LOOP;
 
-	      for (ae = new_bb->succ; ae; ae = ae->succ_next)
+	      FOR_EACH_EDGE (ae, new_bb->succs)
+		{
 		if (ae->dest->rbi->duplicated
 		    && (ae->src->loop_father == target
 			|| ae->dest->loop_father == target))
 		  ae->flags |= EDGE_IRREDUCIBLE_LOOP;
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 	  for (i = 0; i < n; i++)
 	    new_bbs[i]->rbi->duplicated = 0;
 	}
@@ -1106,10 +1127,10 @@ mfb_keep_just (edge e)
 static void
 mfb_update_loops (basic_block jump)
 {
-  struct loop *loop = jump->succ->dest->loop_father;
+  struct loop *loop = EDGE_SUCC (jump, 0)->dest->loop_father;
 
   if (dom_computed[CDI_DOMINATORS])
-    set_immediate_dominator (CDI_DOMINATORS, jump, jump->pred->src);
+    set_immediate_dominator (CDI_DOMINATORS, jump, EDGE_PRED (jump, 0)->src);
   add_bb_to_loop (jump, loop);
   loop->latch = jump;
 }
@@ -1130,19 +1151,25 @@ create_preheader (struct loop *loop, int
 
   cloop = loop->outer;
 
-  for (e = loop->header->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, loop->header->preds)
     {
       if (e->src == loop->latch)
 	continue;
       irred |= (e->flags & EDGE_IRREDUCIBLE_LOOP) != 0;
       nentry++;
     }
+  END_FOR_EACH_EDGE;
+
   gcc_assert (nentry);
   if (nentry == 1)
     {
-      for (e = loop->header->pred; e->src == loop->latch; e = e->pred_next);
-      if (!(flags & CP_SIMPLE_PREHEADERS)
-	  || !e->src->succ->succ_next)
+      FOR_EACH_EDGE (e, loop->header->preds)
+	{
+	  if (e->src != loop->latch)
+	    break;
+	}
+      END_FOR_EACH_EDGE;
+      if (!(flags & CP_SIMPLE_PREHEADERS) || EDGE_COUNT (e->src->succs) == 1)
 	return NULL;
     }
 
@@ -1160,9 +1187,12 @@ create_preheader (struct loop *loop, int
 
   /* Reorganize blocks so that the preheader is not stuck in the middle of the
      loop.  */
-  for (e = dummy->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, dummy->preds)
+    {
     if (e->src != loop->latch)
       break;
+    }
+  END_FOR_EACH_EDGE;
   move_block_after (dummy, e->src);
 
   loop->header->loop_father = loop;
@@ -1171,7 +1201,7 @@ create_preheader (struct loop *loop, int
   if (irred)
     {
       dummy->flags |= BB_IRREDUCIBLE_LOOP;
-      dummy->succ->flags |= EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (dummy, 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
     }
 
   if (dump_file)
@@ -1204,12 +1234,15 @@ force_single_succ_latches (struct loops 
   for (i = 1; i < loops->num; i++)
     {
       loop = loops->parray[i];
-      if (loop->latch != loop->header
-	  && !loop->latch->succ->succ_next)
+      if (loop->latch != loop->header && EDGE_COUNT (loop->latch->succs) == 1)
 	continue;
 
-      for (e = loop->header->pred; e->src != loop->latch; e = e->pred_next)
-	continue;
+      FOR_EACH_EDGE (e, loop->header->preds)
+	{
+	  if (e->src == loop->latch)
+	    break;
+	}
+      END_FOR_EACH_EDGE;
 
       loop_split_edge_with (e, NULL_RTX);
     }
@@ -1238,7 +1271,7 @@ loop_split_edge_with (edge e, rtx insns)
   add_bb_to_loop (new_bb, loop_c);
   new_bb->flags = insns ? BB_SUPERBLOCK : 0;
 
-  new_e = new_bb->succ;
+  new_e = EDGE_SUCC (new_bb, 0);
   if (e->flags & EDGE_IRREDUCIBLE_LOOP)
     {
       new_bb->flags |= BB_IRREDUCIBLE_LOOP;
@@ -1316,9 +1349,9 @@ create_loop_notes (void)
 		      && onlyjump_p (insn))
 		    {
 		      pbb = BLOCK_FOR_INSN (insn);
-		      gcc_assert (pbb && pbb->succ && !pbb->succ->succ_next);
+		      gcc_assert (pbb && EDGE_COUNT (pbb->succs) == 1);
 
-		      if (!flow_bb_inside_loop_p (loop, pbb->succ->dest))
+		      if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (pbb, 0)->dest))
 			insn = BB_HEAD (first[loop->num]);
 		    }
 		  else
Index: gcc/cfgrtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgrtl.c,v
retrieving revision 1.133
diff -u -p -w -r1.133 cfgrtl.c
--- gcc/cfgrtl.c	7 Sep 2004 17:54:16 -0000	1.133
+++ gcc/cfgrtl.c	13 Sep 2004 04:38:55 -0000
@@ -482,10 +482,13 @@ rtl_split_block (basic_block bb, void *i
   BB_END (bb) = insn;
 
   /* Redirect the outgoing edges.  */
-  new_bb->succ = bb->succ;
-  bb->succ = NULL;
-  for (e = new_bb->succ; e; e = e->succ_next)
+  new_bb->succs = bb->succs;
+  bb->succs = NULL;
+  FOR_EACH_EDGE (e, new_bb->succs)
+    {
     e->src = new_bb;
+    }
+  END_FOR_EACH_EDGE;
 
   if (bb->global_live_at_start)
     {
@@ -625,10 +628,12 @@ rtl_can_merge_blocks (basic_block a,basi
     return false;
 
   /* There must be exactly one edge in between the blocks.  */
-  return (a->succ && !a->succ->succ_next && a->succ->dest == b
-	  && !b->pred->pred_next && a != b
+  return (EDGE_COUNT (a->succs) == 1
+	  && EDGE_SUCC (a, 0)->dest == b
+	  && EDGE_COUNT (b->preds) == 1
+	  && a != b
 	  /* Must be simple edge.  */
-	  && !(a->succ->flags & EDGE_COMPLEX)
+	  && !(EDGE_SUCC (a, 0)->flags & EDGE_COMPLEX)
 	  && a->next_bb == b
 	  && a != ENTRY_BLOCK_PTR && b != EXIT_BLOCK_PTR
 	  /* If the jump insn has side effects,
@@ -669,7 +674,6 @@ try_redirect_by_replacing_jump (edge e, 
   rtx set;
   int fallthru = 0;
 
-
   /* If we are partitioning hot/cold basic blocks, we don't want to
      mess up unconditional or indirect jumps that cross between hot
      and cold sections.
@@ -686,9 +690,12 @@ try_redirect_by_replacing_jump (edge e, 
     return NULL;
 
   /* Verify that all targets will be TARGET.  */
-  for (tmp = src->succ; tmp; tmp = tmp->succ_next)
+  FOR_EACH_EDGE (tmp, src->succs)
+    {
     if (tmp->dest != target && tmp != e)
       break;
+    }
+  END_FOR_EACH_EDGE;
 
   if (tmp || !onlyjump_p (insn))
     return NULL;
@@ -814,9 +821,10 @@ try_redirect_by_replacing_jump (edge e, 
     }
 
   /* Keep only one edge out and set proper flags.  */
-  while (src->succ->succ_next)
-    remove_edge (src->succ);
-  e = src->succ;
+  while (EDGE_COUNT (src->succs) > 1)
+    remove_edge (e);
+
+  e = EDGE_SUCC (src, 0);
   if (fallthru)
     e->flags = EDGE_FALLTHRU;
   else
@@ -1042,26 +1050,36 @@ force_nonfallthru_and_redirect (edge e, 
 	  /* We can't redirect the entry block.  Create an empty block
              at the start of the function which we use to add the new
              jump.  */
-	  edge *pe1;
-	  basic_block bb
-	    = create_basic_block (BB_HEAD (e->dest), NULL, ENTRY_BLOCK_PTR);
+	  edge tmp;
+	  unsigned ix;
+	  bool found = false;
+	  
+	  basic_block bb = create_basic_block (BB_HEAD (e->dest), NULL, ENTRY_BLOCK_PTR);
 
 	  /* Change the existing edge's source to be the new block, and add
 	     a new edge from the entry block to the new block.  */
 	  e->src = bb;
-	  for (pe1 = &ENTRY_BLOCK_PTR->succ; *pe1; pe1 = &(*pe1)->succ_next)
-	    if (*pe1 == e)
+	  for (ix = 0; VEC_iterate (edge, ENTRY_BLOCK_PTR->succs, ix, tmp); )
+	    {
+	      if (tmp == e)
 	      {
-		*pe1 = e->succ_next;
+		  VEC_unordered_remove (edge, ENTRY_BLOCK_PTR->succs, ix);
+		  found = true;
 		break;
 	      }
-	  e->succ_next = 0;
-	  bb->succ = e;
+	      else
+		ix++;
+	    }
+	  
+	  if (!found)
+	    abort ();
+	  
+	  VEC_safe_push (edge, bb->succs, e);
 	  make_single_succ_edge (ENTRY_BLOCK_PTR, bb, EDGE_FALLTHRU);
 	}
     }
 
-  if (e->src->succ->succ_next || abnormal_edge_flags)
+  if (EDGE_COUNT (e->src->succs) >= 2 || abnormal_edge_flags)
     {
       /* Create the new structures.  */
 
@@ -1113,7 +1131,7 @@ force_nonfallthru_and_redirect (edge e, 
 	    }
 	  if (JUMP_P (BB_END (jump_block))
 	      && !any_condjump_p (BB_END (jump_block))
-	      && (jump_block->succ->flags & EDGE_CROSSING))
+	      && (EDGE_SUCC (jump_block, 0)->flags & EDGE_CROSSING))
 	    REG_NOTES (BB_END (jump_block)) = gen_rtx_EXPR_LIST 
 	      (REG_CROSSING_JUMP, NULL_RTX, 
 	       REG_NOTES (BB_END (jump_block)));
@@ -1193,6 +1211,15 @@ rtl_tidy_fallthru_edge (edge e)
 {
   rtx q;
   basic_block b = e->src, c = b->next_bb;
+  edge e2;
+  unsigned ix;
+
+  for (ix = 0; ix < EDGE_COUNT (b->succs); ix++)
+    {
+      e2 = EDGE_I (b->succs, ix);
+      if (e == e2)
+	break;
+    }
 
   /* ??? In a late-running flow pass, other folks may have deleted basic
      blocks by nopping out blocks, leaving multiple BARRIERs between here
@@ -1215,7 +1242,8 @@ rtl_tidy_fallthru_edge (edge e)
   if (JUMP_P (q)
       && onlyjump_p (q)
       && (any_uncondjump_p (q)
-	  || (b->succ == e && e->succ_next == NULL)))
+	  /* FIXME: correct? */
+	  || (EDGE_SUCC (b, 0) == e && ix == EDGE_COUNT (b->succs) - 1)))
     {
 #ifdef HAVE_cc0
       /* If this was a conditional jump, we need to also delete
@@ -1304,9 +1332,12 @@ rtl_split_edge (edge edge_in)
     {
       edge e;
 
-      for (e = edge_in->dest->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, edge_in->dest->preds)
+	{
 	if (e->flags & EDGE_FALLTHRU)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
 
       if (e)
 	force_nonfallthru (e);
@@ -1518,7 +1549,8 @@ commit_one_edge_insertion (edge e, int w
 
   /* Special case -- avoid inserting code between call and storing
      its return value.  */
-  if (watch_calls && (e->flags & EDGE_FALLTHRU) && !e->dest->pred->pred_next
+  if (watch_calls && (e->flags & EDGE_FALLTHRU)
+      && EDGE_COUNT (e->dest->preds) == 1
       && e->src != ENTRY_BLOCK_PTR
       && CALL_P (BB_END (e->src)))
     {
@@ -1538,7 +1570,7 @@ commit_one_edge_insertion (edge e, int w
     {
       /* Figure out where to put these things.  If the destination has
          one predecessor, insert there.  Except for the exit block.  */
-      if (e->dest->pred->pred_next == NULL && e->dest != EXIT_BLOCK_PTR)
+      if (EDGE_COUNT (e->dest->preds) == 1 && e->dest != EXIT_BLOCK_PTR)
 	{
 	  bb = e->dest;
 
@@ -1564,7 +1596,7 @@ commit_one_edge_insertion (edge e, int w
       /* If the source has one successor and the edge is not abnormal,
          insert there.  Except for the entry block.  */
       else if ((e->flags & EDGE_ABNORMAL) == 0
-	       && e->src->succ->succ_next == NULL
+	       && EDGE_COUNT (e->src->succs) == 1
 	       && e->src != ENTRY_BLOCK_PTR)
 	{
 	  bb = e->src;
@@ -1619,7 +1651,7 @@ commit_one_edge_insertion (edge e, int w
 	      NOTE_BASIC_BLOCK (new_note) = bb;
 	      if (JUMP_P (BB_END (bb))
 		  && !any_condjump_p (BB_END (bb))
-		  && (bb->succ->flags & EDGE_CROSSING))
+  		  && (EDGE_SUCC (bb, 0)->flags & EDGE_CROSSING))
 		REG_NOTES (BB_END (bb)) = gen_rtx_EXPR_LIST 
 		  (REG_CROSSING_JUMP, NULL_RTX, REG_NOTES (BB_END (bb)));
 	      if (after == bb_note)
@@ -1645,9 +1677,9 @@ commit_one_edge_insertion (edge e, int w
          for the (single) epilogue, which already has a fallthru edge
          to EXIT.  */
 
-      e = bb->succ;
+      e = EDGE_SUCC (bb, 0);
       gcc_assert (e->dest == EXIT_BLOCK_PTR
-		  && !e->succ_next && (e->flags & EDGE_FALLTHRU));
+		  && EDGE_COUNT (bb->succs) == 1 && (e->flags & EDGE_FALLTHRU));
 
       e->flags &= ~EDGE_FALLTHRU;
       emit_barrier_after (last);
@@ -1677,17 +1709,17 @@ commit_edge_insertions (void)
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
-      edge e, next;
+      edge e;
 
-      for (e = bb->succ; e; e = next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
-	  next = e->succ_next;
 	  if (e->insns.r)
 	    {
 	      changed = true;
 	      commit_one_edge_insertion (e, false);
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   if (!changed)
@@ -1724,17 +1756,17 @@ commit_edge_insertions_watch_calls (void
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
-      edge e, next;
+      edge e;
 
-      for (e = bb->succ; e; e = next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
-	  next = e->succ_next;
 	  if (e->insns.r)
 	    {
 	      changed = true;
 	      commit_one_edge_insertion (e, true);
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   if (!changed)
@@ -1966,7 +1998,7 @@ rtl_verify_flow_info_1 (void)
 
       if (INSN_P (BB_END (bb))
 	  && (note = find_reg_note (BB_END (bb), REG_BR_PROB, NULL_RTX))
-	  && bb->succ && bb->succ->succ_next
+	  && EDGE_COUNT (bb->succs) >= 2
 	  && any_condjump_p (BB_END (bb)))
 	{
 	  if (INTVAL (XEXP (note, 0)) != BRANCH_EDGE (bb)->probability)
@@ -1976,7 +2008,7 @@ rtl_verify_flow_info_1 (void)
 	      err = 1;
 	    }
 	}
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (e->flags & EDGE_FALLTHRU)
 	    {
@@ -2007,6 +2039,7 @@ rtl_verify_flow_info_1 (void)
 	  else if (e->flags & EDGE_ABNORMAL)
 	    n_abnormal++;
 	}
+      END_FOR_EACH_EDGE;
 
       if (n_eh && GET_CODE (PATTERN (BB_END (bb))) != RESX
 	  && !find_reg_note (BB_END (bb), REG_EH_REGION, NULL_RTX))
@@ -2143,9 +2176,12 @@ rtl_verify_flow_info (void)
   FOR_EACH_BB_REVERSE (bb)
     {
       edge e;
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (e->flags & EDGE_FALLTHRU)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
       if (!e)
 	{
 	  rtx insn;
@@ -2257,9 +2293,11 @@ rtl_verify_flow_info (void)
 bool
 purge_dead_edges (basic_block bb)
 {
-  edge e, next;
+  edge e;
+  unsigned ix;
   rtx insn = BB_END (bb), note;
   bool purged = false;
+  bool found;
 
   /* If this instruction cannot trap, remove REG_EH_REGION notes.  */
   if (NONJUMP_INSN_P (insn)
@@ -2274,23 +2312,31 @@ purge_dead_edges (basic_block bb)
     }
 
   /* Cleanup abnormal edges caused by exceptions or non-local gotos.  */
-  for (e = bb->succ; e; e = next)
+  for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
     {
-      next = e->succ_next;
       if (e->flags & EDGE_EH)
 	{
 	  if (can_throw_internal (BB_END (bb)))
+	    {
+	      ix++;
 	    continue;
 	}
+	}
       else if (e->flags & EDGE_ABNORMAL_CALL)
 	{
 	  if (CALL_P (BB_END (bb))
 	      && (! (note = find_reg_note (insn, REG_EH_REGION, NULL))
 		  || INTVAL (XEXP (note, 0)) >= 0))
+	    {
+	      ix++;
 	    continue;
 	}
+	}
       else
+	{
+	  ix++;
 	continue;
+	}
 
       remove_edge (e);
       bb->flags |= BB_DIRTY;
@@ -2301,6 +2347,7 @@ purge_dead_edges (basic_block bb)
     {
       rtx note;
       edge b,f;
+      unsigned ix;
 
       /* We do care only about conditional jumps and simplejumps.  */
       if (!any_condjump_p (insn)
@@ -2319,10 +2366,8 @@ purge_dead_edges (basic_block bb)
 	    remove_note (insn, note);
 	}
 
-      for (e = bb->succ; e; e = next)
+      for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
 	{
-	  next = e->succ_next;
-
 	  /* Avoid abnormal flags to leak from computed jumps turned
 	     into simplejumps.  */
 
@@ -2332,22 +2377,32 @@ purge_dead_edges (basic_block bb)
 	  if ((e->flags & EDGE_FALLTHRU) && any_condjump_p (insn))
 	    /* A conditional jump can fall through into the next
 	       block, so we should keep the edge.  */
+	    {
+	      ix++;
 	    continue;
+	    }
 	  else if (e->dest != EXIT_BLOCK_PTR
 		   && BB_HEAD (e->dest) == JUMP_LABEL (insn))
 	    /* If the destination block is the target of the jump,
 	       keep the edge.  */
+	    {
+	      ix++;
 	    continue;
+	    }
 	  else if (e->dest == EXIT_BLOCK_PTR && returnjump_p (insn))
 	    /* If the destination block is the exit block, and this
 	       instruction is a return, then keep the edge.  */
+	    {
+	      ix++;
 	    continue;
+	    }
 	  else if ((e->flags & EDGE_EH) && can_throw_internal (insn))
 	    /* Keep the edges that correspond to exceptions thrown by
 	       this instruction and rematerialize the EDGE_ABNORMAL
 	       flag we just cleared above.  */
 	    {
 	      e->flags |= EDGE_ABNORMAL;
+	      ix++;
 	      continue;
 	    }
 
@@ -2357,7 +2412,7 @@ purge_dead_edges (basic_block bb)
 	  remove_edge (e);
 	}
 
-      if (!bb->succ || !purged)
+      if (EDGE_COUNT (bb->succs) == 0 || !purged)
 	return purged;
 
       if (dump_file)
@@ -2367,10 +2422,10 @@ purge_dead_edges (basic_block bb)
 	return purged;
 
       /* Redistribute probabilities.  */
-      if (!bb->succ->succ_next)
+      if (EDGE_COUNT (bb->succs) == 1)
 	{
-	  bb->succ->probability = REG_BR_PROB_BASE;
-	  bb->succ->count = bb->count;
+	  EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE;
+	  EDGE_SUCC (bb, 0)->count = bb->count;
 	}
       else
 	{
@@ -2394,8 +2449,8 @@ purge_dead_edges (basic_block bb)
 	 from non-local gotos and the like.  If there were, we shouldn't
 	 have created the sibcall in the first place.  Second, there
 	 should of course never have been a fallthru edge.  */
-      gcc_assert (bb->succ && !bb->succ->succ_next);
-      gcc_assert (bb->succ->flags == (EDGE_SIBCALL | EDGE_ABNORMAL));
+      gcc_assert (EDGE_COUNT (bb->succs) == 1);
+      gcc_assert (EDGE_SUCC (bb, 0)->flags == (EDGE_SIBCALL | EDGE_ABNORMAL));
 
       return 0;
     }
@@ -2405,28 +2460,36 @@ purge_dead_edges (basic_block bb)
      as these are only created by conditional branches.  If we find such an
      edge we know that there used to be a jump here and can then safely
      remove all non-fallthru edges.  */
-  for (e = bb->succ; e && (e->flags & (EDGE_COMPLEX | EDGE_FALLTHRU));
-       e = e->succ_next)
-    ;
+  found = false;
+  FOR_EACH_EDGE (e, bb->succs)
+    {
+      if (! (e->flags & (EDGE_COMPLEX | EDGE_FALLTHRU)))
+	{
+	  found = true;
+	  break;
+	}
+    }
+  END_FOR_EACH_EDGE;
 
-  if (!e)
+  if (!found)
     return purged;
 
-  for (e = bb->succ; e; e = next)
+  for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
     {
-      next = e->succ_next;
       if (!(e->flags & EDGE_FALLTHRU))
 	{
 	  bb->flags |= BB_DIRTY;
 	  remove_edge (e);
 	  purged = true;
 	}
+      else
+	ix++;
     }
 
-  gcc_assert (bb->succ && !bb->succ->succ_next);
+  gcc_assert (EDGE_COUNT (bb->succs) == 1);
 
-  bb->succ->probability = REG_BR_PROB_BASE;
-  bb->succ->count = bb->count;
+  EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE;
+  EDGE_SUCC (bb, 0)->count = bb->count;
 
   if (dump_file)
     fprintf (dump_file, "Purged non-fallthru edges from bb %i\n",
@@ -2542,10 +2605,31 @@ cfg_layout_redirect_edge_and_branch (edg
 	}
       /* In case we are redirecting fallthru edge to the branch edge
          of conditional jump, remove it.  */
-      if (src->succ->succ_next
-	  && !src->succ->succ_next->succ_next)
+      if (EDGE_COUNT (src->succs) == 2)
+	{
+	  bool found = false;
+	  unsigned ix = 0;
+	  edge tmp, s;
+
+	  FOR_EACH_EDGE (tmp, src->succs)
+	    {
+	      if (e == tmp)
 	{
-	  edge s = e->succ_next ? e->succ_next : src->succ;
+		  found = true;
+		  ix = __ix;
+		  break;
+		}
+	    }
+	  END_FOR_EACH_EDGE;
+
+	  if (!found)
+	    abort ();
+
+	  if (EDGE_COUNT (src->succs) > (ix + 1))
+	    s = EDGE_SUCC (src, ix + 1);
+	  else
+	    s = EDGE_SUCC (src, 0);
+
 	  if (s->dest == dest
 	      && any_condjump_p (BB_END (src))
 	      && onlyjump_p (BB_END (src)))
@@ -2679,10 +2763,12 @@ cfg_layout_can_merge_blocks_p (basic_blo
     return false;
 
   /* There must be exactly one edge in between the blocks.  */
-  return (a->succ && !a->succ->succ_next && a->succ->dest == b
-	  && !b->pred->pred_next && a != b
+  return (EDGE_COUNT (a->succs) == 1
+	  && EDGE_SUCC (a, 0)->dest == b
+	  && EDGE_COUNT (b->preds) == 1
+	  && a != b
 	  /* Must be simple edge.  */
-	  && !(a->succ->flags & EDGE_COMPLEX)
+	  && !(EDGE_SUCC (a, 0)->flags & EDGE_COMPLEX)
 	  && a != ENTRY_BLOCK_PTR && b != EXIT_BLOCK_PTR
 	  /* If the jump insn has side effects,
 	     we can't kill the edge.  */
@@ -2706,7 +2792,7 @@ cfg_layout_merge_blocks (basic_block a, 
   /* We should have fallthru edge in a, or we can do dummy redirection to get
      it cleaned up.  */
   if (JUMP_P (BB_END (a)))
-    try_redirect_by_replacing_jump (a->succ, b, true);
+    try_redirect_by_replacing_jump (EDGE_SUCC (a, 0), b, true);
   gcc_assert (!JUMP_P (BB_END (a)));
 
   /* Possible line number notes should appear in between.  */
@@ -2906,7 +2992,8 @@ rtl_flow_call_edges_add (sbitmap blocks)
 	{
 	  edge e;
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->dest == EXIT_BLOCK_PTR)
 	      {
 		insert_insn_on_edge (gen_rtx_USE (VOIDmode, const0_rtx), e);
@@ -2914,6 +3001,8 @@ rtl_flow_call_edges_add (sbitmap blocks)
 		break;
 	      }
 	}
+	  END_FOR_EACH_EDGE;
+	}
     }
 
   /* Now add fake edges to the function exit for any non constant
@@ -2954,8 +3043,11 @@ rtl_flow_call_edges_add (sbitmap blocks)
 
 #ifdef ENABLE_CHECKING
 	      if (split_at_insn == BB_END (bb))
-		for (e = bb->succ; e; e = e->succ_next)
+		FOR_EACH_EDGE (e, bb->succs)
+		  {
 		  gcc_assert (e->dest != EXIT_BLOCK_PTR);
+		  }
+	        END_FOR_EACH_EDGE;
 #endif
 
 	      /* Note that the following may create a new basic block
Index: gcc/cse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cse.c,v
retrieving revision 1.313
diff -u -p -w -r1.313 cse.c
--- gcc/cse.c	7 Sep 2004 20:59:18 -0000	1.313
+++ gcc/cse.c	13 Sep 2004 04:38:59 -0000
@@ -7401,7 +7401,7 @@ cse_cc_succs (basic_block bb, rtx cc_reg
   found_equiv = false;
   mode = GET_MODE (cc_src);
   insn_count = 0;
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       rtx insn;
       rtx end;
@@ -7409,8 +7409,7 @@ cse_cc_succs (basic_block bb, rtx cc_reg
       if (e->flags & EDGE_COMPLEX)
 	continue;
 
-      if (! e->dest->pred
-	  || e->dest->pred->pred_next
+      if (EDGE_COUNT (e->dest->preds) != 1
 	  || e->dest == EXIT_BLOCK_PTR)
 	continue;
 
@@ -7523,6 +7522,7 @@ cse_cc_succs (basic_block bb, rtx cc_reg
 	    }
 	}
     }
+  END_FOR_EACH_EDGE;
 
   if (! found_equiv)
     return VOIDmode;
Index: gcc/df.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/df.c,v
retrieving revision 1.71
diff -u -p -w -r1.71 df.c
--- gcc/df.c	8 Sep 2004 07:47:44 -0000	1.71
+++ gcc/df.c	13 Sep 2004 04:39:00 -0000
@@ -3794,13 +3794,13 @@ hybrid_search (basic_block bb, struct da
   gcc_assert (TEST_BIT (pending, bb->index));
   RESET_BIT (pending, i);
 
-#define HS(E_ANTI, E_ANTI_NEXT, E_ANTI_BB, E_ANTI_START_BB, IN_SET,	\
-	   E, E_NEXT, E_BB, E_START_BB, OUT_SET)			\
+#define HS(E_ANTI, E_ANTI_BB, E_ANTI_START_BB, IN_SET,			\
+	   E, E_BB, E_START_BB, OUT_SET)				\
   do									\
     {									\
       /*  Calculate <conf_op> of predecessor_outs.  */			\
       bitmap_zero (IN_SET[i]);						\
-      for (e = bb->E_ANTI; e; e = e->E_ANTI_NEXT)			\
+      FOR_EACH_EDGE (e, bb->E_ANTI)					\
 	{								\
 	  if (e->E_ANTI_BB == E_ANTI_START_BB)				\
 	    continue;							\
@@ -3811,7 +3811,7 @@ hybrid_search (basic_block bb, struct da
 			       IN_SET[i], IN_SET[i],			\
 			       OUT_SET[e->E_ANTI_BB->index]);		\
 	}								\
-									\
+      END_FOR_EACH_EDGE;						\
       (*dataflow->transfun)(i, &changed,				\
 			    dataflow->in[i], dataflow->out[i],		\
 			    dataflow->gen[i], dataflow->kill[i],	\
@@ -3820,7 +3820,7 @@ hybrid_search (basic_block bb, struct da
       if (!changed)							\
 	break;								\
 									\
-      for (e = bb->E; e; e = e->E_NEXT)					\
+      FOR_EACH_EDGE (e, bb->E)						\
 	{								\
 	  if (e->E_BB == E_START_BB || e->E_BB->index == i)		\
 	    continue;							\
@@ -3830,8 +3830,9 @@ hybrid_search (basic_block bb, struct da
 									\
 	  SET_BIT (pending, e->E_BB->index);				\
       	}								\
+      END_FOR_EACH_EDGE;						\
 									\
-      for (e = bb->E; e; e = e->E_NEXT)					\
+      FOR_EACH_EDGE (e, bb->E)						\
 	{								\
 	  if (e->E_BB == E_START_BB || e->E_BB->index == i)		\
 	    continue;							\
@@ -3842,14 +3843,15 @@ hybrid_search (basic_block bb, struct da
 	  if (!TEST_BIT (visited, e->E_BB->index))			\
 	    hybrid_search (e->E_BB, dataflow, visited, pending, considered); \
 	}								\
+      END_FOR_EACH_EDGE;						\
     } while (0)
 
   if (dataflow->dir == DF_FORWARD)
-    HS (pred, pred_next, src, ENTRY_BLOCK_PTR, dataflow->in,
-	succ, succ_next, dest, EXIT_BLOCK_PTR, dataflow->out);
+    HS (preds, src, ENTRY_BLOCK_PTR, dataflow->in,
+	succs, dest, EXIT_BLOCK_PTR, dataflow->out);
   else
-    HS (succ, succ_next, dest, EXIT_BLOCK_PTR, dataflow->out,
-	pred, pred_next, src, ENTRY_BLOCK_PTR, dataflow->in);
+    HS (succs, dest, EXIT_BLOCK_PTR, dataflow->out,
+	preds, src, ENTRY_BLOCK_PTR, dataflow->in);
 }
 
 /* This function will perform iterative bitvector dataflow described by
Index: gcc/dominance.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dominance.c,v
retrieving revision 1.27
diff -u -p -w -r1.27 dominance.c
--- gcc/dominance.c	8 Sep 2004 07:47:45 -0000	1.27
+++ gcc/dominance.c	13 Sep 2004 04:39:01 -0000
@@ -205,31 +205,35 @@ calc_dfs_tree_nonrec (struct dom_info *d
 {
   /* We call this _only_ if bb is not already visited.  */
   edge e;
+  VEC(edge) *ev;
+  VEC(edge) *ev_next;
   TBB child_i, my_i = 0;
-  edge *stack;
+  struct edge_stack *stack;
   int sp;
   /* Start block (ENTRY_BLOCK_PTR for forward problem, EXIT_BLOCK for backward
      problem).  */
   basic_block en_block;
   /* Ending block.  */
   basic_block ex_block;
+  unsigned ix, ix_next;
 
-  stack = xmalloc ((n_basic_blocks + 3) * sizeof (edge));
+  stack = xmalloc ((n_basic_blocks + 3) * sizeof (struct edge_stack));
   sp = 0;
 
   /* Initialize our border blocks, and the first edge.  */
   if (reverse)
     {
-      e = bb->pred;
+      ev = bb->preds;
       en_block = EXIT_BLOCK_PTR;
       ex_block = ENTRY_BLOCK_PTR;
     }
   else
     {
-      e = bb->succ;
+      ev = bb->succs;
       en_block = ENTRY_BLOCK_PTR;
       ex_block = EXIT_BLOCK_PTR;
     }
+  ix = 0;
 
   /* When the stack is empty we break out of this loop.  */
   while (1)
@@ -238,9 +242,9 @@ calc_dfs_tree_nonrec (struct dom_info *d
 
       /* This loop traverses edges e in depth first manner, and fills the
          stack.  */
-      while (e)
+      while (ix < EDGE_COUNT (ev))
 	{
-	  edge e_next;
+	  e = EDGE_I (ev, ix);
 
 	  /* Deduce from E the current and the next block (BB and BN), and the
 	     next edge.  */
@@ -253,22 +257,24 @@ calc_dfs_tree_nonrec (struct dom_info *d
 	         with the next edge out of the current node.  */
 	      if (bn == ex_block || di->dfs_order[bn->index])
 		{
-		  e = e->pred_next;
+		  ix++;
 		  continue;
 		}
 	      bb = e->dest;
-	      e_next = bn->pred;
+	      ix_next = 0;
+	      ev_next = bn->preds;
 	    }
 	  else
 	    {
 	      bn = e->dest;
 	      if (bn == ex_block || di->dfs_order[bn->index])
 		{
-		  e = e->succ_next;
+		  ix++;
 		  continue;
 		}
 	      bb = e->src;
-	      e_next = bn->succ;
+	      ix_next = 0;
+	      ev_next = bn->succs;
 	    }
 
 	  gcc_assert (bn != en_block);
@@ -283,13 +289,17 @@ calc_dfs_tree_nonrec (struct dom_info *d
 	  di->dfs_parent[child_i] = my_i;
 
 	  /* Save the current point in the CFG on the stack, and recurse.  */
-	  stack[sp++] = e;
-	  e = e_next;
+	  stack[sp].ev = ev;
+	  stack[sp++].ix = ix;
+
+	  ev = ev_next;
+	  ix = ix_next;
 	}
 
       if (!sp)
 	break;
-      e = stack[--sp];
+      ev = stack[--sp].ev;
+      ix = stack[sp].ix;
 
       /* OK.  The edge-list was exhausted, meaning normally we would
          end the recursion.  After returning from the recursive call,
@@ -300,10 +310,7 @@ calc_dfs_tree_nonrec (struct dom_info *d
          the block not yet completed (the parent of the one above)
          in e->src.  This could be used e.g. for computing the number of
          descendants or the tree depth.  */
-      if (reverse)
-	e = e->pred_next;
-      else
-	e = e->succ_next;
+      ix++;
     }
   free (stack);
 }
@@ -341,7 +348,7 @@ calc_dfs_tree (struct dom_info *di, enum
 
       FOR_EACH_BB_REVERSE (b)
 	{
-	  if (b->succ)
+	  if (EDGE_COUNT (b->succs) > 0)
 	    {
 	      if (di->dfs_order[b->index] == 0)
 		saw_unconnected = true;
@@ -478,6 +485,9 @@ calc_idoms (struct dom_info *di, enum cd
 {
   TBB v, w, k, par;
   basic_block en_block;
+  VEC(edge) *ev;
+  unsigned ix, ix_next;
+
   if (reverse)
     en_block = EXIT_BLOCK_PTR;
   else
@@ -488,43 +498,37 @@ calc_idoms (struct dom_info *di, enum cd
   while (v > 1)
     {
       basic_block bb = di->dfs_to_bb[v];
-      edge e, e_next;
+      edge e;
 
       par = di->dfs_parent[v];
       k = v;
+
+      ev = (reverse) ? bb->succs : bb->preds;
+      ix = 0;
+
       if (reverse)
 	{
-	  e = bb->succ;
-
 	  /* If this block has a fake edge to exit, process that first.  */
 	  if (bitmap_bit_p (di->fake_exit_edge, bb->index))
 	    {
-	      e_next = e;
+	      ix_next = 0;
 	      goto do_fake_exit_edge;
 	    }
 	}
-      else
-	e = bb->pred;
 
       /* Search all direct predecessors for the smallest node with a path
          to them.  That way we have the smallest node with also a path to
          us only over nodes behind us.  In effect we search for our
          semidominator.  */
-      for (; e ; e = e_next)
+      while (ix < EDGE_COUNT (ev))
 	{
 	  TBB k1;
 	  basic_block b;
 
-	  if (reverse)
-	    {
-	      b = e->dest;
-	      e_next = e->succ_next;
-	    }
-	  else
-	    {
-	      b = e->src;
-	      e_next = e->pred_next;
-	    }
+	  e = EDGE_I (ev, ix);
+	  b = (reverse) ? e->dest : e->src;
+	  ix_next = ix + 1;
+
 	  if (b == en_block)
 	    {
 	    do_fake_exit_edge:
@@ -539,6 +543,8 @@ calc_idoms (struct dom_info *di, enum cd
 	    k1 = di->key[eval (di, k1)];
 	  if (k1 < k)
 	    k = k1;
+
+	  ix = ix_next;
 	}
 
       di->key[v] = k;
@@ -844,7 +850,7 @@ recount_dominator (enum cdi_direction di
 
   if (dir == CDI_DOMINATORS)
     {
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  /* Ignore the predecessors that either are not reachable from
 	     the entry block, or whose dominator was not determined yet.  */
@@ -854,14 +860,16 @@ recount_dominator (enum cdi_direction di
 	  if (!dominated_by_p (dir, e->src, bb))
 	    dom_bb = nearest_common_dominator (dir, dom_bb, e->src);
 	}
+      END_FOR_EACH_EDGE;
     }
   else
     {
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (!dominated_by_p (dir, e->dest, bb))
 	    dom_bb = nearest_common_dominator (dir, dom_bb, e->dest);
 	}
+      END_FOR_EACH_EDGE;
     }
 
   return dom_bb;
Index: gcc/domwalk.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/domwalk.c,v
retrieving revision 2.1
diff -u -p -w -r2.1 domwalk.c
--- gcc/domwalk.c	13 May 2004 06:39:37 -0000	2.1
+++ gcc/domwalk.c	13 Sep 2004 04:39:01 -0000
@@ -201,7 +201,7 @@ walk_dominator_tree (struct dom_walk_dat
     {
       /* The destination block may have become unreachable, in
 	 which case there's no point in optimizing it.  */
-      if (dest->pred)
+      if (EDGE_COUNT (dest->preds) > 0)
 	walk_dominator_tree (walk_data, dest);
     }
 
Index: gcc/except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/except.c,v
retrieving revision 1.287
diff -u -p -w -r1.287 except.c
--- gcc/except.c	12 Sep 2004 17:22:03 -0000	1.287
+++ gcc/except.c	13 Sep 2004 04:39:02 -0000
@@ -1449,13 +1449,18 @@ emit_to_new_bb_before (rtx seq, rtx insn
   rtx last;
   basic_block bb;
   edge e;
+  unsigned ix;
 
   /* If there happens to be an fallthru edge (possibly created by cleanup_cfg
      call), we don't want it to go into newly created landing pad or other EH 
      construct.  */
-  for (e = BLOCK_FOR_INSN (insn)->pred; e; e = e->pred_next)
+  for (ix = 0; VEC_iterate (edge, BLOCK_FOR_INSN (insn)->preds, ix, e); )
+    {
     if (e->flags & EDGE_FALLTHRU)
       force_nonfallthru (e);
+      else
+	ix++;
+    }
   last = emit_insn_before (seq, insn);
   if (BARRIER_P (last))
     last = PREV_INSN (last);
@@ -1623,8 +1628,8 @@ connect_post_landing_pads (void)
 	  emit_jump (outer->post_landing_pad);
 	  src = BLOCK_FOR_INSN (region->resume);
 	  dest = BLOCK_FOR_INSN (outer->post_landing_pad);
-	  while (src->succ)
-	    remove_edge (src->succ);
+	  while (EDGE_COUNT (src->succs) > 0)
+	    remove_edge (EDGE_SUCC (src, 0));
 	  e = make_edge (src, dest, 0);
 	  e->probability = REG_BR_PROB_BASE;
 	  e->count = src->count;
@@ -1991,10 +1996,10 @@ sjlj_emit_function_enter (rtx dispatch_l
 	    || NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_BASIC_BLOCK))
       break;
   if (NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG)
-    insert_insn_on_edge (seq, ENTRY_BLOCK_PTR->succ);
+    insert_insn_on_edge (seq, EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
   else
     {
-      rtx last = BB_END (ENTRY_BLOCK_PTR->succ->dest);
+      rtx last = BB_END (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest);
       for (; ; fn_begin = NEXT_INSN (fn_begin))
 	if ((NOTE_P (fn_begin)
 	     && NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG)
@@ -2031,9 +2036,12 @@ sjlj_emit_function_exit (void)
      post-dominates all can_throw_internal instructions.  This is
      the last possible moment.  */
 
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     if (e->flags & EDGE_FALLTHRU)
       break;
+    }
+  END_FOR_EACH_EDGE;
   if (e)
     {
       rtx insn;
@@ -2198,16 +2206,19 @@ finish_eh_generation (void)
     commit_edge_insertions ();
   FOR_EACH_BB (bb)
     {
-      edge e, next;
+      edge e;
       bool eh = false;
-      for (e = bb->succ; e; e = next)
+      unsigned ix;
+
+      for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
 	{
-	  next = e->succ_next;
 	  if (e->flags & EDGE_EH)
 	    {
 	      remove_edge (e);
 	      eh = true;
 	    }
+	  else
+	    ix++;
 	}
       if (eh)
 	rtl_make_eh_edge (NULL, bb, BB_END (bb));
Index: gcc/final.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/final.c,v
retrieving revision 1.337
diff -u -p -w -r1.337 final.c
--- gcc/final.c	11 Sep 2004 01:54:14 -0000	1.337
+++ gcc/final.c	13 Sep 2004 04:39:03 -0000
@@ -684,13 +684,14 @@ compute_alignments (void)
       max_log = LABEL_ALIGN (label);
       max_skip = LABEL_ALIGN_MAX_SKIP;
 
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  if (e->flags & EDGE_FALLTHRU)
 	    has_fallthru = 1, fallthru_frequency += EDGE_FREQUENCY (e);
 	  else
 	    branch_frequency += EDGE_FREQUENCY (e);
 	}
+      END_FOR_EACH_EDGE;
 
       /* There are two purposes to align block with no fallthru incoming edge:
 	 1) to avoid fetch stalls when branch destination is near cache boundary
Index: gcc/flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.597
diff -u -p -w -r1.597 flow.c
--- gcc/flow.c	8 Sep 2004 15:44:44 -0000	1.597
+++ gcc/flow.c	13 Sep 2004 04:39:05 -0000
@@ -1100,8 +1100,8 @@ calculate_global_regs_live (sbitmap bloc
       /* Begin by propagating live_at_start from the successor blocks.  */
       CLEAR_REG_SET (new_live_at_end);
 
-      if (bb->succ)
-	for (e = bb->succ; e; e = e->succ_next)
+      if (EDGE_COUNT (bb->succs) > 0)
+	FOR_EACH_EDGE (e, bb->succs)
 	  {
 	    basic_block sb = e->dest;
 
@@ -1125,6 +1125,7 @@ calculate_global_regs_live (sbitmap bloc
 		if (EH_USES (i))
 		  SET_REGNO_REG_SET (new_live_at_end, i);
 	  }
+        END_FOR_EACH_EDGE;
       else
 	{
 	  /* This might be a noreturn function that throws.  And
@@ -1257,7 +1258,7 @@ calculate_global_regs_live (sbitmap bloc
 
       /* Queue all predecessors of BB so that we may re-examine
 	 their live_at_end.  */
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  basic_block pb = e->src;
 	  if (pb->aux == NULL)
@@ -1268,6 +1269,7 @@ calculate_global_regs_live (sbitmap bloc
 	      pb->aux = pb;
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   FREE_REG_SET (tmp);
@@ -1363,7 +1365,7 @@ initialize_uninitialized_subregs (void)
   int reg, did_something = 0;
   find_regno_partial_param param;
 
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
     {
       basic_block bb = e->dest;
       regset map = bb->global_live_at_start;
@@ -1398,6 +1400,7 @@ initialize_uninitialized_subregs (void)
 	    }
 	});
     }
+  END_FOR_EACH_EDGE;
 
   if (did_something)
     commit_edge_insertions ();
@@ -1827,19 +1830,19 @@ init_propagate_block_info (basic_block b
       int i;
 
       /* Identify the successor blocks.  */
-      bb_true = bb->succ->dest;
-      if (bb->succ->succ_next != NULL)
+      bb_true = EDGE_SUCC (bb, 0)->dest;
+      if (EDGE_COUNT (bb->succs) > 1)
 	{
-	  bb_false = bb->succ->succ_next->dest;
+	  bb_false = EDGE_SUCC (bb, 1)->dest;
 
-	  if (bb->succ->flags & EDGE_FALLTHRU)
+	  if (EDGE_SUCC (bb, 0)->flags & EDGE_FALLTHRU)
 	    {
 	      basic_block t = bb_false;
 	      bb_false = bb_true;
 	      bb_true = t;
 	    }
 	  else
-	    gcc_assert (bb->succ->succ_next->flags & EDGE_FALLTHRU);
+	    gcc_assert (EDGE_SUCC (bb, 1)->flags & EDGE_FALLTHRU);
 	}
       else
 	{
@@ -1921,9 +1924,9 @@ init_propagate_block_info (basic_block b
 	    && (TYPE_RETURNS_STACK_DEPRESSED
 		(TREE_TYPE (current_function_decl))))
       && (flags & PROP_SCAN_DEAD_STORES)
-      && (bb->succ == NULL
-	  || (bb->succ->succ_next == NULL
-	      && bb->succ->dest == EXIT_BLOCK_PTR
+      && (EDGE_COUNT (bb->succs) == 0
+	  || (EDGE_COUNT (bb->succs) == 1
+	      && EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
 	      && ! current_function_calls_eh_return)))
     {
       rtx insn, set;
Index: gcc/function.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/function.c,v
retrieving revision 1.575
diff -u -p -w -r1.575 function.c
--- gcc/function.c	10 Sep 2004 00:50:24 -0000	1.575
+++ gcc/function.c	13 Sep 2004 04:39:09 -0000
@@ -4955,6 +4955,9 @@ thread_prologue_and_epilogue_insns (rtx 
 #if defined (HAVE_epilogue) || defined(HAVE_return)
   rtx epilogue_end = NULL_RTX;
 #endif
+#ifdef HAVE_return
+  unsigned ix;
+#endif
 
 #ifdef HAVE_prologue
   if (HAVE_prologue)
@@ -4974,18 +4977,22 @@ thread_prologue_and_epilogue_insns (rtx 
       /* Can't deal with multiple successors of the entry block
          at the moment.  Function should always have at least one
          entry point.  */
-      gcc_assert (ENTRY_BLOCK_PTR->succ && !ENTRY_BLOCK_PTR->succ->succ_next);
+      gcc_assert (EDGE_COUNT (ENTRY_BLOCK_PTR->succs) == 1);
 
-      insert_insn_on_edge (seq, ENTRY_BLOCK_PTR->succ);
+      insert_insn_on_edge (seq, EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
       inserted = 1;
     }
 #endif
 
   /* If the exit block has no non-fake predecessors, we don't need
      an epilogue.  */
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     if ((e->flags & EDGE_FAKE) == 0)
       break;
+    }
+  END_FOR_EACH_EDGE;
+
   if (e == NULL)
     goto epilogue_done;
 
@@ -4999,12 +5006,15 @@ thread_prologue_and_epilogue_insns (rtx 
 	 emit (conditional) return instructions.  */
 
       basic_block last;
-      edge e_next;
       rtx label;
 
-      for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+	{
 	if (e->flags & EDGE_FALLTHRU)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
+
       if (e == NULL)
 	goto epilogue_done;
       last = e->src;
@@ -5020,6 +5030,7 @@ thread_prologue_and_epilogue_insns (rtx 
 
       if (BB_HEAD (last) == label && LABEL_P (label))
 	{
+	  unsigned ix;
 	  rtx epilogue_line_note = NULL_RTX;
 
 	  /* Locate the line number associated with the closing brace,
@@ -5033,18 +5044,23 @@ thread_prologue_and_epilogue_insns (rtx 
 		break;
 	      }
 
-	  for (e = last->pred; e; e = e_next)
+	  for (ix = 0; VEC_iterate (edge, last->preds, ix, e); )
 	    {
 	      basic_block bb = e->src;
 	      rtx jump;
 
-	      e_next = e->pred_next;
 	      if (bb == ENTRY_BLOCK_PTR)
+		{
+		  ix++;
 		continue;
+		}
 
 	      jump = BB_END (bb);
 	      if (!JUMP_P (jump) || JUMP_LABEL (jump) != label)
+		{
+		  ix++;
 		continue;
+		}
 
 	      /* If we have an unconditional jump, we can replace that
 		 with a simple return instruction.  */
@@ -5059,16 +5075,25 @@ thread_prologue_and_epilogue_insns (rtx 
 	      else if (condjump_p (jump))
 		{
 		  if (! redirect_jump (jump, 0, 0))
+		    {
+		      ix++;
 		    continue;
+		    }
 
 		  /* If this block has only one successor, it both jumps
 		     and falls through to the fallthru block, so we can't
 		     delete the edge.  */
-		  if (bb->succ->succ_next == NULL)
+		  if (EDGE_COUNT (bb->succs) == 1)
+		    {
+		      ix++;
 		    continue;
 		}
+		}
 	      else
+		{
+		  ix++;
 		continue;
+		}
 
 	      /* Fix up the CFG for the successful change we just made.  */
 	      redirect_edge_succ (e, EXIT_BLOCK_PTR);
@@ -5080,7 +5105,7 @@ thread_prologue_and_epilogue_insns (rtx 
 	  emit_barrier_after (BB_END (last));
 	  emit_return_into_block (last, epilogue_line_note);
 	  epilogue_end = BB_END (last);
-	  last->succ->flags &= ~EDGE_FALLTHRU;
+	  EDGE_SUCC (last, 0)->flags &= ~EDGE_FALLTHRU;
 	  goto epilogue_done;
 	}
     }
@@ -5090,9 +5115,13 @@ thread_prologue_and_epilogue_insns (rtx 
      There really shouldn't be a mixture -- either all should have
      been converted or none, however...  */
 
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     if (e->flags & EDGE_FALLTHRU)
       break;
+    }
+  END_FOR_EACH_EDGE;
+
   if (e == NULL)
     goto epilogue_done;
 
@@ -5151,7 +5180,8 @@ epilogue_done:
 
 #ifdef HAVE_sibcall_epilogue
   /* Emit sibling epilogues before any sibling call sites.  */
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+
+  for (ix = 0; VEC_iterate (edge, EXIT_BLOCK_PTR->preds, ix, e); )
     {
       basic_block bb = e->src;
       rtx insn = BB_END (bb);
@@ -5160,7 +5190,10 @@ epilogue_done:
 
       if (!CALL_P (insn)
 	  || ! SIBLING_CALL_P (insn))
+	{
+	  ix++;
 	continue;
+	}
 
       start_sequence ();
       emit_insn (gen_sibcall_epilogue ());
@@ -5175,6 +5208,8 @@ epilogue_done:
 
       i = PREV_INSN (insn);
       newinsn = emit_insn_before (seq, insn);
+
+      ix++;
     }
 #endif
 
Index: gcc/gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gcse.c,v
retrieving revision 1.314
diff -u -p -w -r1.314 gcse.c
--- gcc/gcse.c	9 Sep 2004 13:53:55 -0000	1.314
+++ gcc/gcse.c	13 Sep 2004 04:39:12 -0000
@@ -3396,7 +3396,7 @@ find_implicit_sets (void)
   count = 0;
   FOR_EACH_BB (bb)
     /* Check for more than one successor.  */
-    if (bb->succ && bb->succ->succ_next)
+    if (EDGE_COUNT (bb->succs) > 1)
       {
 	cond = fis_get_condition (BB_END (bb));
 
@@ -3409,7 +3409,7 @@ find_implicit_sets (void)
 	    dest = GET_CODE (cond) == EQ ? BRANCH_EDGE (bb)->dest
 					 : FALLTHRU_EDGE (bb)->dest;
 
-	    if (dest && ! dest->pred->pred_next
+	    if (dest && EDGE_COUNT (dest->preds) == 1
 		&& dest != EXIT_BLOCK_PTR)
 	      {
 		new = gen_rtx_SET (VOIDmode, XEXP (cond, 0),
@@ -3566,9 +3566,10 @@ static int
 bypass_block (basic_block bb, rtx setcc, rtx jump)
 {
   rtx insn, note;
-  edge e, enext, edest;
+  edge e, edest;
   int i, change;
   int may_be_loop_header;
+  unsigned ix, removed_p;
 
   insn = (setcc != NULL) ? setcc : jump;
 
@@ -3580,30 +3581,44 @@ bypass_block (basic_block bb, rtx setcc,
     find_used_regs (&XEXP (note, 0), NULL);
 
   may_be_loop_header = false;
-  for (e = bb->pred; e; e = e->pred_next)
+
+  FOR_EACH_EDGE (e, bb->preds)
+    {
     if (e->flags & EDGE_DFS_BACK)
       {
 	may_be_loop_header = true;
 	break;
       }
+    }
+  END_FOR_EACH_EDGE;
 
   change = 0;
-  for (e = bb->pred; e; e = enext)
+  for (ix = 0; VEC_iterate (edge, bb->preds, ix, e); )
     {
-      enext = e->pred_next;
+      removed_p = 0;
+	  
       if (e->flags & EDGE_COMPLEX)
+	{
+	  ix++;
 	continue;
+	}
 
       /* We can't redirect edges from new basic blocks.  */
       if (e->src->index >= bypass_last_basic_block)
+	{
+	  ix++;
 	continue;
+	}
 
       /* The irreducible loops created by redirecting of edges entering the
 	 loop from outside would decrease effectiveness of some of the following
 	 optimizations, so prevent this.  */
       if (may_be_loop_header
 	  && !(e->flags & EDGE_DFS_BACK))
+	{
+	  ix++;
 	continue;
+	}
 
       for (i = 0; i < reg_use_count; i++)
 	{
@@ -3649,13 +3664,16 @@ bypass_block (basic_block bb, rtx setcc,
 	    {
 	      dest = BLOCK_FOR_INSN (XEXP (new, 0));
 	      /* Don't bypass edges containing instructions.  */
-	      for (edest = bb->succ; edest; edest = edest->succ_next)
+	      FOR_EACH_EDGE (edest, bb->succs)
+		{
 		if (edest->dest == dest && edest->insns.r)
 		  {
 		    dest = NULL;
 		    break;
 		  }
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 	  else
 	    dest = NULL;
 
@@ -3666,13 +3684,16 @@ bypass_block (basic_block bb, rtx setcc,
 	  if (dest && setcc && !CC0_P (SET_DEST (PATTERN (setcc))))
 	    {
 	      edge e2;
-	      for (e2 = e->src->succ; e2; e2 = e2->succ_next)
+	      FOR_EACH_EDGE (e2, e->src->succs)
+		{
 		if (e2->dest == dest)
 		  {
 		    dest = NULL;
 		    break;
 		  }
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 
 	  old_dest = e->dest;
 	  if (dest != NULL
@@ -3700,9 +3721,12 @@ bypass_block (basic_block bb, rtx setcc,
 			   e->src->index, old_dest->index, dest->index);
 		}
 	      change = 1;
+	      removed_p = 1;
 	      break;
 	    }
 	}
+      if (!removed_p)
+	ix++;
     }
   return change;
 }
@@ -3735,7 +3759,7 @@ bypass_conditional_jumps (void)
 		  EXIT_BLOCK_PTR, next_bb)
     {
       /* Check for more than one predecessor.  */
-      if (bb->pred && bb->pred->pred_next)
+      if (EDGE_COUNT (bb->preds) > 1)
 	{
 	  setcc = NULL_RTX;
 	  for (insn = BB_HEAD (bb);
@@ -3887,13 +3911,16 @@ compute_pre_data (void)
 	 kill all trapping expressions because we won't be able to properly
 	 place the instruction on the edge.  So make them neither
 	 anticipatable nor transparent.  This is fairly conservative.  */
-      for (e = bb->pred; e ; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (e->flags & EDGE_ABNORMAL)
 	  {
 	    sbitmap_difference (antloc[bb->index], antloc[bb->index], trapping_expr);
 	    sbitmap_difference (transp[bb->index], transp[bb->index], trapping_expr);
 	    break;
 	  }
+	}
+      END_FOR_EACH_EDGE;
 
       sbitmap_a_or_b (ae_kill[bb->index], transp[bb->index], comp[bb->index]);
       sbitmap_not (ae_kill[bb->index], ae_kill[bb->index]);
@@ -3928,7 +3955,7 @@ pre_expr_reaches_here_p_work (basic_bloc
 {
   edge pred;
 
-  for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
+  FOR_EACH_EDGE (pred, bb->preds)
     {
       basic_block pred_bb = pred->src;
 
@@ -3960,6 +3987,7 @@ pre_expr_reaches_here_p_work (basic_bloc
 	    return 1;
 	}
     }
+  END_FOR_EACH_EDGE;
 
   /* All paths have been checked.  */
   return 0;
@@ -4046,7 +4074,8 @@ insert_insn_end_bb (struct expr *expr, b
 
   if (JUMP_P (insn)
       || (NONJUMP_INSN_P (insn)
-	  && (bb->succ->succ_next || (bb->succ->flags & EDGE_ABNORMAL))))
+	  && (EDGE_COUNT (bb->succs) > 1
+	      || EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL)))
     {
 #ifdef HAVE_cc0
       rtx note;
@@ -4087,7 +4116,7 @@ insert_insn_end_bb (struct expr *expr, b
   /* Likewise if the last insn is a call, as will happen in the presence
      of exception handling.  */
   else if (CALL_P (insn)
-	   && (bb->succ->succ_next || (bb->succ->flags & EDGE_ABNORMAL)))
+	   && (EDGE_COUNT (bb->succs) > 1 || EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL))
     {
       /* Keeping in mind SMALL_REGISTER_CLASSES and parameters in registers,
 	 we search backward and place the instructions before the first
@@ -4807,14 +4836,13 @@ hoist_expr_reaches_here_p (basic_block e
   edge pred;
   int visited_allocated_locally = 0;
 
-
   if (visited == NULL)
     {
       visited_allocated_locally = 1;
       visited = xcalloc (last_basic_block, 1);
     }
 
-  for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
+  FOR_EACH_EDGE (pred, bb->preds)
     {
       basic_block pred_bb = pred->src;
 
@@ -4840,6 +4868,7 @@ hoist_expr_reaches_here_p (basic_block e
 	    break;
 	}
     }
+  END_FOR_EACH_EDGE;
   if (visited_allocated_locally)
     free (visited);
 
@@ -6199,25 +6228,28 @@ insert_store (struct ls_expr * expr, edg
      insert it at the start of the BB, and reset the insert bits on the other
      edges so we don't try to insert it on the other edges.  */
   bb = e->dest;
-  for (tmp = e->dest->pred; tmp ; tmp = tmp->pred_next)
+  FOR_EACH_EDGE (tmp, e->dest->preds)
+    {
     if (!(tmp->flags & EDGE_FAKE))
       {
 	int index = EDGE_INDEX (edge_list, tmp->src, tmp->dest);
-	
 	gcc_assert (index != EDGE_INDEX_NO_EDGE);
 	if (! TEST_BIT (pre_insert_map[index], expr->index))
 	  break;
       }
+    }
+  END_FOR_EACH_EDGE;
 
   /* If tmp is NULL, we found an insertion on every edge, blank the
      insertion vector for these edges, and insert at the start of the BB.  */
   if (!tmp && bb != EXIT_BLOCK_PTR)
     {
-      for (tmp = e->dest->pred; tmp ; tmp = tmp->pred_next)
+      FOR_EACH_EDGE (tmp, e->dest->preds)
 	{
 	  int index = EDGE_INDEX (edge_list, tmp->src, tmp->dest);
 	  RESET_BIT (pre_insert_map[index], expr->index);
 	}
+      END_FOR_EACH_EDGE;
       insert_insn_start_bb (insn, bb);
       return 0;
     }
@@ -6251,33 +6283,44 @@ insert_store (struct ls_expr * expr, edg
 static void
 remove_reachable_equiv_notes (basic_block bb, struct ls_expr *smexpr)
 {
-  edge *stack = xmalloc (sizeof (edge) * n_basic_blocks), act;
+  struct edge_stack *stack;
+  int sp;
+  VEC(edge) *ev;
+  unsigned ix;
+  edge act;
   sbitmap visited = sbitmap_alloc (last_basic_block);
-  int stack_top = 0;
   rtx last, insn, note;
   rtx mem = smexpr->pattern;
 
+  stack = xmalloc (sizeof (struct edge_stack) * n_basic_blocks);
+  sp = 0;
+
+  ev = bb->succs;
+  ix = 0;
+
   sbitmap_zero (visited);
-  act = bb->succ;
 
+  act = (EDGE_COUNT (ev) > 0 ? EDGE_I (ev, 0) : NULL);
   while (1)
     {
       if (!act)
 	{
-	  if (!stack_top)
+	  if (!sp)
 	    {
 	      free (stack);
 	      sbitmap_free (visited);
 	      return;
 	    }
-	  act = stack[--stack_top];
+	  ev = stack[--sp].ev;
+	  ix = stack[sp].ix;
+	  act = EDGE_I (ev, ix);
 	}
       bb = act->dest;
 
       if (bb == EXIT_BLOCK_PTR
 	  || TEST_BIT (visited, bb->index))
 	{
-	  act = act->succ_next;
+	  act = (EDGE_COUNT (ev) > ++ix ? EDGE_I (ev, ix) : NULL);
 	  continue;
 	}
       SET_BIT (visited, bb->index);
@@ -6305,12 +6348,18 @@ remove_reachable_equiv_notes (basic_bloc
 		       INSN_UID (insn));
 	    remove_note (insn, note);
 	  }
-      act = act->succ_next;
-      if (bb->succ)
+
+      act = (EDGE_COUNT (ev) > ++ix ? EDGE_I (ev, ix) : NULL);
+      if (EDGE_COUNT (bb->succs) > 0)
 	{
 	  if (act)
-	    stack[stack_top++] = act;
-	  act = bb->succ;
+	    {
+	      stack[sp].ev = ev;
+	      stack[sp++].ix = ix;
+	    }
+	  ev = bb->succs;
+	  ix = 0;
+	  act = (EDGE_COUNT (ev) > 0 ? EDGE_I (ev, 0) : NULL);
 	}
     }
 }
Index: gcc/global.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/global.c,v
retrieving revision 1.108
diff -u -p -w -r1.108 global.c
--- gcc/global.c	9 Sep 2004 13:54:06 -0000	1.108
+++ gcc/global.c	13 Sep 2004 04:39:13 -0000
@@ -749,9 +749,12 @@ global_conflicts (void)
 	{
 	  edge e;
 
-	  for (e = b->pred; e ; e = e->pred_next)
+	  FOR_EACH_EDGE (e, b->preds)
+	    {
 	    if (e->flags & EDGE_ABNORMAL)
 	      break;
+	    }
+	  END_FOR_EACH_EDGE;
 
 	  if (e != NULL)
 	    {
@@ -2341,10 +2344,13 @@ calculate_reg_pav (void)
 	{
 	  bb = bb_array [i];
 	  changed_p = 0;
-	  for (e = bb->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, bb->preds)
+	    {
 	    changed_p = modify_bb_reg_pav (bb, e->src, changed_p);
+	    }
+	  END_FOR_EACH_EDGE;
 	  if (changed_p)
-	    for (e = bb->succ; e; e = e->succ_next)
+	    FOR_EACH_EDGE (e, bb->succs)
 	      {
 		succ = e->dest;
 		if (succ->index != EXIT_BLOCK && !TEST_BIT (wset, succ->index))
@@ -2353,6 +2359,7 @@ calculate_reg_pav (void)
 		    VARRAY_PUSH_BB (new_bbs, succ);
 		  }
 	      }
+	    END_FOR_EACH_EDGE;
 	}
       temp = bbs;
       bbs = new_bbs;
Index: gcc/graph.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/graph.c,v
retrieving revision 1.35
diff -u -p -w -r1.35 graph.c
--- gcc/graph.c	9 Sep 2004 13:54:07 -0000	1.35
+++ gcc/graph.c	13 Sep 2004 04:39:14 -0000
@@ -316,7 +316,8 @@ print_rtl_graph_with_bb (const char *bas
 
 	      /* Now specify the edges to all the successors of this
 		 basic block.  */
-	      for (e = bb->succ; e ; e = e->succ_next)
+
+	      FOR_EACH_EDGE (e, bb->succs)
 		{
 		  if (e->dest != EXIT_BLOCK_PTR)
 		    {
@@ -340,6 +341,7 @@ print_rtl_graph_with_bb (const char *bas
 			edge_printed = 1;
 		    }
 		}
+	      END_FOR_EACH_EDGE;
 	    }
 
 	  if (!edge_printed)
Index: gcc/ifcvt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ifcvt.c,v
retrieving revision 1.164
diff -u -p -w -r1.164 ifcvt.c
--- gcc/ifcvt.c	29 Aug 2004 22:10:42 -0000	1.164
+++ gcc/ifcvt.c	13 Sep 2004 04:39:16 -0000
@@ -65,8 +65,8 @@
 #define MAX_CONDITIONAL_EXECUTE   (BRANCH_COST + 1)
 #endif
 
-#define NULL_EDGE	((struct edge_def *)NULL)
-#define NULL_BLOCK	((struct basic_block_def *)NULL)
+#define NULL_EDGE	((edge) NULL)
+#define NULL_BLOCK	((basic_block) NULL)
 
 /* # of IF-THEN or IF-THEN-ELSE blocks we looked at  */
 static int num_possible_if_blocks;
@@ -126,7 +126,7 @@ mark_loop_exit_edges (void)
     {
       FOR_EACH_BB (bb)
 	{
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      if (find_common_loop (bb->loop_father, e->dest->loop_father)
 		  != bb->loop_father)
@@ -134,6 +134,7 @@ mark_loop_exit_edges (void)
 	      else
 		e->flags &= ~EDGE_LOOP_EXIT;
 	    }
+	  END_FOR_EACH_EDGE;
 	}
     }
 
@@ -250,10 +251,12 @@ block_fallthru (basic_block bb)
 {
   edge e;
 
-  for (e = bb->succ;
-       e != NULL_EDGE && (e->flags & EDGE_FALLTHRU) == 0;
-       e = e->succ_next)
-    ;
+  FOR_EACH_EDGE (e, bb->succs)
+    {
+      if (e->flags & EDGE_FALLTHRU)
+	break;
+    }
+  END_FOR_EACH_EDGE;
 
   return (e) ? e->dest : NULL_BLOCK;
 }
@@ -2206,7 +2209,7 @@ merge_if_block (struct ce_if_block * ce_
 
       /* The outgoing edge for the current COMBO block should already
 	 be correct.  Verify this.  */
-      if (combo_bb->succ == NULL_EDGE)
+      if (EDGE_COUNT (combo_bb->succs) == 0)
 	{
 	  if (find_reg_note (last, REG_NORETURN, NULL))
 	    ;
@@ -2222,11 +2225,11 @@ merge_if_block (struct ce_if_block * ce_
          blocks taking us to our final destination.  */
       else if (JUMP_P (last))
 	;
-      else if (combo_bb->succ->dest == EXIT_BLOCK_PTR
+      else if (EDGE_SUCC (combo_bb, 0)->dest == EXIT_BLOCK_PTR
 	       && CALL_P (last)
 	       && SIBLING_CALL_P (last))
 	;
-      else if ((combo_bb->succ->flags & EDGE_EH)
+      else if ((EDGE_SUCC (combo_bb, 0)->flags & EDGE_EH)
 	       && can_throw_internal (last))
 	;
       else
@@ -2239,8 +2242,7 @@ merge_if_block (struct ce_if_block * ce_
      is more than one remaining edge, it must come from elsewhere.  There
      may be zero incoming edges if the THEN block didn't actually join
      back up (as with a call to abort).  */
-  else if ((join_bb->pred == NULL
-	    || join_bb->pred->pred_next == NULL)
+  else if (EDGE_COUNT (join_bb->preds) < 2
 	   && join_bb != EXIT_BLOCK_PTR)
     {
       /* We can merge the JOIN.  */
@@ -2257,13 +2259,13 @@ merge_if_block (struct ce_if_block * ce_
 
       /* The outgoing edge for the current COMBO block should already
 	 be correct.  Verify this.  */
-      if (combo_bb->succ->succ_next != NULL_EDGE
-	  || combo_bb->succ->dest != join_bb)
+      if (EDGE_COUNT (combo_bb->succs) > 1
+	  || EDGE_SUCC (combo_bb, 0)->dest != join_bb)
 	abort ();
 
       /* Remove the jump and cruft from the end of the COMBO block.  */
       if (join_bb != EXIT_BLOCK_PTR)
-	tidy_fallthru_edge (combo_bb->succ);
+	tidy_fallthru_edge (EDGE_SUCC (combo_bb, 0));
     }
 
   num_updated_if_blocks++;
@@ -2282,11 +2284,12 @@ find_if_header (basic_block test_bb, int
   edge else_edge;
 
   /* The kind of block we're looking for has exactly two successors.  */
-  if ((then_edge = test_bb->succ) == NULL_EDGE
-      || (else_edge = then_edge->succ_next) == NULL_EDGE
-      || else_edge->succ_next != NULL_EDGE)
+  if (EDGE_COUNT (test_bb->succs) != 2)
     return NULL;
 
+  then_edge = EDGE_SUCC (test_bb, 0);
+  else_edge = EDGE_SUCC (test_bb, 1);
+
   /* Neither edge should be abnormal.  */
   if ((then_edge->flags & EDGE_COMPLEX)
       || (else_edge->flags & EDGE_COMPLEX))
@@ -2363,12 +2366,10 @@ block_jumps_and_fallthru_p (basic_block 
     return -1;
 
   /* If no edges, obviously it doesn't jump or fallthru.  */
-  if (cur_bb->succ == NULL_EDGE)
+  if (EDGE_COUNT (cur_bb->succs) == 0)
     return FALSE;
 
-  for (cur_edge = cur_bb->succ;
-       cur_edge != NULL_EDGE;
-       cur_edge = cur_edge->succ_next)
+  FOR_EACH_EDGE (cur_edge, cur_bb->succs)
     {
       if (cur_edge->flags & EDGE_COMPLEX)
 	/* Anything complex isn't what we want.  */
@@ -2383,6 +2384,7 @@ block_jumps_and_fallthru_p (basic_block 
       else
 	return -1;
     }
+  END_FOR_EACH_EDGE;
 
   if ((jump_p & fallthru_p) == 0)
     return -1;
@@ -2425,8 +2427,6 @@ find_if_block (struct ce_if_block * ce_i
   basic_block then_bb = ce_info->then_bb;
   basic_block else_bb = ce_info->else_bb;
   basic_block join_bb = NULL_BLOCK;
-  edge then_succ = then_bb->succ;
-  edge else_succ = else_bb->succ;
   int then_predecessors;
   int else_predecessors;
   edge cur_edge;
@@ -2438,11 +2438,10 @@ find_if_block (struct ce_if_block * ce_i
      were && tests (which jump to the else block) or || tests (which jump to
      the then block).  */
   if (HAVE_conditional_execution && reload_completed
-      && test_bb->pred != NULL_EDGE
-      && test_bb->pred->pred_next == NULL_EDGE
-      && test_bb->pred->flags == EDGE_FALLTHRU)
+      && EDGE_COUNT (test_bb->preds) == 1
+      && EDGE_PRED (test_bb, 0)->flags == EDGE_FALLTHRU)
     {
-      basic_block bb = test_bb->pred->src;
+      basic_block bb = EDGE_PRED (test_bb, 0)->src;
       basic_block target_bb;
       int max_insns = MAX_CONDITIONAL_EXECUTE;
       int n_insns;
@@ -2475,10 +2474,10 @@ find_if_block (struct ce_if_block * ce_i
 	      total_insns += n_insns;
 	      blocks++;
 
-	      if (bb->pred == NULL_EDGE || bb->pred->pred_next != NULL_EDGE)
+	      if (EDGE_COUNT (bb->preds) != 1)
 		break;
 
-	      bb = bb->pred->src;
+	      bb = EDGE_PRED (bb, 0)->src;
 	      n_insns = block_jumps_and_fallthru_p (bb, target_bb);
 	    }
 	  while (n_insns >= 0 && (total_insns + n_insns) <= max_insns);
@@ -2495,24 +2494,22 @@ find_if_block (struct ce_if_block * ce_i
 
   /* Count the number of edges the THEN and ELSE blocks have.  */
   then_predecessors = 0;
-  for (cur_edge = then_bb->pred;
-       cur_edge != NULL_EDGE;
-       cur_edge = cur_edge->pred_next)
+  FOR_EACH_EDGE (cur_edge, then_bb->preds)
     {
       then_predecessors++;
       if (cur_edge->flags & EDGE_COMPLEX)
 	return FALSE;
     }
+  END_FOR_EACH_EDGE;
 
   else_predecessors = 0;
-  for (cur_edge = else_bb->pred;
-       cur_edge != NULL_EDGE;
-       cur_edge = cur_edge->pred_next)
+  FOR_EACH_EDGE (cur_edge, else_bb->preds)
     {
       else_predecessors++;
       if (cur_edge->flags & EDGE_COMPLEX)
 	return FALSE;
     }
+  END_FOR_EACH_EDGE;
 
   /* The THEN block of an IF-THEN combo must have exactly one predecessor,
      other than any || blocks which jump to the THEN block.  */
@@ -2520,9 +2517,9 @@ find_if_block (struct ce_if_block * ce_i
     return FALSE;
 
   /* The THEN block of an IF-THEN combo must have zero or one successors.  */
-  if (then_succ != NULL_EDGE
-      && (then_succ->succ_next != NULL_EDGE
-          || (then_succ->flags & EDGE_COMPLEX)
+  if (EDGE_COUNT (then_bb->succs) > 0
+      && (EDGE_COUNT (then_bb->succs) > 1
+          || (EDGE_SUCC (then_bb, 0)->flags & EDGE_COMPLEX)
 	  || (flow2_completed && tablejump_p (BB_END (then_bb), NULL, NULL))))
     return FALSE;
 
@@ -2532,9 +2529,9 @@ find_if_block (struct ce_if_block * ce_i
      Check for the last insn of the THEN block being an indirect jump, which
      is listed as not having any successors, but confuses the rest of the CE
      code processing.  ??? we should fix this in the future.  */
-  if (then_succ == NULL)
+  if (EDGE_COUNT (then_bb->succs) == 0)
     {
-      if (else_bb->pred->pred_next == NULL_EDGE)
+      if (EDGE_COUNT (else_bb->preds) == 1)
 	{
 	  rtx last_insn = BB_END (then_bb);
 
@@ -2557,7 +2554,7 @@ find_if_block (struct ce_if_block * ce_i
 
   /* If the THEN block's successor is the other edge out of the TEST block,
      then we have an IF-THEN combo without an ELSE.  */
-  else if (then_succ->dest == else_bb)
+  else if (EDGE_SUCC (then_bb, 0)->dest == else_bb)
     {
       join_bb = else_bb;
       else_bb = NULL_BLOCK;
@@ -2566,13 +2563,12 @@ find_if_block (struct ce_if_block * ce_i
   /* If the THEN and ELSE block meet in a subsequent block, and the ELSE
      has exactly one predecessor and one successor, and the outgoing edge
      is not complex, then we have an IF-THEN-ELSE combo.  */
-  else if (else_succ != NULL_EDGE
-	   && then_succ->dest == else_succ->dest
-	   && else_bb->pred->pred_next == NULL_EDGE
-	   && else_succ->succ_next == NULL_EDGE
-	   && ! (else_succ->flags & EDGE_COMPLEX)
+  else if (EDGE_COUNT (else_bb->succs) == 1
+	   && EDGE_SUCC (then_bb, 0)->dest == EDGE_SUCC (else_bb, 0)->dest
+	   && EDGE_COUNT (else_bb->preds) == 1
+	   && ! (EDGE_SUCC (else_bb, 0)->flags & EDGE_COMPLEX)
 	   && ! (flow2_completed && tablejump_p (BB_END (else_bb), NULL, NULL)))
-    join_bb = else_succ->dest;
+    join_bb = EDGE_SUCC (else_bb, 0)->dest;
 
   /* Otherwise it is not an IF-THEN or IF-THEN-ELSE combination.  */
   else
@@ -2706,7 +2702,7 @@ find_cond_trap (basic_block test_bb, edg
 
   /* Delete the trap block if possible.  */
   remove_edge (trap_bb == then_bb ? then_edge : else_edge);
-  if (trap_bb->pred == NULL)
+  if (EDGE_COUNT (trap_bb->preds) == 0)
     delete_basic_block (trap_bb);
 
   /* If the non-trap block and the test are now adjacent, merge them.
@@ -2751,7 +2747,7 @@ block_has_only_trap (basic_block bb)
     return NULL_RTX;
 
   /* The block must have no successors.  */
-  if (bb->succ)
+  if (EDGE_COUNT (bb->succs) > 0)
     return NULL_RTX;
 
   /* The only instruction in the THEN block must be the trap.  */
@@ -2846,7 +2842,6 @@ find_if_case_1 (basic_block test_bb, edg
 {
   basic_block then_bb = then_edge->dest;
   basic_block else_bb = else_edge->dest, new_bb;
-  edge then_succ = then_bb->succ;
   int then_bb_index, bb_cost;
 
   /* If we are partitioning hot/cold basic blocks, we don't want to
@@ -2868,15 +2863,15 @@ find_if_case_1 (basic_block test_bb, edg
     return FALSE;
 
   /* THEN has one successor.  */
-  if (!then_succ || then_succ->succ_next != NULL)
+  if (EDGE_COUNT (then_bb->succs) != 1)
     return FALSE;
 
   /* THEN does not fall through, but is not strange either.  */
-  if (then_succ->flags & (EDGE_COMPLEX | EDGE_FALLTHRU))
+  if (EDGE_SUCC (then_bb, 0)->flags & (EDGE_COMPLEX | EDGE_FALLTHRU))
     return FALSE;
 
   /* THEN has one predecessor.  */
-  if (then_bb->pred->pred_next != NULL)
+  if (EDGE_COUNT (then_bb->preds) != 1)
     return FALSE;
 
   /* THEN must do something.  */
@@ -2896,7 +2891,7 @@ find_if_case_1 (basic_block test_bb, edg
 
   /* Registers set are dead, or are predicable.  */
   if (! dead_or_predicable (test_bb, then_bb, else_bb,
-			    then_bb->succ->dest, 1))
+			    EDGE_SUCC (then_bb, 0)->dest, 1))
     return FALSE;
 
   /* Conversion went ok, including moving the insns and fixing up the
@@ -2937,7 +2932,7 @@ find_if_case_2 (basic_block test_bb, edg
 {
   basic_block then_bb = then_edge->dest;
   basic_block else_bb = else_edge->dest;
-  edge else_succ = else_bb->succ;
+  edge else_succ;
   int bb_cost;
   rtx note;
 
@@ -2960,15 +2955,17 @@ find_if_case_2 (basic_block test_bb, edg
     return FALSE;
 
   /* ELSE has one successor.  */
-  if (!else_succ || else_succ->succ_next != NULL)
+  if (EDGE_COUNT (else_bb->succs) != 1)
     return FALSE;
+  else
+    else_succ = EDGE_SUCC (else_bb, 0);
 
   /* ELSE outgoing edge is not complex.  */
   if (else_succ->flags & EDGE_COMPLEX)
     return FALSE;
 
   /* ELSE has one predecessor.  */
-  if (else_bb->pred->pred_next != NULL)
+  if (EDGE_COUNT (else_bb->preds) != 1)
     return FALSE;
 
   /* THEN is not EXIT.  */
Index: gcc/lambda-code.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lambda-code.c,v
retrieving revision 2.6
diff -u -p -w -r2.6 lambda-code.c
--- gcc/lambda-code.c	10 Sep 2004 15:09:38 -0000	2.6
+++ gcc/lambda-code.c	13 Sep 2004 04:39:17 -0000
@@ -1830,7 +1830,7 @@ lambda_loopnest_to_gcc_loopnest (struct 
       /* Create the new iv, and insert it's increment on the latch
          block.  */
 
-      bb = temp->latch->pred->src;
+      bb = EDGE_PRED (temp->latch, 0)->src;
       bsi = bsi_last (bb);
       create_iv (newlowerbound,
 		 build_int_cst (integer_type_node, LL_STEP (newloop)),
Index: gcc/lcm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/lcm.c,v
retrieving revision 1.65
diff -u -p -w -r1.65 lcm.c
--- gcc/lcm.c	10 Sep 2004 11:02:20 -0000	1.65
+++ gcc/lcm.c	13 Sep 2004 04:39:17 -0000
@@ -126,8 +126,11 @@ compute_antinout_edge (sbitmap *antloc, 
 
   /* Mark blocks which are predecessors of the exit block so that we
      can easily identify them below.  */
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     e->src->aux = EXIT_BLOCK_PTR;
+    }
+  END_FOR_EACH_EDGE;
 
   /* Iterate until the worklist is empty.  */
   while (qlen)
@@ -157,7 +160,8 @@ compute_antinout_edge (sbitmap *antloc, 
 	/* If the in state of this block changed, then we need
 	   to add the predecessors of this block to the worklist
 	   if they are not already on the worklist.  */
-	for (e = bb->pred; e; e = e->pred_next)
+	FOR_EACH_EDGE (e, bb->preds)
+	  {
 	  if (!e->src->aux && e->src != ENTRY_BLOCK_PTR)
 	    {
 	      *qin++ = e->src;
@@ -167,6 +171,8 @@ compute_antinout_edge (sbitmap *antloc, 
 		qin = worklist;
 	    }
     }
+        END_FOR_EACH_EDGE;
+    }
 
   clear_aux_for_edges ();
   clear_aux_for_blocks ();
@@ -280,8 +286,11 @@ compute_laterin (struct edge_list *edge_
      do not want to be overly optimistic.  Consider an outgoing edge from
      the entry block.  That edge should always have a LATER value the
      same as EARLIEST for that edge.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+    {
     sbitmap_copy (later[(size_t) e->aux], earliest[(size_t) e->aux]);
+    }
+  END_FOR_EACH_EDGE;
 
   /* Add all the blocks to the worklist.  This prevents an early exit from
      the loop given our optimistic initialization of LATER above.  */
@@ -310,12 +319,16 @@ compute_laterin (struct edge_list *edge_
 
       /* Compute the intersection of LATERIN for each incoming edge to B.  */
       sbitmap_ones (laterin[bb->index]);
-      for (e = bb->pred; e != NULL; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	sbitmap_a_and_b (laterin[bb->index], laterin[bb->index],
 			 later[(size_t)e->aux]);
+	}
+      END_FOR_EACH_EDGE;
 
       /* Calculate LATER for all outgoing edges.  */
-      for (e = bb->succ; e != NULL; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (sbitmap_union_of_diff_cg (later[(size_t) e->aux],
 				      earliest[(size_t) e->aux],
 				      laterin[e->src->index],
@@ -331,15 +344,20 @@ compute_laterin (struct edge_list *edge_
 	      qin = worklist;
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Computation of insertion and deletion points requires computing LATERIN
      for the EXIT block.  We allocated an extra entry in the LATERIN array
      for just this purpose.  */
   sbitmap_ones (laterin[last_basic_block]);
-  for (e = EXIT_BLOCK_PTR->pred; e != NULL; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     sbitmap_a_and_b (laterin[last_basic_block],
 		     laterin[last_basic_block],
 		     later[(size_t) e->aux]);
+    }
+  END_FOR_EACH_EDGE;
 
   clear_aux_for_edges ();
   free (worklist);
@@ -501,8 +519,11 @@ compute_available (sbitmap *avloc, sbitm
 
   /* Mark blocks which are successors of the entry block so that we
      can easily identify them below.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+    {
     e->dest->aux = ENTRY_BLOCK_PTR;
+    }
+  END_FOR_EACH_EDGE;
 
   /* Iterate until the worklist is empty.  */
   while (qlen)
@@ -534,7 +555,8 @@ compute_available (sbitmap *avloc, sbitm
 	/* If the out state of this block changed, then we need
 	   to add the successors of this block to the worklist
 	   if they are not already on the worklist.  */
-	for (e = bb->succ; e; e = e->succ_next)
+	FOR_EACH_EDGE (e, bb->succs)
+	  {
 	  if (!e->dest->aux && e->dest != EXIT_BLOCK_PTR)
 	    {
 	      *qin++ = e->dest;
@@ -545,6 +567,8 @@ compute_available (sbitmap *avloc, sbitm
 		qin = worklist;
 	    }
     }
+        END_FOR_EACH_EDGE;
+    }
 
   clear_aux_for_edges ();
   clear_aux_for_blocks ();
@@ -624,8 +648,11 @@ compute_nearerout (struct edge_list *edg
      do not want to be overly optimistic.  Consider an incoming edge to
      the exit block.  That edge should always have a NEARER value the
      same as FARTHEST for that edge.  */
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     sbitmap_copy (nearer[(size_t)e->aux], farthest[(size_t)e->aux]);
+    }
+  END_FOR_EACH_EDGE;
 
   /* Add all the blocks to the worklist.  This prevents an early exit
      from the loop given our optimistic initialization of NEARER.  */
@@ -644,12 +671,16 @@ compute_nearerout (struct edge_list *edg
 
       /* Compute the intersection of NEARER for each outgoing edge from B.  */
       sbitmap_ones (nearerout[bb->index]);
-      for (e = bb->succ; e != NULL; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	sbitmap_a_and_b (nearerout[bb->index], nearerout[bb->index],
 			 nearer[(size_t) e->aux]);
+	}
+      END_FOR_EACH_EDGE;
 
       /* Calculate NEARER for all incoming edges.  */
-      for (e = bb->pred; e != NULL; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (sbitmap_union_of_diff_cg (nearer[(size_t) e->aux],
 				      farthest[(size_t) e->aux],
 				      nearerout[e->dest->index],
@@ -662,15 +693,20 @@ compute_nearerout (struct edge_list *edg
 	    e->src->aux = e;
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Computation of insertion and deletion points requires computing NEAREROUT
      for the ENTRY block.  We allocated an extra entry in the NEAREROUT array
      for just this purpose.  */
   sbitmap_ones (nearerout[last_basic_block]);
-  for (e = ENTRY_BLOCK_PTR->succ; e != NULL; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+    {
     sbitmap_a_and_b (nearerout[last_basic_block],
 		     nearerout[last_basic_block],
 		     nearer[(size_t) e->aux]);
+    }
+  END_FOR_EACH_EDGE;
 
   clear_aux_for_edges ();
   free (tos);
@@ -913,7 +949,7 @@ make_preds_opaque (basic_block b, int j)
 {
   edge e;
 
-  for (e = b->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, b->preds)
     {
       basic_block pb = e->src;
 
@@ -923,6 +959,7 @@ make_preds_opaque (basic_block b, int j)
       RESET_BIT (transp[pb->index], j);
       make_preds_opaque (pb, j);
     }
+  END_FOR_EACH_EDGE;
 }
 
 /* Record in LIVE that register REG died.  */
Index: gcc/loop-doloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-doloop.c,v
retrieving revision 2.7
diff -u -p -w -r2.7 loop-doloop.c
--- gcc/loop-doloop.c	10 Sep 2004 11:02:24 -0000	2.7
+++ gcc/loop-doloop.c	13 Sep 2004 04:39:18 -0000
@@ -358,11 +358,11 @@ doloop_modify (struct loop *loop, struct
       /* Expand the condition testing the assumptions and if it does not pass,
 	 reset the count register to 0.  */
       add_test (XEXP (ass, 0), preheader, set_zero);
-      preheader->succ->flags &= ~EDGE_FALLTHRU;
-      cnt = preheader->succ->count;
-      preheader->succ->probability = 0;
-      preheader->succ->count = 0;
-      irr = preheader->succ->flags & EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (preheader, 0)->flags &= ~EDGE_FALLTHRU;
+      cnt = EDGE_SUCC (preheader, 0)->count;
+      EDGE_SUCC (preheader, 0)->probability = 0;
+      EDGE_SUCC (preheader, 0)->count = 0;
+      irr = EDGE_SUCC (preheader, 0)->flags & EDGE_IRREDUCIBLE_LOOP;
       te = make_edge (preheader, new_preheader, EDGE_FALLTHRU | irr);
       te->probability = REG_BR_PROB_BASE;
       te->count = cnt;
@@ -374,7 +374,7 @@ doloop_modify (struct loop *loop, struct
       for (ass = XEXP (ass, 1); ass; ass = XEXP (ass, 1))
 	{
 	  bb = loop_split_edge_with (te, NULL_RTX);
-	  te = bb->succ;
+	  te = EDGE_SUCC (bb, 0);
 	  add_test (XEXP (ass, 0), bb, set_zero);
 	  make_edge (bb, set_zero, irr);
 	}
Index: gcc/loop-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-init.c,v
retrieving revision 1.11
diff -u -p -w -r1.11 loop-init.c
--- gcc/loop-init.c	17 Jul 2004 18:08:10 -0000	1.11
+++ gcc/loop-init.c	13 Sep 2004 04:39:18 -0000
@@ -35,6 +35,7 @@ loop_optimizer_init (FILE *dumpfile)
 {
   struct loops *loops = xcalloc (1, sizeof (struct loops));
   edge e;
+  unsigned ix;
   static bool first_time = true;
 
   if (first_time)
@@ -45,9 +46,14 @@ loop_optimizer_init (FILE *dumpfile)
 
   /* Avoid annoying special cases of edges going to exit
      block.  */
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
-    if ((e->flags & EDGE_FALLTHRU) && e->src->succ->succ_next)
+
+  for (ix = 0; VEC_iterate (edge, EXIT_BLOCK_PTR->preds, ix, e); )
+    {
+      if ((e->flags & EDGE_FALLTHRU) && EDGE_COUNT (e->src->succs) > 1)
       split_edge (e);
+      else
+	ix++;
+    }
 
   /* Find the loops.  */
 
Index: gcc/loop-invariant.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-invariant.c,v
retrieving revision 2.6
diff -u -p -w -r2.6 loop-invariant.c
--- gcc/loop-invariant.c	12 Sep 2004 05:51:01 -0000	2.6
+++ gcc/loop-invariant.c	13 Sep 2004 04:39:18 -0000
@@ -239,7 +239,7 @@ find_exits (struct loop *loop, basic_blo
 		}
 	    }
 
-	  for (e = body[i]->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, body[i]->succs)
 	    {
 	      if (flow_bb_inside_loop_p (loop, e->dest))
 		continue;
@@ -249,6 +249,7 @@ find_exits (struct loop *loop, basic_blo
 	      outermost_exit = find_common_loop (outermost_exit,
 						 e->dest->loop_father);
 	    }
+	  END_FOR_EACH_EDGE;
 	  continue;
 	}
      
Index: gcc/loop-iv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-iv.c,v
retrieving revision 2.18
diff -u -p -w -r2.18 loop-iv.c
--- gcc/loop-iv.c	10 Sep 2004 11:02:24 -0000	2.18
+++ gcc/loop-iv.c	13 Sep 2004 04:39:19 -0000
@@ -1764,6 +1764,8 @@ simplify_using_initial_values (struct lo
 
   while (1)
     {
+      basic_block tmp_bb;
+
       insn = BB_END (e->src);
       if (any_condjump_p (insn))
 	{
@@ -1795,8 +1797,12 @@ simplify_using_initial_values (struct lo
 	    }
 	}
 
-      e = e->src->pred;
-      if (e->pred_next
+      /* This is a bit subtle.  Store away e->src in tmp_bb, since we
+	 modify `e' and this can invalidate the subsequent count of
+	 e->src's predecessors by looking at the wrong block.  */
+      tmp_bb = e->src;
+      e = EDGE_PRED (tmp_bb, 0);
+      if (EDGE_COUNT (tmp_bb->preds) > 1
 	  || e->src == ENTRY_BLOCK_PTR)
 	break;
     }
@@ -2492,9 +2498,9 @@ check_simple_exit (struct loop *loop, ed
   if (!any_condjump_p (BB_END (exit_bb)))
     return;
 
-  ei = exit_bb->succ;
+  ei = EDGE_SUCC (exit_bb, 0);
   if (ei == e)
-    ei = ei->succ_next;
+    ei = EDGE_SUCC (exit_bb, 1);
 
   desc->out_edge = e;
   desc->in_edge = ei;
@@ -2531,7 +2537,7 @@ find_simple_exit (struct loop *loop, str
 
   for (i = 0; i < loop->num_nodes; i++)
     {
-      for (e = body[i]->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, body[i]->succs)
 	{
 	  if (flow_bb_inside_loop_p (loop, e->dest))
 	    continue;
@@ -2548,6 +2554,7 @@ find_simple_exit (struct loop *loop, str
 	    continue;
 	  *desc = act;
 	}
+      END_FOR_EACH_EDGE;
     }
 
   if (dump_file)
Index: gcc/loop-unroll.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unroll.c,v
retrieving revision 1.18
diff -u -p -w -r1.18 loop-unroll.c
--- gcc/loop-unroll.c	10 Sep 2004 11:02:24 -0000	1.18
+++ gcc/loop-unroll.c	13 Sep 2004 04:39:19 -0000
@@ -690,15 +690,15 @@ unroll_loop_constant_iterations (struct 
       basic_block exit_block = desc->in_edge->src->rbi->copy;
       /* Find a new in and out edge; they are in the last copy we have made.  */
       
-      if (exit_block->succ->dest == desc->out_edge->dest)
+      if (EDGE_SUCC (exit_block, 0)->dest == desc->out_edge->dest)
 	{
-	  desc->out_edge = exit_block->succ;
-	  desc->in_edge = exit_block->succ->succ_next;
+	  desc->out_edge = EDGE_SUCC (exit_block, 0);
+	  desc->in_edge = EDGE_SUCC (exit_block, 1);
 	}
       else
 	{
-	  desc->out_edge = exit_block->succ->succ_next;
-	  desc->in_edge = exit_block->succ;
+	  desc->out_edge = EDGE_SUCC (exit_block, 1);
+	  desc->in_edge = EDGE_SUCC (exit_block, 0);
 	}
     }
 
@@ -946,11 +946,11 @@ unroll_loop_runtime_iterations (struct l
       branch_code = compare_and_jump_seq (copy_rtx (niter), GEN_INT (j), EQ,
 					  block_label (preheader), p, NULL_RTX);
 
-      swtch = loop_split_edge_with (swtch->pred, branch_code);
+      swtch = loop_split_edge_with (EDGE_PRED (swtch, 0), branch_code);
       set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
-      swtch->succ->probability = REG_BR_PROB_BASE - p;
+      EDGE_SUCC (swtch, 0)->probability = REG_BR_PROB_BASE - p;
       e = make_edge (swtch, preheader,
-		     swtch->succ->flags & EDGE_IRREDUCIBLE_LOOP);
+		     EDGE_SUCC (swtch, 0)->flags & EDGE_IRREDUCIBLE_LOOP);
       e->probability = p;
     }
 
@@ -963,11 +963,11 @@ unroll_loop_runtime_iterations (struct l
       branch_code = compare_and_jump_seq (copy_rtx (niter), const0_rtx, EQ,
 					  block_label (preheader), p, NULL_RTX);
 
-      swtch = loop_split_edge_with (swtch->succ, branch_code);
+      swtch = loop_split_edge_with (EDGE_SUCC (swtch, 0), branch_code);
       set_immediate_dominator (CDI_DOMINATORS, preheader, swtch);
-      swtch->succ->probability = REG_BR_PROB_BASE - p;
+      EDGE_SUCC (swtch, 0)->probability = REG_BR_PROB_BASE - p;
       e = make_edge (swtch, preheader,
-		     swtch->succ->flags & EDGE_IRREDUCIBLE_LOOP);
+		     EDGE_SUCC (swtch, 0)->flags & EDGE_IRREDUCIBLE_LOOP);
       e->probability = p;
     }
 
@@ -992,15 +992,15 @@ unroll_loop_runtime_iterations (struct l
       basic_block exit_block = desc->in_edge->src->rbi->copy;
       /* Find a new in and out edge; they are in the last copy we have made.  */
       
-      if (exit_block->succ->dest == desc->out_edge->dest)
+      if (EDGE_SUCC (exit_block, 0)->dest == desc->out_edge->dest)
 	{
-	  desc->out_edge = exit_block->succ;
-	  desc->in_edge = exit_block->succ->succ_next;
+	  desc->out_edge = EDGE_SUCC (exit_block, 0);
+	  desc->in_edge = EDGE_SUCC (exit_block, 1);
 	}
       else
 	{
-	  desc->out_edge = exit_block->succ->succ_next;
-	  desc->in_edge = exit_block->succ;
+	  desc->out_edge = EDGE_SUCC (exit_block, 1);
+	  desc->in_edge = EDGE_SUCC (exit_block, 0);
 	}
     }
 
Index: gcc/loop-unswitch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/loop-unswitch.c,v
retrieving revision 1.21
diff -u -p -w -r1.21 loop-unswitch.c
--- gcc/loop-unswitch.c	10 Sep 2004 11:02:24 -0000	1.21
+++ gcc/loop-unswitch.c	13 Sep 2004 04:39:20 -0000
@@ -180,14 +180,14 @@ may_unswitch_on (basic_block bb, struct 
   enum machine_mode mode;
 
   /* BB must end in a simple conditional jump.  */
-  if (!bb->succ || !bb->succ->succ_next || bb->succ->succ_next->succ_next)
+  if (EDGE_COUNT (bb->succs) != 2)
     return NULL_RTX;
   if (!any_condjump_p (BB_END (bb)))
     return NULL_RTX;
 
   /* With branches inside loop.  */
-  if (!flow_bb_inside_loop_p (loop, bb->succ->dest)
-      || !flow_bb_inside_loop_p (loop, bb->succ->succ_next->dest))
+  if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (bb, 0)->dest)
+      || !flow_bb_inside_loop_p (loop, EDGE_SUCC (bb, 1)->dest))
     return NULL_RTX;
 
   /* It must be executed just once each iteration (because otherwise we
@@ -414,16 +414,15 @@ unswitch_loop (struct loops *loops, stru
   /* Some sanity checking.  */
   if (!flow_bb_inside_loop_p (loop, unswitch_on))
     abort ();
-  if (!unswitch_on->succ || !unswitch_on->succ->succ_next ||
-      unswitch_on->succ->succ_next->succ_next)
+  if (EDGE_COUNT (unswitch_on->succs) != 2)
     abort ();
   if (!just_once_each_iteration_p (loop, unswitch_on))
     abort ();
   if (loop->inner)
     abort ();
-  if (!flow_bb_inside_loop_p (loop, unswitch_on->succ->dest))
+  if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 0)->dest))
     abort ();
-  if (!flow_bb_inside_loop_p (loop, unswitch_on->succ->succ_next->dest))
+  if (!flow_bb_inside_loop_p (loop, EDGE_SUCC (unswitch_on, 1)->dest))
     abort ();
 
   entry = loop_preheader_edge (loop);
@@ -444,7 +443,7 @@ unswitch_loop (struct loops *loops, stru
   unswitch_on_alt = unswitch_on->rbi->copy;
   true_edge = BRANCH_EDGE (unswitch_on_alt);
   false_edge = FALLTHRU_EDGE (unswitch_on);
-  latch_edge = loop->latch->rbi->copy->succ;
+  latch_edge = EDGE_SUCC (loop->latch->rbi->copy, 0);
 
   /* Create a block with the condition.  */
   prob = true_edge->probability;
@@ -463,19 +462,19 @@ unswitch_loop (struct loops *loops, stru
   if (irred_flag)
     {
       switch_bb->flags |= BB_IRREDUCIBLE_LOOP;
-      switch_bb->succ->flags |= EDGE_IRREDUCIBLE_LOOP;
-      switch_bb->succ->succ_next->flags |= EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 0)->flags |= EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 1)->flags |= EDGE_IRREDUCIBLE_LOOP;
     }
   else
     {
       switch_bb->flags &= ~BB_IRREDUCIBLE_LOOP;
-      switch_bb->succ->flags &= ~EDGE_IRREDUCIBLE_LOOP;
-      switch_bb->succ->succ_next->flags &= ~EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 0)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
+      EDGE_SUCC (switch_bb, 1)->flags &= ~EDGE_IRREDUCIBLE_LOOP;
     }
 
   /* Loopify from the copy of LOOP body, constructing the new loop.  */
   nloop = loopify (loops, latch_edge,
-		   loop->header->rbi->copy->pred, switch_bb);
+		   EDGE_PRED (loop->header->rbi->copy, 0), switch_bb);
 
   /* Remove branches that are now unreachable in new loops.  */
   remove_path (loops, true_edge);
Index: gcc/modulo-sched.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/modulo-sched.c,v
retrieving revision 1.14
diff -u -p -w -r1.14 modulo-sched.c
--- gcc/modulo-sched.c	10 Sep 2004 11:02:24 -0000	1.14
+++ gcc/modulo-sched.c	13 Sep 2004 04:39:21 -0000
@@ -671,9 +671,9 @@ generate_prolog_epilog (partial_schedule
   rtx orig_loop_bct = NULL_RTX;
 
   /* Loop header edge.  */
-  e = ps->g->bb->pred;
+  e = EDGE_PRED (ps->g->bb, 0);
   if (e->src == ps->g->bb)
-    e = e->pred_next;
+    e = EDGE_PRED (ps->g->bb, 1);
 
   /* Generate the prolog, inserting its insns on the loop-entry edge.  */
   start_sequence ();
@@ -726,9 +726,9 @@ generate_prolog_epilog (partial_schedule
       loop_exit_label_insn = emit_label (loop_exit_label);
     }
 
-  e = ps->g->bb->succ;
+  e = EDGE_SUCC (ps->g->bb, 0);
   if (e->dest == ps->g->bb)
-    e = e->succ_next;
+    e = EDGE_SUCC (ps->g->bb, 1);
 
   e->insns.r = get_insns ();
   end_sequence ();
@@ -742,7 +742,7 @@ generate_prolog_epilog (partial_schedule
       basic_block epilog_bb = BLOCK_FOR_INSN (last_epilog_insn);
       basic_block precond_bb = BLOCK_FOR_INSN (precond_jump);
       basic_block orig_loop_bb = BLOCK_FOR_INSN (precond_exit_label_insn);
-      edge epilog_exit_edge = epilog_bb->succ;
+      edge epilog_exit_edge = EDGE_SUCC (epilog_bb, 0);
 
       /* Do loop preconditioning to take care of cases were the loop count is
 	 less than the stage count.  Update the CFG properly.  */
@@ -851,28 +851,25 @@ sms_schedule (FILE *dump_file)
 	continue;
 
       /* Check if bb has two successors, one being itself.  */
-      e = bb->succ;
-      if (!e || !e->succ_next || e->succ_next->succ_next)
+      if (EDGE_COUNT (bb->succs) != 2)
 	continue;
 
-      if (e->dest != bb && e->succ_next->dest != bb)
+      if (EDGE_SUCC (bb, 0)->dest != bb && EDGE_SUCC (bb, 1)->dest != bb)
 	continue;
 
-      if ((e->flags & EDGE_COMPLEX)
-	  || (e->succ_next->flags & EDGE_COMPLEX))
+      if ((EDGE_SUCC (bb, 0)->flags & EDGE_COMPLEX)
+	  || (EDGE_SUCC (bb, 1)->flags & EDGE_COMPLEX))
 	continue;
 
       /* Check if bb has two predecessors, one being itself.  */
-      /* In view of above tests, suffices to check e->pred_next->pred_next?  */
-      e = bb->pred;
-      if (!e || !e->pred_next || e->pred_next->pred_next)
+      if (EDGE_COUNT (bb->preds) != 2)
 	continue;
 
-      if (e->src != bb && e->pred_next->src != bb)
+      if (EDGE_PRED (bb, 0)->src != bb && EDGE_PRED (bb, 1)->src != bb)
 	continue;
 
-      if ((e->flags & EDGE_COMPLEX)
-	  || (e->pred_next->flags & EDGE_COMPLEX))
+      if ((EDGE_PRED (bb, 0)->flags & EDGE_COMPLEX)
+	  || (EDGE_PRED (bb, 1)->flags & EDGE_COMPLEX))
 	continue;
 
       /* For debugging.  */
@@ -884,9 +881,9 @@ sms_schedule (FILE *dump_file)
 	}
 
       get_block_head_tail (bb->index, &head, &tail);
-      pre_header_edge = bb->pred;
-      if (bb->pred->src != bb)
-	pre_header_edge = bb->pred->pred_next;
+      pre_header_edge = EDGE_PRED (bb, 0);
+      if (EDGE_PRED (bb, 0)->src != bb)
+	pre_header_edge = EDGE_PRED (bb, 1);
 
       /* Perfrom SMS only on loops that their average count is above threshold.  */
       if (bb->count < pre_header_edge->count * SMS_LOOP_AVERAGE_COUNT_THRESHOLD)
@@ -926,9 +923,9 @@ sms_schedule (FILE *dump_file)
       if ( !(count_reg = doloop_register_get (tail, &comp)))
 	continue;
 
-      e = bb->pred;
+      e = EDGE_PRED (bb, 0);
       if (e->src == bb)
-	pre_header = e->pred_next->src;
+	pre_header = EDGE_PRED (bb, 1)->src;
       else
 	pre_header = e->src;
 
@@ -987,9 +984,9 @@ sms_schedule (FILE *dump_file)
 
       get_block_head_tail (g->bb->index, &head, &tail);
 
-      pre_header_edge = g->bb->pred;
-      if (g->bb->pred->src != g->bb)
-	pre_header_edge = g->bb->pred->pred_next;
+      pre_header_edge = EDGE_PRED (g->bb, 0);
+      if (EDGE_PRED (g->bb, 0)->src != g->bb)
+	pre_header_edge = EDGE_PRED (g->bb, 1);
 
       if (stats_file)
 	{
Index: gcc/postreload-gcse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/postreload-gcse.c,v
retrieving revision 2.4
diff -u -p -w -r2.4 postreload-gcse.c
--- gcc/postreload-gcse.c	10 Sep 2004 11:02:26 -0000	2.4
+++ gcc/postreload-gcse.c	13 Sep 2004 04:39:21 -0000
@@ -1037,10 +1037,10 @@ bb_has_well_behaved_predecessors (basic_
 {
   edge pred;
 
-  if (! bb->pred)
+  if (EDGE_COUNT (bb->preds) == 0)
     return false;
 
-  for (pred = bb->pred; pred != NULL; pred = pred->pred_next)
+  FOR_EACH_EDGE (pred, bb->preds)
     {
       if ((pred->flags & EDGE_ABNORMAL) && EDGE_CRITICAL_P (pred))
 	return false;
@@ -1048,6 +1048,7 @@ bb_has_well_behaved_predecessors (basic_
       if (JUMP_TABLE_DATA_P (BB_END (pred->src)))
 	return false;
     }
+  END_FOR_EACH_EDGE;
   return true;
 }
 
@@ -1097,7 +1098,7 @@ eliminate_partially_redundant_load (basi
     return;
 
   /* Check potential for replacing load with copy for predecessors.  */
-  for (pred = bb->pred; pred; pred = pred->pred_next)
+  FOR_EACH_EDGE (pred, bb->preds)
     {
       rtx next_pred_bb_end;
 
@@ -1159,6 +1160,7 @@ eliminate_partially_redundant_load (basi
 	    rollback_unoccr = unoccr;
 	}
     }
+  END_FOR_EACH_EDGE;
 
   if (/* No load can be replaced by copy.  */
       npred_ok == 0
Index: gcc/predict.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/predict.c,v
retrieving revision 1.116
diff -u -p -w -r1.116 predict.c
--- gcc/predict.c	10 Sep 2004 11:02:26 -0000	1.116
+++ gcc/predict.c	13 Sep 2004 04:39:22 -0000
@@ -247,7 +247,7 @@ can_predict_insn_p (rtx insn)
 {
   return (JUMP_P (insn)
 	  && any_condjump_p (insn)
-	  && BLOCK_FOR_INSN (insn)->succ->succ_next);
+	  && EDGE_COUNT (BLOCK_FOR_INSN (insn)->succs) >= 2);
 }
 
 /* Predict edge E by given predictor if possible.  */
@@ -286,13 +286,17 @@ static void
 dump_prediction (FILE *file, enum br_predictor predictor, int probability,
 		 basic_block bb, int used)
 {
-  edge e = bb->succ;
+  edge e;
 
   if (!file)
     return;
 
-  while (e && (e->flags & EDGE_FALLTHRU))
-    e = e->succ_next;
+  FOR_EACH_EDGE (e, bb->succs)
+    {
+      if (! (e->flags & EDGE_FALLTHRU))
+	break;
+    }
+  END_FOR_EACH_EDGE;
 
   fprintf (file, "  %s heuristics%s: %.1f%%",
 	   predictor_info[predictor].name,
@@ -321,15 +325,22 @@ set_even_probabilities (basic_block bb)
   int nedges = 0;
   edge e;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (!(e->flags & (EDGE_EH | EDGE_FAKE)))
       nedges ++;
-  for (e = bb->succ; e; e = e->succ_next)
+    }
+  END_FOR_EACH_EDGE;
+
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (!(e->flags & (EDGE_EH | EDGE_FAKE)))
       e->probability = (REG_BR_PROB_BASE + nedges / 2) / nedges;
     else
       e->probability = 0;
 }
+  END_FOR_EACH_EDGE;
+}
 
 /* Combine all REG_BR_PRED notes into single probability and attach REG_BR_PROB
    note if not already present.  Remove now useless REG_BR_PRED notes.  */
@@ -429,7 +440,7 @@ combine_predictions_for_insn (rtx insn, 
 
       /* Save the prediction into CFG in case we are seeing non-degenerated
 	 conditional jump.  */
-      if (bb->succ->succ_next)
+      if (EDGE_COUNT (bb->succs) > 1)
 	{
 	  BRANCH_EDGE (bb)->probability = combined_probability;
 	  FALLTHRU_EDGE (bb)->probability
@@ -454,7 +465,8 @@ combine_predictions_for_bb (FILE *file, 
   int nedges = 0;
   edge e, first = NULL, second = NULL;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (!(e->flags & (EDGE_EH | EDGE_FAKE)))
       {
         nedges ++;
@@ -463,6 +475,8 @@ combine_predictions_for_bb (FILE *file, 
 	if (!first)
 	  first = e;
       }
+    }
+  END_FOR_EACH_EDGE;
 
   /* When there is no successor or only one choice, prediction is easy. 
 
@@ -537,7 +551,7 @@ combine_predictions_for_bb (FILE *file, 
       int predictor = pred->predictor;
       int probability = pred->probability;
 
-      if (pred->edge != bb->succ)
+      if (pred->edge != EDGE_SUCC (bb, 0))
 	probability = REG_BR_PROB_BASE - probability;
       dump_prediction (file, predictor, probability, bb,
 		       !first_match || best_predictor == predictor);
@@ -615,18 +629,22 @@ predict_loops (struct loops *loops_info,
 
 	  /* Loop branch heuristics - predict an edge back to a
 	     loop's head as taken.  */
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->dest == loop->header
 		&& e->src == loop->latch)
 	      {
 		header_found = 1;
 		predict_edge_def (e, PRED_LOOP_BRANCH, TAKEN);
 	      }
+	    }
+	  END_FOR_EACH_EDGE;
 
 	  /* Loop exit heuristics - predict an edge exiting the loop if the
 	     conditional has no loop header successors as not taken.  */
 	  if (!header_found)
-	    for (e = bb->succ; e; e = e->succ_next)
+	    FOR_EACH_EDGE (e, bb->succs)
+	      {
 	      if (e->dest->index < 0
 		  || !flow_bb_inside_loop_p (loop, e->dest))
 		predict_edge
@@ -635,6 +653,8 @@ predict_loops (struct loops *loops_info,
 		    - predictor_info [(int) PRED_LOOP_EXIT].hitrate)
 		   / exits);
 	}
+	    END_FOR_EACH_EDGE;
+	}
       
       /* Free basic blocks from get_loop_body.  */
       free (bbs);
@@ -766,14 +786,14 @@ estimate_probability (struct loops *loop
       if (! can_predict_insn_p (last_insn))
 	continue;
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  /* Predict early returns to be probable, as we've already taken
 	     care for error returns and other are often used for fast paths
 	     trought function.  */
 	  if ((e->dest == EXIT_BLOCK_PTR
-	       || (e->dest->succ && !e->dest->succ->succ_next
-		   && e->dest->succ->dest == EXIT_BLOCK_PTR))
+	       || (EDGE_COUNT (e->dest->succs) == 1
+		   && EDGE_SUCC (e->dest, 0)->dest == EXIT_BLOCK_PTR))
 	       && !predicted_by_p (bb, PRED_NULL_RETURN)
 	       && !predicted_by_p (bb, PRED_CONST_RETURN)
 	       && !predicted_by_p (bb, PRED_NEGATIVE_RETURN)
@@ -804,6 +824,7 @@ estimate_probability (struct loops *loop
 		  }
 	    }
 	}
+      END_FOR_EACH_EDGE;
       bb_estimate_probability_locally (bb);
     }
 
@@ -811,7 +832,7 @@ estimate_probability (struct loops *loop
   FOR_EACH_BB (bb)
     if (JUMP_P (BB_END (bb))
 	&& any_condjump_p (BB_END (bb))
-	&& bb->succ->succ_next != NULL)
+	&& EDGE_COUNT (bb->succs) >= 2)
       combine_predictions_for_insn (BB_END (bb), bb);
 
   remove_fake_exit_edges ();
@@ -829,16 +850,20 @@ estimate_probability (struct loops *loop
 	  int nedges = 0;
 	  edge e;
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      nedges++;
 	      if (e->probability != 0)
 		break;
 	    }
+	  END_FOR_EACH_EDGE;
 	  if (!e)
-	    for (e = bb->succ; e; e = e->succ_next)
+	    FOR_EACH_EDGE (e, bb->succs)
+	      {
 	      e->probability = (REG_BR_PROB_BASE + nedges / 2) / nedges;
 	}
+	    END_FOR_EACH_EDGE;
+	}
     }
   estimate_bb_frequencies (loops_info);
   free_dominance_info (CDI_POST_DOMINATORS);
@@ -867,9 +892,12 @@ tree_predict_by_opcode (basic_block bb)
 
   if (!stmt || TREE_CODE (stmt) != COND_EXPR)
     return;
-  for (then_edge = bb->succ; then_edge; then_edge = then_edge->succ_next)
+  FOR_EACH_EDGE (then_edge, bb->succs)
+    {
     if (then_edge->flags & EDGE_TRUE_VALUE)
        break;
+    }
+  END_FOR_EACH_EDGE;
   cond = TREE_OPERAND (stmt, 0);
   if (TREE_CODE_CLASS (TREE_CODE (cond)) != '<')
     return;
@@ -981,14 +1009,14 @@ tree_estimate_probability (void)
     {
       edge e;
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  /* Predict early returns to be probable, as we've already taken
 	     care for error returns and other are often used for fast paths
 	     trought function.  */
 	  if ((e->dest == EXIT_BLOCK_PTR
-	       || (e->dest->succ && !e->dest->succ->succ_next
-		   && e->dest->succ->dest == EXIT_BLOCK_PTR))
+	       || (EDGE_COUNT (e->dest->succs) == 1
+		   && EDGE_SUCC (e->dest, 0)->dest == EXIT_BLOCK_PTR))
 	       && !predicted_by_p (bb, PRED_NULL_RETURN)
 	       && !predicted_by_p (bb, PRED_CONST_RETURN)
 	       && !predicted_by_p (bb, PRED_NEGATIVE_RETURN)
@@ -1024,6 +1052,7 @@ tree_estimate_probability (void)
 		}
 	    }
 	}
+      END_FOR_EACH_EDGE;
       tree_predict_by_opcode (bb);
     }
   FOR_EACH_BB (bb)
@@ -1123,8 +1152,8 @@ last_basic_block_p (basic_block bb)
 
   return (bb->next_bb == EXIT_BLOCK_PTR
 	  || (bb->next_bb->next_bb == EXIT_BLOCK_PTR
-	      && bb->succ && !bb->succ->succ_next
-	      && bb->succ->dest->next_bb == EXIT_BLOCK_PTR));
+	      && EDGE_COUNT (bb->succs) == 1
+	      && EDGE_SUCC (bb, 0)->dest->next_bb == EXIT_BLOCK_PTR));
 }
 
 /* This is used to carry information about basic blocks.  It is
@@ -1179,7 +1208,8 @@ propagate_freq (struct loop *loop)
 	{
 	  int count = 0;
 
-	  for (e = bb->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, bb->preds)
+	    {
 	    if (BLOCK_INFO (e->src)->tovisit && !(e->flags & EDGE_DFS_BACK))
 	      count++;
 	    else if (BLOCK_INFO (e->src)->tovisit
@@ -1187,6 +1217,8 @@ propagate_freq (struct loop *loop)
 	      fprintf (dump_file,
 		       "Irreducible region hit, ignoring edge to %i->%i\n",
 		       e->src->index, bb->index);
+	    }
+	  END_FOR_EACH_EDGE;
 	  BLOCK_INFO (bb)->npredecessors = count;
 	}
     }
@@ -1207,12 +1239,16 @@ propagate_freq (struct loop *loop)
       if (bb != head)
 	{
 #ifdef ENABLE_CHECKING
-	  for (e = bb->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, bb->preds)
+	    {
 	    if (BLOCK_INFO (e->src)->tovisit && !(e->flags & EDGE_DFS_BACK))
 	      abort ();
+	    }
+	  END_FOR_EACH_EDGE;
 #endif
 
-	  for (e = bb->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, bb->preds)
+	    {
 	    if (EDGE_INFO (e)->back_edge)
 	      {
 		sreal_add (&cyclic_probability, &cyclic_probability,
@@ -1231,6 +1267,8 @@ propagate_freq (struct loop *loop)
 		sreal_mul (&tmp, &tmp, &real_inv_br_prob_base);
 		sreal_add (&frequency, &frequency, &tmp);
 	      }
+	    }
+	  END_FOR_EACH_EDGE;
 
 	  if (sreal_compare (&cyclic_probability, &real_zero) == 0)
 	    {
@@ -1257,7 +1295,8 @@ propagate_freq (struct loop *loop)
       BLOCK_INFO (bb)->tovisit = 0;
 
       /* Compute back edge frequencies.  */
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (e->dest == head)
 	  {
 	    sreal tmp;
@@ -1271,9 +1310,12 @@ propagate_freq (struct loop *loop)
 	    sreal_mul (&EDGE_INFO (e)->back_edge_prob,
 		       &tmp, &real_inv_br_prob_base);
 	  }
+	}
+      END_FOR_EACH_EDGE;
 
       /* Propagate to successor blocks.  */
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (!(e->flags & EDGE_DFS_BACK)
 	    && BLOCK_INFO (e->dest)->npredecessors)
 	  {
@@ -1289,6 +1331,8 @@ propagate_freq (struct loop *loop)
 	      }
 	   }
     }
+      END_FOR_EACH_EDGE;
+    }
 }
 
 /* Estimate probabilities of loopback edges in loops at same nest level.  */
@@ -1306,7 +1350,8 @@ estimate_loops_at_level (struct loop *fi
 
       estimate_loops_at_level (loop->inner);
 
-      if (loop->latch->succ)  /* Do not do this for dummy function loop.  */
+      /* Do not do this for dummy function loop.  */
+      if (EDGE_COUNT (loop->latch->succs) > 0)
 	{
 	  /* Find current loop back edge and mark it.  */
 	  e = loop_latch_edge (loop);
@@ -1407,7 +1452,7 @@ estimate_bb_frequencies (struct loops *l
 
       mark_dfs_back_edges ();
 
-      ENTRY_BLOCK_PTR->succ->probability = REG_BR_PROB_BASE;
+      EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->probability = REG_BR_PROB_BASE;
 
       /* Set up block info for each basic block.  */
       alloc_aux_for_blocks (sizeof (struct block_info_def));
@@ -1417,13 +1462,14 @@ estimate_bb_frequencies (struct loops *l
 	  edge e;
 
 	  BLOCK_INFO (bb)->tovisit = 0;
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      sreal_init (&EDGE_INFO (e)->back_edge_prob, e->probability, 0);
 	      sreal_mul (&EDGE_INFO (e)->back_edge_prob,
 			 &EDGE_INFO (e)->back_edge_prob,
 			 &real_inv_br_prob_base);
 	    }
+	  END_FOR_EACH_EDGE;
 	}
 
       /* First compute probabilities locally for each loop from innermost
Index: gcc/profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.140
diff -u -p -w -r1.140 profile.c
--- gcc/profile.c	11 Sep 2004 19:50:17 -0000	1.140
+++ gcc/profile.c	13 Sep 2004 04:39:22 -0000
@@ -143,7 +143,7 @@ instrument_edges (struct edge_list *el)
     {
       edge e;
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  struct edge_info *inf = EDGE_INFO (e);
 
@@ -158,6 +158,7 @@ instrument_edges (struct edge_list *el)
 	      (profile_hooks->gen_edge_profiler) (num_instr_edges++, e);
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   total_num_blocks_created += num_edges;
@@ -239,10 +240,13 @@ get_exec_counts (void)
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
     {
       edge e;
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (!EDGE_INFO (e)->ignore && !EDGE_INFO (e)->on_tree)
 	  num_edges++;
     }
+      END_FOR_EACH_EDGE;
+    }
 
   counts = get_coverage_counts (GCOV_COUNTER_ARCS, num_edges, &profile_info);
   if (!counts)
@@ -295,14 +299,20 @@ compute_branch_probabilities (void)
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
     {
       edge e;
-
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (!EDGE_INFO (e)->ignore)
 	  BB_INFO (bb)->succ_count++;
-      for (e = bb->pred; e; e = e->pred_next)
+	}
+      END_FOR_EACH_EDGE;
+
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (!EDGE_INFO (e)->ignore)
 	  BB_INFO (bb)->pred_count++;
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Avoid predicting entry on exit nodes.  */
   BB_INFO (EXIT_BLOCK_PTR)->succ_count = 2;
@@ -317,7 +327,9 @@ compute_branch_probabilities (void)
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
     {
       edge e;
-      for (e = bb->succ; e; e = e->succ_next)
+
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (!EDGE_INFO (e)->ignore && !EDGE_INFO (e)->on_tree)
 	  {
 	    num_edges++;
@@ -345,6 +357,8 @@ compute_branch_probabilities (void)
 	      }
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 
   if (dump_file)
     fprintf (dump_file, "\n%d edge counts read\n", num_edges);
@@ -382,8 +396,9 @@ compute_branch_probabilities (void)
 		  edge e;
 		  gcov_type total = 0;
 
-		  for (e = bb->succ; e; e = e->succ_next)
+		  FOR_EACH_EDGE (e, bb->succs)
 		    total += e->count;
+		  END_FOR_EACH_EDGE;
 		  bb->count = total;
 		  bi->count_valid = 1;
 		  changes = 1;
@@ -393,8 +408,9 @@ compute_branch_probabilities (void)
 		  edge e;
 		  gcov_type total = 0;
 
-		  for (e = bb->pred; e; e = e->pred_next)
+		  FOR_EACH_EDGE (e, bb->preds)
 		    total += e->count;
+		  END_FOR_EACH_EDGE;
 		  bb->count = total;
 		  bi->count_valid = 1;
 		  changes = 1;
@@ -409,13 +425,17 @@ compute_branch_probabilities (void)
 
 		  /* One of the counts will be invalid, but it is zero,
 		     so adding it in also doesn't hurt.  */
-		  for (e = bb->succ; e; e = e->succ_next)
+		  FOR_EACH_EDGE (e, bb->succs)
 		    total += e->count;
+		  END_FOR_EACH_EDGE;
 
 		  /* Seedgeh for the invalid edge, and set its count.  */
-		  for (e = bb->succ; e; e = e->succ_next)
+		  FOR_EACH_EDGE (e, bb->succs)
+		    {
 		    if (! EDGE_INFO (e)->count_valid && ! EDGE_INFO (e)->ignore)
 		      break;
+		    }
+		  END_FOR_EACH_EDGE;
 
 		  /* Calculate count for remaining edge by conservation.  */
 		  total = bb->count - total;
@@ -436,13 +456,17 @@ compute_branch_probabilities (void)
 
 		  /* One of the counts will be invalid, but it is zero,
 		     so adding it in also doesn't hurt.  */
-		  for (e = bb->pred; e; e = e->pred_next)
+		  FOR_EACH_EDGE (e, bb->preds)
 		    total += e->count;
+		  END_FOR_EACH_EDGE;
 
 		  /* Search for the invalid edge, and set its count.  */
-		  for (e = bb->pred; e; e = e->pred_next)
+		  FOR_EACH_EDGE (e, bb->preds)
+		    {
 		    if (!EDGE_INFO (e)->count_valid && !EDGE_INFO (e)->ignore)
 		      break;
+		    }
+		  END_FOR_EACH_EDGE;
 
 		  /* Calculate count for remaining edge by conservation.  */
 		  total = bb->count - total + e->count;
@@ -493,7 +517,7 @@ compute_branch_probabilities (void)
 		 bb->index, (int)bb->count);
 	  bb->count = 0;
 	}
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  /* Function may return twice in the cased the called function is
 	     setjmp or calls fork, but we can't represent this by extra
@@ -516,13 +540,19 @@ compute_branch_probabilities (void)
 	      e->count = bb->count / 2;
 	    }
 	}
+      END_FOR_EACH_EDGE;
+
       if (bb->count)
 	{
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    e->probability = (e->count * REG_BR_PROB_BASE + bb->count / 2) / bb->count;
+	    }
+	  END_FOR_EACH_EDGE;
+
 	  if (bb->index >= 0
 	      && block_ends_with_condjump_p (bb)
-	      && bb->succ->succ_next)
+	      && EDGE_COUNT (bb->succs) >= 2)
 	    {
 	      int prob;
 	      edge e;
@@ -530,9 +560,12 @@ compute_branch_probabilities (void)
 
 	      /* Find the branch edge.  It is possible that we do have fake
 		 edges here.  */
-	      for (e = bb->succ; e->flags & (EDGE_FAKE | EDGE_FALLTHRU);
-		   e = e->succ_next)
-		continue; /* Loop body has been intentionally left blank.  */
+	      FOR_EACH_EDGE (e, bb->succs)
+		{
+		  if (!(e->flags & (EDGE_FAKE | EDGE_FALLTHRU)))
+		    break;
+		}
+	      END_FOR_EACH_EDGE;
 
 	      prob = e->probability;
 	      index = prob * 20 / REG_BR_PROB_BASE;
@@ -566,27 +599,35 @@ compute_branch_probabilities (void)
 	{
 	  int total = 0;
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (!(e->flags & (EDGE_COMPLEX | EDGE_FAKE)))
 	      total ++;
+	    }
+	  END_FOR_EACH_EDGE;
 	  if (total)
 	    {
-	      for (e = bb->succ; e; e = e->succ_next)
+	      FOR_EACH_EDGE (e, bb->succs)
+		{
 		if (!(e->flags & (EDGE_COMPLEX | EDGE_FAKE)))
 		  e->probability = REG_BR_PROB_BASE / total;
 		else
 		  e->probability = 0;
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 	  else
 	    {
-	      for (e = bb->succ; e; e = e->succ_next)
-		total ++;
-	      for (e = bb->succ; e; e = e->succ_next)
+	      total += EDGE_COUNT (bb->succs);
+	      FOR_EACH_EDGE (e, bb->succs)
+		{
 		e->probability = REG_BR_PROB_BASE / total;
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 	  if (bb->index >= 0
 	      && block_ends_with_condjump_p (bb)
-	      && bb->succ->succ_next)
+	      && EDGE_COUNT (bb->succs) >= 2)
 	    num_branches++, num_never_executed;
 	}
     }
@@ -783,7 +824,7 @@ branch_prob (void)
          with the extra edges because that would result in flowgraph that
 	 needs to have fake edges outside the spanning tree.  */
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
 	       && e->dest != EXIT_BLOCK_PTR)
@@ -791,7 +832,9 @@ branch_prob (void)
 	  if (e->dest == EXIT_BLOCK_PTR)
 	    have_exit_edge = 1;
 	}
-      for (e = bb->pred; e; e = e->pred_next)
+      END_FOR_EACH_EDGE;
+
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  if ((e->flags & (EDGE_ABNORMAL | EDGE_ABNORMAL_CALL))
 	       && e->src != ENTRY_BLOCK_PTR)
@@ -799,6 +842,7 @@ branch_prob (void)
 	  if (e->src == ENTRY_BLOCK_PTR)
 	    have_entry_edge = 1;
 	}
+      END_FOR_EACH_EDGE;
 
       if (need_exit_edge && !have_exit_edge)
 	{
@@ -910,7 +954,7 @@ branch_prob (void)
 	  offset = gcov_write_tag (GCOV_TAG_ARCS);
 	  gcov_write_unsigned (BB_TO_GCOV_INDEX (bb));
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      struct edge_info *i = EDGE_INFO (e);
 	      if (!i->ignore)
@@ -934,6 +978,7 @@ branch_prob (void)
 		  gcov_write_unsigned (flag_bits);
 	        }
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  gcov_write_length (offset);
 	}
@@ -1031,9 +1076,9 @@ branch_prob (void)
 
 	      /* Notice GOTO expressions we elliminated while constructing the
 	         CFG.  */
-	      if (bb->succ && !bb->succ->succ_next && bb->succ->goto_locus)
+	      if (EDGE_COUNT (bb->succs) == 1 && EDGE_SUCC (bb, 0)->goto_locus)
 	        {
-		  curr_location = bb->succ->goto_locus;
+		  curr_location = EDGE_SUCC (bb, 0)->goto_locus;
 	          output_location (curr_location->file, curr_location->line, &offset, bb);
 	        }
 
Index: gcc/ra-build.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-build.c,v
retrieving revision 1.33
diff -u -p -w -r1.33 ra-build.c
--- gcc/ra-build.c	9 Sep 2004 17:19:09 -0000	1.33
+++ gcc/ra-build.c	13 Sep 2004 04:39:24 -0000
@@ -924,6 +924,7 @@ live_in (struct df *df, struct curr_use 
      are allowed.  */
   while (1)
     {
+      unsigned int i;
       int uid = INSN_UID (insn);
       basic_block bb = BLOCK_FOR_INSN (insn);
       number_seen[uid]++;
@@ -940,7 +941,7 @@ live_in (struct df *df, struct curr_use 
 	  edge e;
 	  unsigned HOST_WIDE_INT undef = use->undefined;
 	  struct ra_bb_info *info = (struct ra_bb_info *) bb->aux;
-	  if ((e = bb->pred) == NULL)
+	  if (EDGE_COUNT (bb->preds) == 0)
 	    return;
 	  /* We now check, if we already traversed the predecessors of this
 	     block for the current pass and the current set of undefined
@@ -952,8 +953,9 @@ live_in (struct df *df, struct curr_use 
 	  info->pass = loc_vpass;
 	  info->undefined = undef;
 	  /* All but the last predecessor are handled recursively.  */
-	  for (; e->pred_next; e = e->pred_next)
+	  for (e = NULL, i = 0; i < EDGE_COUNT (bb->preds) - 1; i++)
 	    {
+	      e = EDGE_PRED (bb, i);
 	      insn = live_in_edge (df, use, e);
 	      if (insn)
 		live_in (df, use, insn);
Index: gcc/ra-rewrite.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-rewrite.c,v
retrieving revision 1.26
diff -u -p -w -r1.26 ra-rewrite.c
--- gcc/ra-rewrite.c	9 Sep 2004 17:19:11 -0000	1.26
+++ gcc/ra-rewrite.c	13 Sep 2004 04:39:24 -0000
@@ -1344,11 +1344,16 @@ rewrite_program2 (bitmap new_deaths)
 	  int in_ir = 0;
 	  edge e;
 	  int num = 0;
+
 	  HARD_REG_SET cum_colors, colors;
 	  CLEAR_HARD_REG_SET (cum_colors);
-	  for (e = bb->pred; e && num < 5; e = e->pred_next, num++)
+
+	  FOR_EACH_EDGE (e, bb->preds)
 	    {
 	      int j;
+
+	      if (num >= 5)
+		break;
 	      CLEAR_HARD_REG_SET (colors);
 	      EXECUTE_IF_SET_IN_BITMAP (live_at_end[e->src->index], 0, j,
 		{
@@ -1358,7 +1363,10 @@ rewrite_program2 (bitmap new_deaths)
 		    update_spill_colors (&colors, web, 1);
 		});
 	      IOR_HARD_REG_SET (cum_colors, colors);
+	      num++;
 	    }
+	  END_FOR_EACH_EDGE;
+
 	  if (num == 5)
 	    in_ir = 1;
 
Index: gcc/ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.20
diff -u -p -w -r1.20 ra.c
--- gcc/ra.c	9 Sep 2004 17:19:11 -0000	1.20
+++ gcc/ra.c	13 Sep 2004 04:39:25 -0000
@@ -682,7 +682,8 @@ reg_alloc (void)
   if (last)
     {
       edge e;
-      for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+
+      FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
 	{
 	  basic_block bb = e->src;
 	  last = BB_END (bb);
@@ -696,6 +697,7 @@ reg_alloc (void)
 	      emit_insn_after (insns, last);
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   /* Setup debugging levels.  */
Index: gcc/recog.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/recog.c,v
retrieving revision 1.210
diff -u -p -w -r1.210 recog.c
--- gcc/recog.c	9 Sep 2004 17:19:12 -0000	1.210
+++ gcc/recog.c	13 Sep 2004 04:39:26 -0000
@@ -3117,10 +3117,12 @@ peephole2_optimize (FILE *dump_file ATTR
 		    {
 		      edge eh_edge;
 
-		      for (eh_edge = bb->succ; eh_edge
-			   ; eh_edge = eh_edge->succ_next)
+		      FOR_EACH_EDGE (eh_edge, bb->succs)
+			{
 			if (eh_edge->flags & (EDGE_EH | EDGE_ABNORMAL_CALL))
 			  break;
+			}
+		      END_FOR_EACH_EDGE;
 
 		      for (x = try ; x != before_try ; x = PREV_INSN (x))
 			if (CALL_P (x)
Index: gcc/reg-stack.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reg-stack.c,v
retrieving revision 1.163
diff -u -p -w -r1.163 reg-stack.c
--- gcc/reg-stack.c	9 Sep 2004 17:19:12 -0000	1.163
+++ gcc/reg-stack.c	13 Sep 2004 04:39:28 -0000
@@ -442,11 +442,15 @@ reg_to_stack (FILE *file)
   FOR_EACH_BB_REVERSE (bb)
     {
       edge e;
-      for (e = bb->pred; e; e = e->pred_next)
+
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (!(e->flags & EDGE_DFS_BACK)
 	    && e->src != ENTRY_BLOCK_PTR)
 	  BLOCK_INFO (bb)->predecessors++;
     }
+      END_FOR_EACH_EDGE;
+    }
 
   /* Create the replacement registers up front.  */
   for (i = FIRST_STACK_REG; i <= LAST_STACK_REG; i++)
@@ -2557,7 +2561,7 @@ convert_regs_entry (void)
      Note that we are inserting converted code here.  This code is
      never seen by the convert_regs pass.  */
 
-  for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
     {
       basic_block block = e->dest;
       block_info bi = BLOCK_INFO (block);
@@ -2579,6 +2583,7 @@ convert_regs_entry (void)
 
       bi->stack_in.top = top;
     }
+  END_FOR_EACH_EDGE;
 
   return inserted;
 }
@@ -2717,7 +2722,7 @@ compensate_edge (edge e, FILE *file)
      instead of to the edge, because emit_swap can do minimal
      insn scheduling.  We can do this when there is only one
      edge out, and it is not abnormal.  */
-  else if (block->succ->succ_next == NULL && !(e->flags & EDGE_ABNORMAL))
+  else if (EDGE_COUNT (block->succs) == 1 && !(e->flags & EDGE_ABNORMAL))
     {
       /* change_stack kills values in regstack.  */
       tmpstack = regstack;
@@ -2774,7 +2779,7 @@ convert_regs_1 (FILE *file, basic_block 
      if multiple such exists, take one with largest count, prefer critical
      one (as splitting critical edges is more expensive), or one with lowest
      index, to avoid random changes with different orders of the edges.  */
-  for (e = block->pred; e ; e = e->pred_next)
+  FOR_EACH_EDGE (e, block->preds)
     {
       if (e->flags & EDGE_DFS_BACK)
 	;
@@ -2797,6 +2802,7 @@ convert_regs_1 (FILE *file, basic_block 
       else if (e->src->index < beste->src->index)
 	beste = e;
     }
+  END_FOR_EACH_EDGE;
 
   /* Initialize stack at block entry.  */
   if (bi->stack_in.top == -2)
@@ -2923,7 +2929,7 @@ convert_regs_1 (FILE *file, basic_block 
   bi->stack_out = regstack;
 
   /* Compensate the back edges, as those wasn't visited yet.  */
-  for (e = block->succ; e ; e = e->succ_next)
+  FOR_EACH_EDGE (e, block->succs)
     {
       if (e->flags & EDGE_DFS_BACK
 	  || (e->dest == EXIT_BLOCK_PTR))
@@ -2933,7 +2939,9 @@ convert_regs_1 (FILE *file, basic_block 
 	  inserted |= compensate_edge (e, file);
 	}
     }
-  for (e = block->pred; e ; e = e->pred_next)
+  END_FOR_EACH_EDGE;
+
+  FOR_EACH_EDGE (e, block->preds)
     {
       if (e != beste && !(e->flags & EDGE_DFS_BACK)
 	  && e->src != ENTRY_BLOCK_PTR)
@@ -2942,6 +2950,7 @@ convert_regs_1 (FILE *file, basic_block 
 	  inserted |= compensate_edge (e, file);
 	}
     }
+  END_FOR_EACH_EDGE;
 
   return inserted;
 }
@@ -2983,13 +2992,16 @@ convert_regs_2 (FILE *file, basic_block 
 	 stack the successor in all cases and hand over the task of
 	 fixing up the discrepancy to convert_regs_1.  */
 
-      for (e = block->succ; e ; e = e->succ_next)
+      FOR_EACH_EDGE (e, block->succs)
+	{
 	if (! (e->flags & EDGE_DFS_BACK))
 	  {
 	    BLOCK_INFO (e->dest)->predecessors--;
 	    if (!BLOCK_INFO (e->dest)->predecessors)
 	       *sp++ = e->dest;
 	  }
+	}
+      END_FOR_EACH_EDGE;
 
       inserted |= convert_regs_1 (file, block);
       BLOCK_INFO (block)->done = 1;
@@ -3022,8 +3034,12 @@ convert_regs (FILE *file)
      prevent double fxch that often appears at the head of a loop.  */
 
   /* Process all blocks reachable from all entry points.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e ; e = e->succ_next)
+
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+    {
     inserted |= convert_regs_2 (file, e->dest);
+    }
+  END_FOR_EACH_EDGE;
 
   /* ??? Process all unreachable blocks.  Though there's no excuse
      for keeping these even when not optimizing.  */
Index: gcc/regrename.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regrename.c,v
retrieving revision 1.87
diff -u -p -w -r1.87 regrename.c
--- gcc/regrename.c	9 Sep 2004 17:19:12 -0000	1.87
+++ gcc/regrename.c	13 Sep 2004 04:39:30 -0000
@@ -1750,14 +1750,13 @@ copyprop_hardreg_forward (void)
 	 processed, begin with the value data that was live at
 	 the end of the predecessor block.  */
       /* ??? Ought to use more intelligent queuing of blocks.  */
-      if (bb->pred)
-	for (bbp = bb; bbp && bbp != bb->pred->src; bbp = bbp->prev_bb);
-      if (bb->pred
-	  && ! bb->pred->pred_next
-	  && ! (bb->pred->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
-	  && bb->pred->src != ENTRY_BLOCK_PTR
+      if (EDGE_COUNT (bb->preds) > 0)
+	for (bbp = bb; bbp && bbp != EDGE_PRED (bb, 0)->src; bbp = bbp->prev_bb);
+      if (EDGE_COUNT (bb->preds) == 1
+	  && ! (EDGE_PRED (bb, 0)->flags & (EDGE_ABNORMAL_CALL | EDGE_EH))
+	  && EDGE_PRED (bb, 0)->src != ENTRY_BLOCK_PTR
 	  && bbp)
-	all_vd[bb->index] = all_vd[bb->pred->src->index];
+	all_vd[bb->index] = all_vd[EDGE_PRED (bb, 0)->src->index];
       else
 	init_value_data (all_vd + bb->index);
 
Index: gcc/reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.444
diff -u -p -w -r1.444 reload1.c
--- gcc/reload1.c	9 Sep 2004 17:19:12 -0000	1.444
+++ gcc/reload1.c	13 Sep 2004 04:39:36 -0000
@@ -8034,7 +8034,7 @@ fixup_abnormal_edges (void)
 
       /* Look for cases we are interested in - calls or instructions causing
          exceptions.  */
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (e->flags & EDGE_ABNORMAL_CALL)
 	    break;
@@ -8042,14 +8042,21 @@ fixup_abnormal_edges (void)
 	      == (EDGE_ABNORMAL | EDGE_EH))
 	    break;
 	}
+      END_FOR_EACH_EDGE;
+
       if (e && !CALL_P (BB_END (bb))
 	  && !can_throw_internal (BB_END (bb)))
 	{
 	  rtx insn = BB_END (bb), stop = NEXT_INSN (BB_END (bb));
 	  rtx next;
-	  for (e = bb->succ; e; e = e->succ_next)
+
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->flags & EDGE_FALLTHRU)
 	      break;
+	    }
+	  END_FOR_EACH_EDGE;
+
 	  /* Get past the new insns generated. Allow notes, as the insns may
 	     be already deleted.  */
 	  while ((NONJUMP_INSN_P (insn) || NOTE_P (insn))
Index: gcc/sbitmap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sbitmap.c,v
retrieving revision 1.32
diff -u -p -w -r1.32 sbitmap.c
--- gcc/sbitmap.c	9 Sep 2004 17:19:12 -0000	1.32
+++ gcc/sbitmap.c	13 Sep 2004 04:39:36 -0000
@@ -514,9 +514,11 @@ sbitmap_intersection_of_succs (sbitmap d
   basic_block b = BASIC_BLOCK (bb);
   unsigned int set_size = dst->size;
   edge e;
+  unsigned ix;
 
-  for (e = b->succ; e != 0; e = e->succ_next)
+  for (e = NULL, ix = 0; ix < EDGE_COUNT (b->succs); ix++)
     {
+      e = EDGE_SUCC (b, ix);
       if (e->dest == EXIT_BLOCK_PTR)
 	continue;
 
@@ -524,14 +526,15 @@ sbitmap_intersection_of_succs (sbitmap d
       break;
     }
 
-  if (e == 0)
+  if (!e)
     sbitmap_ones (dst);
   else
-    for (e = e->succ_next; e != 0; e = e->succ_next)
+    for (++ix; ix < EDGE_COUNT (b->succs); ix++)
       {
 	unsigned int i;
 	sbitmap_ptr p, r;
 
+	e = EDGE_SUCC (b, ix);
 	if (e->dest == EXIT_BLOCK_PTR)
 	  continue;
 
@@ -551,9 +554,11 @@ sbitmap_intersection_of_preds (sbitmap d
   basic_block b = BASIC_BLOCK (bb);
   unsigned int set_size = dst->size;
   edge e;
+  unsigned ix;
 
-  for (e = b->pred; e != 0; e = e->pred_next)
+  for (e = NULL, ix = 0; ix < EDGE_COUNT (b->preds); ix++)
     {
+      e = EDGE_PRED (b, ix);
       if (e->src == ENTRY_BLOCK_PTR)
 	continue;
 
@@ -561,14 +566,15 @@ sbitmap_intersection_of_preds (sbitmap d
       break;
     }
 
-  if (e == 0)
+  if (!e)
     sbitmap_ones (dst);
   else
-    for (e = e->pred_next; e != 0; e = e->pred_next)
+    for (++ix; ix < EDGE_COUNT (b->preds); ix++)
       {
 	unsigned int i;
 	sbitmap_ptr p, r;
 
+	e = EDGE_PRED (b, ix);
 	if (e->src == ENTRY_BLOCK_PTR)
 	  continue;
 
@@ -588,9 +594,11 @@ sbitmap_union_of_succs (sbitmap dst, sbi
   basic_block b = BASIC_BLOCK (bb);
   unsigned int set_size = dst->size;
   edge e;
+  unsigned ix;
 
-  for (e = b->succ; e != 0; e = e->succ_next)
+  for (ix = 0; ix < EDGE_COUNT (b->succs); ix++)
     {
+      e = EDGE_SUCC (b, ix);
       if (e->dest == EXIT_BLOCK_PTR)
 	continue;
 
@@ -598,14 +606,15 @@ sbitmap_union_of_succs (sbitmap dst, sbi
       break;
     }
 
-  if (e == 0)
+  if (ix == EDGE_COUNT (b->succs))
     sbitmap_zero (dst);
   else
-    for (e = e->succ_next; e != 0; e = e->succ_next)
+    for (ix++; ix < EDGE_COUNT (b->succs); ix++)
       {
 	unsigned int i;
 	sbitmap_ptr p, r;
 
+	e = EDGE_SUCC (b, ix);
 	if (e->dest == EXIT_BLOCK_PTR)
 	  continue;
 
@@ -625,8 +634,9 @@ sbitmap_union_of_preds (sbitmap dst, sbi
   basic_block b = BASIC_BLOCK (bb);
   unsigned int set_size = dst->size;
   edge e;
+  unsigned ix;
 
-  for (e = b->pred; e != 0; e = e->pred_next)
+  for (e = NULL, ix = 0; ix < EDGE_COUNT (b->preds); ix++)
     {
       if (e->src== ENTRY_BLOCK_PTR)
 	continue;
@@ -635,14 +645,15 @@ sbitmap_union_of_preds (sbitmap dst, sbi
       break;
     }
 
-  if (e == 0)
+  if (ix == EDGE_COUNT (b->preds))
     sbitmap_zero (dst);
   else
-    for (e = e->pred_next; e != 0; e = e->pred_next)
+    for (ix++; ix < EDGE_COUNT (b->preds); ix++)
       {
 	unsigned int i;
 	sbitmap_ptr p, r;
 
+	e = EDGE_PRED (b, ix);
 	if (e->src == ENTRY_BLOCK_PTR)
 	  continue;
 
Index: gcc/sched-ebb.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-ebb.c,v
retrieving revision 1.38
diff -u -p -w -r1.38 sched-ebb.c
--- gcc/sched-ebb.c	9 Sep 2004 17:19:13 -0000	1.38
+++ gcc/sched-ebb.c	13 Sep 2004 04:39:37 -0000
@@ -175,7 +175,9 @@ compute_jump_reg_dependencies (rtx insn,
 {
   basic_block b = BLOCK_FOR_INSN (insn);
   edge e;
-  for (e = b->succ; e; e = e->succ_next)
+
+  FOR_EACH_EDGE (e, b->succs)
+    {
     if (e->flags & EDGE_FALLTHRU)
       /* The jump may be a by-product of a branch that has been merged
 	 in the main codepath after being conditionalized.  Therefore
@@ -188,6 +190,8 @@ compute_jump_reg_dependencies (rtx insn,
       bitmap_operation (used, used, e->dest->global_live_at_start,
 			BITMAP_IOR);
 }
+  END_FOR_EACH_EDGE;
+}
 
 /* Used in schedule_insns to initialize current_sched_info for scheduling
    regions (or single basic blocks).  */
@@ -291,9 +295,13 @@ fix_basic_block_boundaries (basic_block 
 	         A safer solution can be to bring the code into sequence,
 	         do the split and re-emit it back in case this will ever
 	         trigger problem.  */
-	      f = bb->prev_bb->succ;
-	      while (f && !(f->flags & EDGE_FALLTHRU))
-		f = f->succ_next;
+
+	      FOR_EACH_EDGE (f, bb->prev_bb->succs)
+		{
+		  if (f->flags & EDGE_FALLTHRU)
+		    break;
+		}
+	      END_FOR_EACH_EDGE;
 
 	      if (f)
 		{
@@ -592,9 +600,12 @@ schedule_ebbs (FILE *dump_file)
 	  if (bb->next_bb == EXIT_BLOCK_PTR
 	      || LABEL_P (BB_HEAD (bb->next_bb)))
 	    break;
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if ((e->flags & EDGE_FALLTHRU) != 0)
 	      break;
+	    }
+	  END_FOR_EACH_EDGE;
 	  if (! e)
 	    break;
 	  if (e->probability <= probability_cutoff)
Index: gcc/sched-rgn.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/sched-rgn.c,v
retrieving revision 1.81
diff -u -p -w -r1.81 sched-rgn.c
--- gcc/sched-rgn.c	9 Sep 2004 17:19:13 -0000	1.81
+++ gcc/sched-rgn.c	13 Sep 2004 04:39:38 -0000
@@ -390,9 +390,9 @@ build_control_flow (struct edge_list *ed
   unreachable = 0;
   FOR_EACH_BB (b)
     {
-      if (b->pred == NULL
-	  || (b->pred->src == b
-	      && b->pred->pred_next == NULL))
+      if (EDGE_COUNT (b->preds) == 0
+	  || (EDGE_PRED (b, 0)->src == b
+	      && EDGE_COUNT (b->preds) == 1))
 	unreachable = 1;
     }
 
@@ -615,7 +615,7 @@ find_rgns (struct edge_list *edge_list)
   char no_loops = 1;
   int node, child, loop_head, i, head, tail;
   int count = 0, sp, idx = 0;
-  int current_edge = out_edges[ENTRY_BLOCK_PTR->succ->dest->index];
+  int current_edge = out_edges[EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->index];
   int num_bbs, num_insns, unreachable;
   int too_large_failure;
   basic_block bb;
@@ -842,9 +842,13 @@ find_rgns (struct edge_list *edge_list)
 
 	      /* Decrease degree of all I's successors for topological
 		 ordering.  */
-	      for (e = bb->succ; e; e = e->succ_next)
+
+	      FOR_EACH_EDGE (e, bb->succs)
+		{
 		if (e->dest != EXIT_BLOCK_PTR)
 		  --degree[e->dest->index];
+		}
+	      END_FOR_EACH_EDGE;
 
 	      /* Estimate # insns, and count # blocks in the region.  */
 	      num_bbs = 1;
@@ -860,9 +864,8 @@ find_rgns (struct edge_list *edge_list)
 		  FOR_EACH_BB (jbb)
 		    /* Leaf nodes have only a single successor which must
 		       be EXIT_BLOCK.  */
-		    if (jbb->succ
-			&& jbb->succ->dest == EXIT_BLOCK_PTR
-			&& jbb->succ->succ_next == NULL)
+		    if (EDGE_COUNT (jbb->succs) == 1
+			&& EDGE_SUCC (jbb, 0)->dest == EXIT_BLOCK_PTR)
 		      {
 			queue[++tail] = jbb->index;
 			SET_BIT (in_queue, jbb->index);
@@ -878,7 +881,7 @@ find_rgns (struct edge_list *edge_list)
 		{
 		  edge e;
 
-		  for (e = bb->pred; e; e = e->pred_next)
+		  FOR_EACH_EDGE (e, bb->preds)
 		    {
 		      if (e->src == ENTRY_BLOCK_PTR)
 			continue;
@@ -898,6 +901,7 @@ find_rgns (struct edge_list *edge_list)
 			    }
 			}
 		    }
+		  END_FOR_EACH_EDGE;
 		}
 
 	      /* Now add all the blocks in the loop to the queue.
@@ -935,7 +939,7 @@ find_rgns (struct edge_list *edge_list)
 		  edge e;
 		  child = queue[++head];
 
-		  for (e = BASIC_BLOCK (child)->pred; e; e = e->pred_next)
+		  FOR_EACH_EDGE (e, BASIC_BLOCK (child)->preds)
 		    {
 		      node = e->src->index;
 
@@ -959,6 +963,7 @@ find_rgns (struct edge_list *edge_list)
 			    }
 			}
 		    }
+		  END_FOR_EACH_EDGE;
 		}
 
 	      if (tail >= 0 && !too_large_failure)
@@ -990,12 +995,13 @@ find_rgns (struct edge_list *edge_list)
 			  CONTAINING_RGN (child) = nr_regions;
 			  queue[head] = queue[tail--];
 
-			  for (e = BASIC_BLOCK (child)->succ;
-			       e;
-			       e = e->succ_next)
+			  FOR_EACH_EDGE (e, BASIC_BLOCK (child)->succs)
+			    {
 			    if (e->dest != EXIT_BLOCK_PTR)
 			      --degree[e->dest->index];
 			}
+			  END_FOR_EACH_EDGE;
+			}
 		      else
 			--head;
 		    }
Index: gcc/tracer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tracer.c,v
retrieving revision 1.21
diff -u -p -w -r1.21 tracer.c
--- gcc/tracer.c	9 Sep 2004 07:54:06 -0000	1.21
+++ gcc/tracer.c	13 Sep 2004 04:39:38 -0000
@@ -119,9 +119,12 @@ find_best_successor (basic_block bb)
   edge e;
   edge best = NULL;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (!best || better_p (e, best))
       best = e;
+    }
+  END_FOR_EACH_EDGE;
   if (!best || ignore_bb_p (best->dest))
     return NULL;
   if (best->probability <= probability_cutoff)
@@ -137,9 +140,12 @@ find_best_predecessor (basic_block bb)
   edge e;
   edge best = NULL;
 
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
+    {
     if (!best || better_p (e, best))
       best = e;
+    }
+  END_FOR_EACH_EDGE;
   if (!best || ignore_bb_p (best->src))
     return NULL;
   if (EDGE_FREQUENCY (best) * REG_BR_PROB_BASE
@@ -269,14 +275,19 @@ tail_duplicate (void)
 	      blocks[bb2->index] = NULL;
 	    }
 	  traced_insns += bb2->frequency * counts [bb2->index];
-	  if (bb2->pred && bb2->pred->pred_next
+	  if (EDGE_COUNT (bb2->preds) > 1
 	      && can_duplicate_block_p (bb2))
 	    {
-	      edge e = bb2->pred;
+	      edge e;
 	      basic_block old = bb2;
 
-	      while (e->src != bb)
-		e = e->pred_next;
+	      FOR_EACH_EDGE (e, bb2->preds)
+		{
+		  if (e->src == bb)
+		    break;
+		}
+	      END_FOR_EACH_EDGE;
+
 	      nduplicated += counts [bb2->index];
 	      bb2 = duplicate_block (bb2, e);
 
@@ -319,8 +330,8 @@ tail_duplicate (void)
 static void
 layout_superblocks (void)
 {
-  basic_block end = ENTRY_BLOCK_PTR->succ->dest;
-  basic_block bb = ENTRY_BLOCK_PTR->succ->dest->next_bb;
+  basic_block end = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest;
+  basic_block bb = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->next_bb;
 
   while (bb != EXIT_BLOCK_PTR)
     {
@@ -328,12 +339,15 @@ layout_superblocks (void)
       while (end->rbi->next)
 	end = end->rbi->next;
 
-      for (e = end->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, end->succs)
+	{
 	if (e->dest != EXIT_BLOCK_PTR
-	    && e->dest != ENTRY_BLOCK_PTR->succ->dest
+	      && e->dest != EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest
 	    && !e->dest->rbi->visited
 	    && (!best || EDGE_FREQUENCY (e) > EDGE_FREQUENCY (best)))
 	  best = e;
+	}
+      END_FOR_EACH_EDGE;
 
       if (best)
 	{
Index: gcc/tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.50
diff -u -p -w -r2.50 tree-cfg.c
--- gcc/tree-cfg.c	11 Sep 2004 20:42:03 -0000	2.50
+++ gcc/tree-cfg.c	13 Sep 2004 04:39:39 -0000
@@ -440,7 +440,7 @@ make_edges (void)
 
       /* Finally, if no edges were created above, this is a regular
 	 basic block that only needs a fallthru edge.  */
-      if (bb->succ == NULL)
+      if (EDGE_COUNT (bb->succs) == 0)
 	make_edge (bb, bb->next_bb, EDGE_FALLTHRU);
     }
 
@@ -482,7 +482,7 @@ make_ctrl_stmt_edges (basic_block bb)
     case RESX_EXPR:
       make_eh_edges (last);
       /* Yet another NORETURN hack.  */
-      if (bb->succ == NULL)
+      if (EDGE_COUNT (bb->succs) == 0)
 	make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
       break;
 
@@ -697,7 +697,7 @@ make_goto_expr_edges (basic_block bb)
     }
 
   /* Degenerate case of computed goto with no labels.  */
-  if (!for_call && !bb->succ)
+  if (!for_call && EDGE_COUNT (bb->succs) == 0)
     make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
 }
 
@@ -1008,20 +1008,19 @@ tree_can_merge_blocks_p (basic_block a, 
   tree stmt;
   block_stmt_iterator bsi;
 
-  if (!a->succ
-      || a->succ->succ_next)
+  if (EDGE_COUNT (a->succs) != 1)
     return false;
 
-  if (a->succ->flags & EDGE_ABNORMAL)
+  if (EDGE_SUCC (a, 0)->flags & EDGE_ABNORMAL)
     return false;
 
-  if (a->succ->dest != b)
+  if (EDGE_SUCC (a, 0)->dest != b)
     return false;
 
   if (b == EXIT_BLOCK_PTR)
     return false;
   
-  if (b->pred->pred_next)
+  if (EDGE_COUNT (b->preds) > 1)
     return false;
 
   /* If A ends by a statement causing exceptions or something similar, we
@@ -1068,7 +1067,7 @@ tree_merge_blocks (basic_block a, basic_
   /* Ensure that B follows A.  */
   move_block_after (b, a);
 
-  gcc_assert (a->succ->flags & EDGE_FALLTHRU);
+  gcc_assert (EDGE_SUCC (a, 0)->flags & EDGE_FALLTHRU);
   gcc_assert (!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a)));
 
   /* Remove labels from B and set bb_for_stmt to A for other statements.  */
@@ -1649,17 +1648,16 @@ cfg_remove_useless_stmts_bb (basic_block
 
   /* Check whether we come here from a condition, and if so, get the
      condition.  */
-  if (!bb->pred
-      || bb->pred->pred_next
-      || !(bb->pred->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
+  if (EDGE_COUNT (bb->preds) != 1
+      || !(EDGE_PRED (bb, 0)->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
     return;
 
-  cond = COND_EXPR_COND (last_stmt (bb->pred->src));
+  cond = COND_EXPR_COND (last_stmt (EDGE_PRED (bb, 0)->src));
 
   if (TREE_CODE (cond) == VAR_DECL || TREE_CODE (cond) == PARM_DECL)
     {
       var = cond;
-      val = (bb->pred->flags & EDGE_FALSE_VALUE
+      val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
 	     ? boolean_false_node : boolean_true_node);
     }
   else if (TREE_CODE (cond) == TRUTH_NOT_EXPR
@@ -1667,12 +1665,12 @@ cfg_remove_useless_stmts_bb (basic_block
 	       || TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL))
     {
       var = TREE_OPERAND (cond, 0);
-      val = (bb->pred->flags & EDGE_FALSE_VALUE
+      val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
 	     ? boolean_true_node : boolean_false_node);
     }
   else
     {
-      if (bb->pred->flags & EDGE_FALSE_VALUE)
+      if (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE)
 	cond = invert_truthvalue (cond);
       if (TREE_CODE (cond) == EQ_EXPR
 	  && (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL
@@ -1775,8 +1773,8 @@ remove_phi_nodes_and_edges_for_unreachab
     }
 
   /* Remove edges to BB's successors.  */
-  while (bb->succ != NULL)
-    ssa_remove_edge (bb->succ);
+  while (EDGE_COUNT (bb->succs) > 0)
+    ssa_remove_edge (EDGE_SUCC (bb, 0));
 }
 
 
@@ -1857,12 +1855,11 @@ tree_block_forwards_to (basic_block bb)
      single successor has phi nodes.  */
   if (bb == EXIT_BLOCK_PTR
       || bb == ENTRY_BLOCK_PTR
-      || !bb->succ
-      || bb->succ->succ_next
-      || bb->succ->dest == EXIT_BLOCK_PTR
-      || (bb->succ->flags & EDGE_ABNORMAL) != 0
+      || EDGE_COUNT (bb->succs) != 1
+      || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+      || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL) != 0
       || phi_nodes (bb)
-      || phi_nodes (bb->succ->dest))
+      || phi_nodes (EDGE_SUCC (bb, 0)->dest))
     return NULL;
 
   /* Walk past any labels at the start of this block.  */
@@ -1880,11 +1877,11 @@ tree_block_forwards_to (basic_block bb)
       edge dest;
 
       /* Recursive call to pick up chains of forwarding blocks.  */
-      dest = tree_block_forwards_to (bb->succ->dest);
+      dest = tree_block_forwards_to (EDGE_SUCC (bb, 0)->dest);
 
-      /* If none found, we forward to bb->succ at minimum.  */
+      /* If none found, we forward to bb->succs[0] at minimum.  */
       if (!dest)
-	dest = bb->succ;
+	dest = EDGE_SUCC (bb, 0);
 
       ann->forwardable = 1;
       return dest;
@@ -1931,9 +1928,10 @@ cleanup_control_expr_graph (basic_block 
   bool retval = false;
   tree expr = bsi_stmt (bsi), val;
 
-  if (bb->succ->succ_next)
+  if (EDGE_COUNT (bb->succs) > 1)
     {
-      edge e, next;
+      edge e;
+      unsigned ix;
 
       switch (TREE_CODE (expr))
 	{
@@ -1956,9 +1954,8 @@ cleanup_control_expr_graph (basic_block 
 	return false;
 
       /* Remove all the edges except the one that is always executed.  */
-      for (e = bb->succ; e; e = next)
+      for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
 	{
-	  next = e->succ_next;
 	  if (e != taken_edge)
 	    {
 	      taken_edge->probability += e->probability;
@@ -1966,12 +1963,15 @@ cleanup_control_expr_graph (basic_block 
 	      ssa_remove_edge (e);
 	      retval = true;
 	    }
+	  else
+	    ix++;
 	}
+
       if (taken_edge->probability > REG_BR_PROB_BASE)
 	taken_edge->probability = REG_BR_PROB_BASE;
     }
   else
-    taken_edge = bb->succ;
+    taken_edge = EDGE_SUCC (bb, 0);
 
   bsi_remove (&bsi);
   taken_edge->flags = EDGE_FALLTHRU;
@@ -2027,7 +2027,7 @@ find_taken_edge (basic_block bb, tree va
   if (TREE_CODE (stmt) == SWITCH_EXPR)
     return find_taken_edge_switch_expr (bb, val);
 
-  return bb->succ;
+  return EDGE_SUCC (bb, 0);
 }
 
 
@@ -2259,11 +2259,7 @@ dump_cfg_stats (FILE *file)
 
   n_edges = 0;
   FOR_EACH_BB (bb)
-    {
-      edge e;
-      for (e = bb->succ; e; e = e->succ_next)
-	n_edges++;
-    }
+    n_edges += EDGE_COUNT (bb->succs);
   size = n_edges * sizeof (struct edge_def);
   total += size;
   fprintf (file, fmt_str_1, "Edges", n_edges, SCALE (size), LABEL (size));
@@ -2315,7 +2311,7 @@ tree_cfg2vcg (FILE *file)
   fprintf (file, "node: { title: \"EXIT\" label: \"EXIT\" }\n");
 
   /* Write blocks and edges.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
     {
       fprintf (file, "edge: { sourcename: \"ENTRY\" targetname: \"%d\"",
 	       e->dest->index);
@@ -2327,6 +2323,8 @@ tree_cfg2vcg (FILE *file)
 
       fprintf (file, " }\n");
     }
+  END_FOR_EACH_EDGE;
+
   fputc ('\n', file);
 
   FOR_EACH_BB (bb)
@@ -2360,7 +2358,7 @@ tree_cfg2vcg (FILE *file)
 	       bb->index, bb->index, head_name, head_line, end_name,
 	       end_line);
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	{
 	  if (e->dest == EXIT_BLOCK_PTR)
 	    fprintf (file, "edge: { sourcename: \"%d\" targetname: \"EXIT\"", bb->index);
@@ -2374,6 +2372,7 @@ tree_cfg2vcg (FILE *file)
 
 	  fprintf (file, " }\n");
 	}
+      END_FOR_EACH_EDGE;
 
       if (bb->next_bb != EXIT_BLOCK_PTR)
 	fputc ('\n', file);
@@ -2521,7 +2520,7 @@ disband_implicit_edges (void)
 	     from cfg_remove_useless_stmts here since it violates the
 	     invariants for tree--cfg correspondence and thus fits better
 	     here where we do it anyway.  */
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    {
 	      if (e->dest != bb->next_bb)
 		continue;
@@ -2534,6 +2533,7 @@ disband_implicit_edges (void)
 		gcc_unreachable ();
 	      e->flags |= EDGE_FALLTHRU;
 	    }
+	  END_FOR_EACH_EDGE;
 
 	  continue;
 	}
@@ -2542,15 +2542,14 @@ disband_implicit_edges (void)
 	{
 	  /* Remove the RETURN_EXPR if we may fall though to the exit
 	     instead.  */
-	  gcc_assert (bb->succ);
-	  gcc_assert (!bb->succ->succ_next);
-	  gcc_assert (bb->succ->dest == EXIT_BLOCK_PTR);
+	  gcc_assert (EDGE_COUNT (bb->succs) == 1);
+	  gcc_assert (EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR);
 
 	  if (bb->next_bb == EXIT_BLOCK_PTR
 	      && !TREE_OPERAND (stmt, 0))
 	    {
 	      bsi_remove (&last);
-	      bb->succ->flags |= EDGE_FALLTHRU;
+	      EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
 	    }
 	  continue;
 	}
@@ -2561,9 +2560,12 @@ disband_implicit_edges (void)
 	continue;
 
       /* Find a fallthru edge and emit the goto if necessary.  */
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (e->flags & EDGE_FALLTHRU)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
 
       if (!e || e->dest == bb->next_bb)
 	continue;
@@ -2845,7 +2847,7 @@ tree_find_edge_insert_loc (edge e, block
      would have to examine the PHIs to prove that none of them used
      the value set by the statement we want to insert on E.   That
      hardly seems worth the effort.  */
-  if (dest->pred->pred_next == NULL
+  if (EDGE_COUNT (dest->preds) == 1
       && ! phi_nodes (dest)
       && dest != EXIT_BLOCK_PTR)
     {
@@ -2877,7 +2879,7 @@ tree_find_edge_insert_loc (edge e, block
      Except for the entry block.  */
   src = e->src;
   if ((e->flags & EDGE_ABNORMAL) == 0
-      && src->succ->succ_next == NULL
+      && EDGE_COUNT (src->succs) == 1
       && src != ENTRY_BLOCK_PTR)
     {
       *bsi = bsi_last (src);
@@ -2908,7 +2910,7 @@ tree_find_edge_insert_loc (edge e, block
   dest = split_edge (e);
   if (new_bb)
     *new_bb = dest;
-  e = dest->pred;
+  e = EDGE_PRED (dest, 0);
   goto restart;
 }
 
@@ -2928,11 +2930,14 @@ bsi_commit_edge_inserts (int *new_blocks
 
   blocks = n_basic_blocks;
 
-  bsi_commit_edge_inserts_1 (ENTRY_BLOCK_PTR->succ);
+  bsi_commit_edge_inserts_1 (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
 
   FOR_EACH_BB (bb)
-    for (e = bb->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, bb->succs)
+      {
       bsi_commit_edge_inserts_1 (e);
+      }
+    END_FOR_EACH_EDGE;
 
   if (new_blocks)
     *new_blocks = n_basic_blocks - blocks;
@@ -3011,9 +3016,13 @@ tree_split_edge (edge edge_in)
   /* Place the new block in the block list.  Try to keep the new block
      near its "logical" location.  This is of most help to humans looking
      at debugging dumps.  */
-  for (e = dest->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, dest->preds)
+    {
     if (e->src->next_bb == dest)
       break;
+    }
+  END_FOR_EACH_EDGE;
+
   if (!e)
     after_bb = dest->prev_bb;
   else
@@ -3449,12 +3458,15 @@ tree_verify_flow_info (void)
       err = 1;
     }
 
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+    {
     if (e->flags & EDGE_FALLTHRU)
       {
 	error ("Fallthru to exit from bb %d\n", e->src->index);
 	err = 1;
       }
+    }
+  END_FOR_EACH_EDGE;
 
   FOR_EACH_BB (bb)
     {
@@ -3515,7 +3527,8 @@ tree_verify_flow_info (void)
 
       if (is_ctrl_stmt (stmt))
 	{
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->flags & EDGE_FALLTHRU)
 	      {
 		error ("Fallthru edge after a control statement in bb %d \n",
@@ -3523,6 +3536,8 @@ tree_verify_flow_info (void)
 		err = 1;
 	      }
 	}
+	  END_FOR_EACH_EDGE;
+	}
 
       switch (TREE_CODE (stmt))
 	{
@@ -3544,7 +3559,7 @@ tree_verify_flow_info (void)
 		|| !(false_edge->flags & EDGE_FALSE_VALUE)
 		|| (true_edge->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL))
 		|| (false_edge->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL))
-		|| bb->succ->succ_next->succ_next)
+		|| EDGE_COUNT (bb->succs) >= 3)
 	      {
 		error ("Wrong outgoing edge flags at end of bb %d\n",
 		       bb->index);
@@ -3579,7 +3594,8 @@ tree_verify_flow_info (void)
 	    {
 	      /* FIXME.  We should double check that the labels in the 
 		 destination blocks have their address taken.  */
-	      for (e = bb->succ; e; e = e->succ_next)
+	      FOR_EACH_EDGE (e, bb->succs)
+		{
 		if ((e->flags & (EDGE_FALLTHRU | EDGE_TRUE_VALUE
 				 | EDGE_FALSE_VALUE))
 		    || !(e->flags & EDGE_ABNORMAL))
@@ -3589,17 +3605,19 @@ tree_verify_flow_info (void)
 		    err = 1;
 		  }
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 	  break;
 
 	case RETURN_EXPR:
-	  if (!bb->succ || bb->succ->succ_next
-	      || (bb->succ->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL
+	  if (EDGE_COUNT (bb->succs) != 1
+	      || (EDGE_SUCC (bb, 0)->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL
 		  		     | EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
 	    {
 	      error ("Wrong outgoing edge flags at end of bb %d\n", bb->index);
 	      err = 1;
 	    }
-	  if (bb->succ->dest != EXIT_BLOCK_PTR)
+	  if (EDGE_SUCC (bb, 0)->dest != EXIT_BLOCK_PTR)
 	    {
 	      error ("Return edge does not point to exit in bb %d\n",
 		     bb->index);
@@ -3655,7 +3673,7 @@ tree_verify_flow_info (void)
 		err = 1;
 	      }
 
-	    for (e = bb->succ; e; e = e->succ_next)
+	    FOR_EACH_EDGE (e, bb->succs)
 	      {
 		if (!e->dest->aux)
 		  {
@@ -3672,6 +3690,7 @@ tree_verify_flow_info (void)
 		    err = 1;
 		  }
 	      }
+	    END_FOR_EACH_EDGE;
 
 	    /* Check that we have all of them.  */
 	    for (i = 0; i < n; ++i)
@@ -3687,9 +3706,12 @@ tree_verify_flow_info (void)
 		  }
 	      }
 
-	    for (e = bb->succ; e; e = e->succ_next)
+	    FOR_EACH_EDGE (e, bb->succs)
+	      {
 	      e->dest->aux = (void *)0;
 	  }
+	    END_FOR_EACH_EDGE;
+	  }
 
 	default: ;
 	}
@@ -3715,7 +3737,7 @@ tree_make_forwarder_block (edge fallthru
   dummy = fallthru->src;
   bb = fallthru->dest;
 
-  if (!bb->pred->pred_next)
+  if (EDGE_COUNT (bb->preds) == 1)
     return;
 
   /* If we redirected a branch we must create new phi nodes at the
@@ -3740,7 +3762,7 @@ tree_make_forwarder_block (edge fallthru
   set_phi_nodes (bb, prev);
 
   /* Add the arguments we have stored on edges.  */
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     {
       if (e == fallthru)
 	continue;
@@ -3752,6 +3774,7 @@ tree_make_forwarder_block (edge fallthru
 
       PENDING_STMT (e) = NULL;
     }
+  END_FOR_EACH_EDGE;
 }
 
 
@@ -3772,10 +3795,9 @@ tree_forwarder_block_p (basic_block bb)
 
   /* BB must have a single outgoing normal edge.  Otherwise it can not be
      a forwarder block.  */
-  if (!bb->succ
-      || bb->succ->succ_next
-      || bb->succ->dest == EXIT_BLOCK_PTR
-      || (bb->succ->flags & EDGE_ABNORMAL)
+  if (EDGE_COUNT (bb->succs) != 1
+      || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+      || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL)
       || bb == ENTRY_BLOCK_PTR)
     {
       bb_ann (bb)->forwardable = 0;
@@ -3783,12 +3805,15 @@ tree_forwarder_block_p (basic_block bb)
     }
 
   /* Successors of the entry block are not forwarders.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
+    {
     if (e->dest == bb)
       {
 	bb_ann (bb)->forwardable = 0;
 	return false;
       }
+    }
+  END_FOR_EACH_EDGE;
 
   /* BB can not have any PHI nodes.  This could potentially be relaxed
      early in compilation if we re-rewrote the variables appearing in
@@ -3830,7 +3855,7 @@ tree_forwarder_block_p (basic_block bb)
 static bool
 thread_jumps (void)
 {
-  edge e, next, last, old;
+  edge e, last, old;
   basic_block bb, dest, tmp, old_dest, dom;
   tree phi;
   int arg;
@@ -3841,8 +3866,10 @@ thread_jumps (void)
 
   FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
     {
+      unsigned ix;
+
       /* Don't waste time on unreachable blocks.  */
-      if (!bb->pred)
+      if (EDGE_COUNT (bb->preds) == 0)
 	continue;
 
       /* Nor on forwarders.  */
@@ -3856,17 +3883,19 @@ thread_jumps (void)
 
       /* Examine each of our block's successors to see if it is
 	 forwardable.  */
-      for (e = bb->succ; e; e = next)
+      for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
 	{
 	  int freq;
 	  gcov_type count;
-	  next = e->succ_next;
 
 	  /* If the edge is abnormal or its destination is not
 	     forwardable, then there's nothing to do.  */
 	  if ((e->flags & EDGE_ABNORMAL)
 	      || !tree_forwarder_block_p (e->dest))
+	    {
+	      ix++;
 	    continue;
+	    }
 
 	  count = e->count;
 	  freq = EDGE_FREQUENCY (e);
@@ -3874,19 +3903,19 @@ thread_jumps (void)
 	  /* Now walk through as many forwarder block as possible to
 	     find the ultimate destination we want to thread our jump
 	     to.  */
-	  last = e->dest->succ;
+	  last = EDGE_SUCC (e->dest, 0);
 	  bb_ann (e->dest)->forwardable = 0;
-	  for (dest = e->dest->succ->dest;
+	  for (dest = EDGE_SUCC (e->dest, 0)->dest;
 	       tree_forwarder_block_p (dest);
-	       last = dest->succ,
-	       dest = dest->succ->dest)
+	       last = EDGE_SUCC (dest, 0),
+	       dest = EDGE_SUCC (dest, 0)->dest)
 	    {
 	      /* An infinite loop detected.  We redirect the edge anyway, so
 		 that the loop is shrunk into single basic block.  */
 	      if (!bb_ann (dest)->forwardable)
 		break;
 
-	      if (dest->succ->dest == EXIT_BLOCK_PTR)
+	      if (EDGE_SUCC (dest, 0)->dest == EXIT_BLOCK_PTR)
 		break;
 
 	      bb_ann (dest)->forwardable = 0;
@@ -3896,19 +3925,22 @@ thread_jumps (void)
 	      dest->count -= count;
 	      if (dest->count < 0)
 		dest->count = 0;
-	      dest->succ->count -= count;
-	      if (dest->succ->count < 0)
-		dest->succ->count = 0;
+	      EDGE_SUCC (dest, 0)->count -= count;
+	      if (EDGE_SUCC (dest, 0)->count < 0)
+		EDGE_SUCC (dest, 0)->count = 0;
 	    }
 
 	  /* Reset the forwardable marks to 1.  */
 	  for (tmp = e->dest;
 	       tmp != dest;
-	       tmp = tmp->succ->dest)
+	       tmp = EDGE_SUCC (tmp, 0)->dest)
 	    bb_ann (tmp)->forwardable = 1;
 
 	  if (dest == e->dest)
+	    {
+	      ix++;
 	    continue;
+	    }
 	      
 	  old = find_edge (bb, dest);
 	  if (old)
@@ -3924,7 +3956,10 @@ thread_jumps (void)
 	  
 		  /* That might mean that no forwarding at all is possible.  */
 		  if (dest == e->dest)
+		    {
+		      ix++;
 		    continue;
+		    }
 
 		  old = find_edge (bb, dest);
 		}
@@ -3957,9 +3992,9 @@ thread_jumps (void)
 		 become unreachable).  */
 	      for (; old_dest != dest; old_dest = tmp)
 		{
-		  tmp = old_dest->succ->dest;
+		  tmp = EDGE_SUCC (old_dest, 0)->dest;
 
-		  if (old_dest->pred)
+		  if (EDGE_COUNT (old_dest->preds) > 0)
 		    break;
 
 		  delete_basic_block (old_dest);
@@ -3978,7 +4013,7 @@ thread_jumps (void)
 
 	      for (; old_dest != dest; old_dest = tmp)
 		{
-		  tmp = old_dest->succ->dest;
+		  tmp = EDGE_SUCC (old_dest, 0)->dest;
 
 		  if (get_immediate_dominator (CDI_DOMINATORS, tmp) == old_dest)
 		    {
@@ -4047,9 +4082,12 @@ tree_try_redirect_by_replacing_jump (edg
   tree stmt;
 
   /* Verify that all targets will be TARGET.  */
-  for (tmp = src->succ; tmp; tmp = tmp->succ_next)
+  FOR_EACH_EDGE (tmp, src->succs)
+    {
     if (tmp->dest != target && tmp != e)
       break;
+    }
+  END_FOR_EACH_EDGE;
 
   if (tmp)
     return NULL;
@@ -4173,10 +4211,13 @@ tree_split_block (basic_block bb, void *
   new_bb = create_empty_bb (bb);
 
   /* Redirect the outgoing edges.  */
-  new_bb->succ = bb->succ;
-  bb->succ = NULL;
-  for (e = new_bb->succ; e; e = e->succ_next)
+  new_bb->succs = bb->succs;
+  bb->succs = NULL;
+  FOR_EACH_EDGE (e, new_bb->succs)
+    {
     e->src = new_bb;
+    }
+  END_FOR_EACH_EDGE;
 
   if (stmt && TREE_CODE ((tree) stmt) == LABEL_EXPR)
     stmt = NULL;
@@ -4380,43 +4421,37 @@ dump_function_to_file (tree fn, FILE *fi
 
 /* Pretty print of the loops intermediate representation.  */
 static void print_loop (FILE *, struct loop *, int);
-static void print_pred_bbs (FILE *, edge);
-static void print_succ_bbs (FILE *, edge);
+static void print_pred_bbs (FILE *, basic_block bb);
+static void print_succ_bbs (FILE *, basic_block bb);
 
 
 /* Print the predecessors indexes of edge E on FILE.  */
 
 static void
-print_pred_bbs (FILE *file, edge e)
+print_pred_bbs (FILE *file, basic_block bb)
 {
-  if (e == NULL)
-    return;
-  
-  else if (e->pred_next == NULL)
-    fprintf (file, "bb_%d", e->src->index);
+  edge e;
   
-  else
+  FOR_EACH_EDGE (e, bb->preds)
     {
-      fprintf (file, "bb_%d, ", e->src->index);
-      print_pred_bbs (file, e->pred_next);
+      fprintf (file, "bb_%d", e->src->index);
     }
+  END_FOR_EACH_EDGE;
 }
 
 
 /* Print the successors indexes of edge E on FILE.  */
 
 static void
-print_succ_bbs (FILE *file, edge e)
+print_succ_bbs (FILE *file, basic_block bb)
 {
-  if (e == NULL)
-    return;
-  else if (e->succ_next == NULL)
-    fprintf (file, "bb_%d", e->dest->index);
-  else
+  edge e;
+
+  FOR_EACH_EDGE (e, bb->succs)
     {
-      fprintf (file, "bb_%d, ", e->dest->index);
-      print_succ_bbs (file, e->succ_next);
+      fprintf (file, "bb_%d", e->src->index);
     }
+  END_FOR_EACH_EDGE;
 }
 
 
@@ -4445,9 +4480,9 @@ print_loop (FILE *file, struct loop *loo
       {
 	/* Print the basic_block's header.  */
 	fprintf (file, "%s  bb_%d (preds = {", s_indent, bb->index);
-	print_pred_bbs (file, bb->pred);
+	print_pred_bbs (file, bb);
 	fprintf (file, "}, succs = {");
-	print_succ_bbs (file, bb->succ);
+	print_succ_bbs (file, bb);
 	fprintf (file, "})\n");
 	
 	/* Print the basic_block's body.  */
@@ -4585,7 +4620,8 @@ tree_flow_call_edges_add (sbitmap blocks
 	{
 	  edge e;
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->dest == EXIT_BLOCK_PTR)
 	      {
 		bsi_insert_on_edge (e, build_empty_stmt ());
@@ -4593,6 +4629,8 @@ tree_flow_call_edges_add (sbitmap blocks
 		break;
 	      }
 	}
+	  END_FOR_EACH_EDGE;
+	}
     }
 
   /* Now add fake edges to the function exit for any non constant
@@ -4627,8 +4665,11 @@ tree_flow_call_edges_add (sbitmap blocks
 		     mark that edge as fake and remove it later.  */
 #ifdef ENABLE_CHECKING
 		  if (stmt == last_stmt)
-		    for (e = bb->succ; e; e = e->succ_next)
+		    {
+		      FOR_EACH_EDGE (e, bb->succs)
 		      gcc_assert (e->dest != EXIT_BLOCK_PTR);
+		      END_FOR_EACH_EDGE;
+		    }
 #endif
 
 		  /* Note that the following may create a new basic block
@@ -4657,20 +4698,22 @@ bool
 tree_purge_dead_eh_edges (basic_block bb)
 {
   bool changed = false;
-  edge e, next;
+  edge e;
+  unsigned ix;
   tree stmt = last_stmt (bb);
 
   if (stmt && tree_can_throw_internal (stmt))
     return false;
 
-  for (e = bb->succ; e ; e = next)
+  for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
     {
-      next = e->succ_next;
       if (e->flags & EDGE_EH)
 	{
 	  ssa_remove_edge (e);
 	  changed = true;
 	}
+      else
+	ix++;
     }
 
   return changed;
@@ -4723,12 +4766,15 @@ split_critical_edges (void)
 
   FOR_ALL_BB (bb)
     {
-      for (e = bb->succ; e ; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (EDGE_CRITICAL_P (e) && !(e->flags & EDGE_ABNORMAL))
 	  {
 	    split_edge (e);
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 }
 
 struct tree_opt_pass pass_split_crit_edges = 
@@ -4836,21 +4882,21 @@ execute_warn_function_return (void)
 
   if (warn_missing_noreturn
       && !TREE_THIS_VOLATILE (cfun->decl)
-      && EXIT_BLOCK_PTR->pred == NULL
+      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0
       && !lang_hooks.function.missing_noreturn_ok_p (cfun->decl))
     warning ("%Jfunction might be possible candidate for attribute `noreturn'",
 	     cfun->decl);
 
   /* If we have a path to EXIT, then we do return.  */
   if (TREE_THIS_VOLATILE (cfun->decl)
-      && EXIT_BLOCK_PTR->pred != NULL)
+      && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0)
     {
 #ifdef USE_MAPPED_LOCATION
       location = UNKNOWN_LOCATION;
 #else
       locus = NULL;
 #endif
-      for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next)
+      FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
 	{
 	  last = last_stmt (e->src);
 	  if (TREE_CODE (last) == RETURN_EXPR
@@ -4861,6 +4907,8 @@ execute_warn_function_return (void)
 #endif
 	    break;
 	}
+      END_FOR_EACH_EDGE;
+
 #ifdef USE_MAPPED_LOCATION
       if (location == UNKNOWN_LOCATION)
 	location = cfun->function_end_locus;
@@ -4875,10 +4923,10 @@ execute_warn_function_return (void)
   /* If we see "return;" in some basic block, then we do reach the end
      without returning a value.  */
   else if (warn_return_type
-	   && EXIT_BLOCK_PTR->pred != NULL
+	   && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0
 	   && !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (cfun->decl))))
     {
-      for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next)
+      FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
 	{
 	  tree last = last_stmt (e->src);
 	  if (TREE_CODE (last) == RETURN_EXPR
@@ -4898,6 +4946,7 @@ execute_warn_function_return (void)
 	      break;
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 }
 
@@ -4912,17 +4961,17 @@ extract_true_false_edges_from_block (bas
 				     edge *true_edge,
 				     edge *false_edge)
 {
-  edge e = b->succ;
+  edge e = EDGE_SUCC (b, 0);
 
   if (e->flags & EDGE_TRUE_VALUE)
     {
       *true_edge = e;
-      *false_edge = e->succ_next;
+      *false_edge = EDGE_SUCC (b, 1);
     }
   else
     {
       *false_edge = e;
-      *true_edge = e->succ_next;
+      *true_edge = EDGE_SUCC (b, 1);
     }
 }
 
Index: gcc/tree-if-conv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-if-conv.c,v
retrieving revision 2.8
diff -u -p -w -r2.8 tree-if-conv.c
--- gcc/tree-if-conv.c	9 Sep 2004 07:54:07 -0000	2.8
+++ gcc/tree-if-conv.c	13 Sep 2004 04:39:40 -0000
@@ -187,9 +187,9 @@ tree_if_conversion (struct loop *loop, b
 
       /* If current bb has only one successor, then consider it as an
 	 unconditional goto.  */
-      if (bb->succ && !bb->succ->succ_next)
+      if (EDGE_COUNT (bb->succs) == 1)
 	{
-	  basic_block bb_n = bb->succ->dest;
+	  basic_block bb_n = EDGE_SUCC (bb, 0)->dest;
 	  if (cond != NULL_TREE)
 	    add_to_predicate_list (bb_n, cond);
 	  cond = NULL_TREE;
@@ -490,7 +490,8 @@ if_convertable_bb_p (struct loop *loop, 
     }
 
   /* Be less adventurous and handle only normal edges.  */
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (e->flags &
 	(EDGE_ABNORMAL_CALL | EDGE_EH | EDGE_ABNORMAL | EDGE_IRREDUCIBLE_LOOP))
       {
@@ -498,6 +499,8 @@ if_convertable_bb_p (struct loop *loop, 
 	  fprintf (dump_file,"Difficult to handle edges\n");
 	return false;
       }
+    }
+  END_FOR_EACH_EDGE;
 
   return true;
 }
@@ -553,9 +556,12 @@ if_convertable_loop_p (struct loop *loop
 
   /* If one of the loop header's edge is exit edge then do not apply
      if-conversion.  */
-  for (e = loop->header->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, loop->header->succs)
+    {
     if ( e->flags & EDGE_LOOP_EXIT)
       return false;
+    }
+  END_FOR_EACH_EDGE;
 
   compute_immediate_uses (TDFA_USE_OPS|TDFA_USE_VOPS, NULL);
 
@@ -677,7 +683,7 @@ find_phi_replacement_condition (basic_bl
   basic_block true_bb = NULL; 
   tree tmp_cond;
 
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     {
       if (p1 == NULL)
 	  p1 = e->src;
@@ -687,6 +693,7 @@ find_phi_replacement_condition (basic_bl
 	  p2 = e->src;
 	}
     }
+  END_FOR_EACH_EDGE;
 
   /* Use condition that is not TRUTH_NOT_EXPR in conditional modify expr.  */
   tmp_cond = p1->aux;
@@ -874,21 +881,24 @@ combine_blocks (struct loop *loop)
 	  if (exit_bb != loop->latch)
 	    {
 	      /* Redirect non-exit edge to loop->latch.  */
-	      for (e = bb->succ; e; e = e->succ_next)
+	      FOR_EACH_EDGE (e, bb->succs)
+		{
 		if (!(e->flags & EDGE_LOOP_EXIT))
 		  {
 		    redirect_edge_and_branch (e, loop->latch);
 		    set_immediate_dominator (CDI_DOMINATORS, loop->latch, bb);
 		  }
 	    }
+	      END_FOR_EACH_EDGE;
+	    }
 	  continue;
 	}
 
       /* It is time to remove this basic block.	 First remove edges.  */
-      while (bb->succ != NULL)
-	ssa_remove_edge (bb->succ);
-      while (bb->pred != NULL)
-	ssa_remove_edge (bb->pred);
+      while (EDGE_COUNT (bb->succs) > 0)
+	ssa_remove_edge (EDGE_SUCC (bb, 0));
+      while (EDGE_COUNT (bb->preds) > 0)
+	ssa_remove_edge (EDGE_PRED (bb, 0));
 
       /* Remove labels and make stmts member of loop->header.  */
       for (bsi = bsi_start (bb); !bsi_end_p (bsi); )
@@ -955,10 +965,12 @@ static bool
 pred_blocks_visited_p (basic_block bb, bitmap *visited)
 {
   edge e;
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
+    {
     if (!bitmap_bit_p (*visited, e->src->index))
       return false;
-
+    }
+  END_FOR_EACH_EDGE;
   return true;
 }
 
@@ -1028,9 +1040,15 @@ bb_with_exit_edge_p (basic_block bb)
   edge e;
   bool exit_edge_found = false;
 
-  for (e = bb->succ; e && !exit_edge_found ; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (e->flags & EDGE_LOOP_EXIT)
+	{
       exit_edge_found = true;
+	  break;
+	}
+    }
+  END_FOR_EACH_EDGE;
 
   return exit_edge_found;
 }
Index: gcc/tree-into-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-into-ssa.c,v
retrieving revision 2.19
diff -u -p -w -r2.19 tree-into-ssa.c
--- gcc/tree-into-ssa.c	9 Sep 2004 20:53:36 -0000	2.19
+++ gcc/tree-into-ssa.c	13 Sep 2004 04:39:41 -0000
@@ -228,7 +228,7 @@ compute_global_livein (bitmap livein, bi
       bb = *--tos;
 
       /* For each predecessor block.  */
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  basic_block pred = e->src;
 	  int pred_index = pred->index;
@@ -242,6 +242,7 @@ compute_global_livein (bitmap livein, bi
 	      bitmap_set_bit (livein, pred_index);
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   free (worklist);
@@ -299,7 +300,7 @@ ssa_mark_phi_uses (struct dom_walk_data 
   tree phi, use;
   unsigned uid;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       if (e->dest == EXIT_BLOCK_PTR)
 	continue;
@@ -317,6 +318,7 @@ ssa_mark_phi_uses (struct dom_walk_data 
 	    set_livein_block (use, bb);
 	}
     }
+  END_FOR_EACH_EDGE;
 }
 
 /* Call back for walk_dominator_tree used to collect definition sites
@@ -734,9 +736,12 @@ ssa_rewrite_initialize_block (struct dom
   if (dump_file && (dump_flags & TDF_DETAILS))
     fprintf (dump_file, "\n\nRenaming block #%d\n\n", bb->index);
 
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
+    {
     if (e->flags & EDGE_ABNORMAL)
       break;
+    }
+  END_FOR_EACH_EDGE;
   abnormal_phi = (e != NULL);
 
   /* Step 1.  Register new definitions for every PHI node in the block.
@@ -772,7 +777,7 @@ rewrite_add_phi_arguments (struct dom_wa
 {
   edge e;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       tree phi;
 
@@ -790,6 +795,7 @@ rewrite_add_phi_arguments (struct dom_wa
 	  add_phi_arg (&phi, currdef, e);
 	}
     }
+  END_FOR_EACH_EDGE;
 }
 
 /* Ditto, for ssa name rewriting.  */
@@ -801,7 +807,7 @@ ssa_rewrite_phi_arguments (struct dom_wa
   sbitmap names_to_rename = walk_data->global_data;
   use_operand_p op;
 
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       tree phi;
 
@@ -822,6 +828,7 @@ ssa_rewrite_phi_arguments (struct dom_wa
 	    SSA_NAME_OCCURS_IN_ABNORMAL_PHI (USE_FROM_PTR (op)) = 1;
 	}
     }
+  END_FOR_EACH_EDGE;
 }
 
 /* SSA Rewriting Step 5.  Restore the current reaching definition for each
@@ -1023,9 +1030,12 @@ insert_phi_nodes_for (tree var, bitmap *
 	/* If we are rewriting ssa names, add also the phi arguments.  */
 	if (TREE_CODE (var) == SSA_NAME)
 	  {
-	    for (e = bb->pred; e; e = e->pred_next)
+	    FOR_EACH_EDGE (e, bb->preds)
+	      {
 	      add_phi_arg (&phi, var, e);
 	  }
+	    END_FOR_EACH_EDGE;
+	  }
       }
     while (0));
 
@@ -1436,13 +1446,7 @@ rewrite_into_ssa (bool all)
   dfs = (bitmap *) xmalloc (last_basic_block * sizeof (bitmap *));
   FOR_EACH_BB (bb)
     {
-      edge e;
-      int count = 0;
-
-      for (e = bb->pred; e; e = e->pred_next)
-	count++;
-
-      bb_ann (bb)->num_preds = count;
+      bb_ann (bb)->num_preds = EDGE_COUNT (bb->preds);
       dfs[bb->index] = BITMAP_XMALLOC ();
     }
 
@@ -1568,13 +1572,7 @@ rewrite_ssa_into_ssa (void)
   dfs = (bitmap *) xmalloc (last_basic_block * sizeof (bitmap *));
   FOR_EACH_BB (bb)
     {
-      edge e;
-      int count = 0;
-
-      for (e = bb->pred; e; e = e->pred_next)
-	count++;
-
-      bb_ann (bb)->num_preds = count;
+      bb_ann (bb)->num_preds = EDGE_COUNT (bb->preds);
       dfs[bb->index] = BITMAP_XMALLOC ();
     }
 
Index: gcc/tree-mudflap.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-mudflap.c,v
retrieving revision 2.23
diff -u -p -w -r2.23 tree-mudflap.c
--- gcc/tree-mudflap.c	10 Sep 2004 15:09:38 -0000	2.23
+++ gcc/tree-mudflap.c	13 Sep 2004 04:39:41 -0000
@@ -525,7 +525,7 @@ mf_build_check_statement_for (tree addr,
 
   /* We expect that the conditional jump we will construct will not
      be taken very often as it basically is an exception condition.  */
-  predict_edge_def (then_bb->pred, PRED_MUDFLAP, NOT_TAKEN);
+  predict_edge_def (EDGE_PRED (then_bb, 0), PRED_MUDFLAP, NOT_TAKEN);
 
   /* Update dominance info.  Note that bb_join's data was
      updated by split_block.  */
Index: gcc/tree-outof-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-outof-ssa.c,v
retrieving revision 2.21
diff -u -p -w -r2.21 tree-outof-ssa.c
--- gcc/tree-outof-ssa.c	9 Sep 2004 20:53:36 -0000	2.21
+++ gcc/tree-outof-ssa.c	13 Sep 2004 04:39:42 -0000
@@ -587,7 +587,8 @@ coalesce_abnormal_edges (var_map map, co
      that edge.  */
 
   FOR_EACH_BB (bb)
-    for (e = bb->succ; e; e = e->succ_next)
+    FOR_EACH_EDGE (e, bb->succs)
+    {
       if (e->dest != EXIT_BLOCK_PTR && e->flags & EDGE_ABNORMAL)
 	for (phi = phi_nodes (e->dest); phi; phi = PHI_CHAIN (phi))
 	  {
@@ -669,6 +670,8 @@ coalesce_abnormal_edges (var_map map, co
 	      }
 	  }
 }
+  END_FOR_EACH_EDGE;
+}
 
 
 /* Reduce the number of live ranges in MAP.  Live range information is 
@@ -1928,9 +1931,12 @@ rewrite_trees (var_map map, tree *values
       phi = phi_nodes (bb);
       if (phi)
         {
-	  for (e = bb->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, bb->preds)
+	    {
 	    eliminate_phi (e, phi_arg_from_edge (phi, e), g);
 	}
+	  END_FOR_EACH_EDGE;
+	}
     }
 
   delete_elim_graph (g);
Index: gcc/tree-pretty-print.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-pretty-print.c,v
retrieving revision 2.37
diff -u -p -w -r2.37 tree-pretty-print.c
--- gcc/tree-pretty-print.c	11 Sep 2004 19:48:54 -0000	2.37
+++ gcc/tree-pretty-print.c	13 Sep 2004 04:39:42 -0000
@@ -2139,7 +2139,8 @@ dump_bb_header (pretty_printer *buffer, 
 
       pp_string (buffer, "# PRED:");
       pp_write_text_to_stream (buffer);
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
         if (flags & TDF_SLIM)
 	  {
 	    pp_string (buffer, " ");
@@ -2150,6 +2151,8 @@ dump_bb_header (pretty_printer *buffer, 
 	  }
 	else
 	  dump_edge_info (buffer->buffer->stream, e, 0);
+	}
+      END_FOR_EACH_EDGE;
       pp_newline (buffer);
     }
   else
@@ -2179,7 +2182,9 @@ dump_bb_end (pretty_printer *buffer, bas
   INDENT (indent);
   pp_string (buffer, "# SUCC:");
   pp_write_text_to_stream (buffer);
-  for (e = bb->succ; e; e = e->succ_next)
+
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (flags & TDF_SLIM)
       {
 	pp_string (buffer, " ");
@@ -2190,6 +2195,8 @@ dump_bb_end (pretty_printer *buffer, bas
       }
     else
       dump_edge_info (buffer->buffer->stream, e, 1);
+    }
+  END_FOR_EACH_EDGE;
   pp_newline (buffer);
 }
 
@@ -2248,9 +2255,12 @@ dump_implicit_edges (pretty_printer *buf
 
   /* If there is a fallthru edge, we may need to add an artificial goto to the
      dump.  */
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
+    {
     if (e->flags & EDGE_FALLTHRU)
       break;
+    }
+  END_FOR_EACH_EDGE;
   if (e && e->dest != bb->next_bb)
     {
       INDENT (indent);
Index: gcc/tree-sra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-sra.c,v
retrieving revision 2.31
diff -u -p -w -r2.31 tree-sra.c
--- gcc/tree-sra.c	11 Sep 2004 23:44:19 -0000	2.31
+++ gcc/tree-sra.c	13 Sep 2004 04:39:43 -0000
@@ -1664,7 +1664,7 @@ insert_edge_copies (tree stmt, basic_blo
   bool first_copy;
 
   first_copy = true;
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       /* We don't need to insert copies on abnormal edges.  The
 	 value of the scalar replacement is not guaranteed to
@@ -1680,6 +1680,7 @@ insert_edge_copies (tree stmt, basic_blo
 	    bsi_insert_on_edge (e, unsave_expr_now (stmt));
 	}
     }
+  END_FOR_EACH_EDGE;
 }
 
 /* Helper function to insert LIST before BSI, and set up line number info.  */
Index: gcc/tree-ssa-dce.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dce.c,v
retrieving revision 2.17
diff -u -p -w -r2.17 tree-ssa-dce.c
--- gcc/tree-ssa-dce.c	10 Sep 2004 08:58:47 -0000	2.17
+++ gcc/tree-ssa-dce.c	13 Sep 2004 04:39:43 -0000
@@ -495,10 +495,13 @@ find_obviously_necessary_stmts (struct e
 	 and we currently do not have a means to recognize the finite ones.  */
       FOR_EACH_BB (bb)
 	{
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (e->flags & EDGE_DFS_BACK)
 	      mark_control_dependent_edges_necessary (e->dest, el);
 	}
+	  END_FOR_EACH_EDGE;
+	}
     }
 }
 
@@ -722,7 +725,6 @@ remove_dead_stmt (block_stmt_iterator *i
   if (is_ctrl_stmt (t))
     {
       basic_block post_dom_bb;
-      edge e;
       /* The post dominance info has to be up-to-date.  */
       gcc_assert (dom_computed[CDI_POST_DOMINATORS] == DOM_OK);
       /* Get the immediate post dominator of bb.  */
@@ -737,30 +739,26 @@ remove_dead_stmt (block_stmt_iterator *i
 	}
 
       /* Redirect the first edge out of BB to reach POST_DOM_BB.  */
-      redirect_edge_and_branch (bb->succ, post_dom_bb);
-      PENDING_STMT (bb->succ) = NULL;
-      bb->succ->probability = REG_BR_PROB_BASE;
-      bb->succ->count = bb->count;
+      redirect_edge_and_branch (EDGE_SUCC (bb, 0), post_dom_bb);
+      PENDING_STMT (EDGE_SUCC (bb, 0)) = NULL;
+      EDGE_SUCC (bb, 0)->probability = REG_BR_PROB_BASE;
+      EDGE_SUCC (bb, 0)->count = bb->count;
 
       /* The edge is no longer associated with a conditional, so it does
 	 not have TRUE/FALSE flags.  */
-      bb->succ->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
+      EDGE_SUCC (bb, 0)->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
 
       /* If the edge reaches any block other than the exit, then it is a
 	 fallthru edge; if it reaches the exit, then it is not a fallthru
 	 edge.  */
       if (post_dom_bb != EXIT_BLOCK_PTR)
-	bb->succ->flags |= EDGE_FALLTHRU;
+	EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
       else
-	bb->succ->flags &= ~EDGE_FALLTHRU;
+	EDGE_SUCC (bb, 0)->flags &= ~EDGE_FALLTHRU;
 
       /* Remove the remaining the outgoing edges.  */
-      for (e = bb->succ->succ_next; e != NULL;)
-	{
-	  edge tmp = e;
-	  e = e->succ_next;
-	  remove_edge (tmp);
-	}
+      while (EDGE_COUNT (bb->succs) != 1)
+	remove_edge (EDGE_SUCC (bb, 1));
     }
 
   bsi_remove (i);
Index: gcc/tree-ssa-dom.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-dom.c,v
retrieving revision 2.37
diff -u -p -w -r2.37 tree-ssa-dom.c
--- gcc/tree-ssa-dom.c	9 Sep 2004 07:54:12 -0000	2.37
+++ gcc/tree-ssa-dom.c	13 Sep 2004 04:39:44 -0000
@@ -589,9 +589,12 @@ thread_across_edge (struct dom_walk_data
 	 edges forward to the same destination block.  */
       if (!e->flags & EDGE_DFS_BACK)
 	{
-	  for (e1 = e->dest->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e1, e->dest->preds)
+	    {
 	    if (e1->flags & EDGE_DFS_BACK)
 	      break;
+	    }
+	  END_FOR_EACH_EDGE;
 	  if (e1)
 	    return;
 	}
@@ -913,24 +916,21 @@ dom_opt_finalize_block (struct dom_walk_
      the edge from BB through its successor.
 
      Do this before we remove entries from our equivalence tables.  */
-  if (bb->succ
-      && ! bb->succ->succ_next
-      && (bb->succ->flags & EDGE_ABNORMAL) == 0
-      && (get_immediate_dominator (CDI_DOMINATORS, bb->succ->dest) != bb
-	  || phi_nodes (bb->succ->dest)))
+  if (EDGE_COUNT (bb->succs) == 1
+      && (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL) == 0
+      && (get_immediate_dominator (CDI_DOMINATORS, EDGE_SUCC (bb, 0)->dest) != bb
+	  || phi_nodes (EDGE_SUCC (bb, 0)->dest)))
 	
     {
-      thread_across_edge (walk_data, bb->succ);
+      thread_across_edge (walk_data, EDGE_SUCC (bb, 0));
     }
   else if ((last = last_stmt (bb))
 	   && TREE_CODE (last) == COND_EXPR
 	   && (TREE_CODE_CLASS (TREE_CODE (COND_EXPR_COND (last))) == '<'
 	       || TREE_CODE (COND_EXPR_COND (last)) == SSA_NAME)
-	   && bb->succ
-	   && (bb->succ->flags & EDGE_ABNORMAL) == 0
-	   && bb->succ->succ_next
-	   && (bb->succ->succ_next->flags & EDGE_ABNORMAL) == 0
-	   && ! bb->succ->succ_next->succ_next)
+	   && EDGE_COUNT (bb->succs) == 2
+	   && (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL) == 0
+	   && (EDGE_SUCC (bb, 1)->flags & EDGE_ABNORMAL) == 0)
     {
       edge true_edge, false_edge;
       tree cond, inverted = NULL;
@@ -1141,7 +1141,7 @@ single_incoming_edge_ignoring_loop_edges
   edge retval = NULL;
   edge e;
 
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     {
       /* A loop back edge can be identified by the destination of
 	 the edge dominating the source of the edge.  */
@@ -1157,6 +1157,7 @@ single_incoming_edge_ignoring_loop_edges
 	 it.  */
       retval = e;
     }
+  END_FOR_EACH_EDGE;
 
   return retval;
 }
@@ -1192,7 +1193,7 @@ record_equivalences_from_incoming_edge (
   /* If we have a single predecessor (ignoring loop backedges), then extract
      EDGE_FLAGS from the single incoming edge.  Otherwise just return as
      there is nothing to do.  */
-  if (bb->pred
+  if (EDGE_COUNT (bb->preds) >= 1
       && parent_block_last_stmt)
     {
       edge e = single_incoming_edge_ignoring_loop_edges (bb);
@@ -1225,7 +1226,7 @@ record_equivalences_from_incoming_edge (
   /* Similarly when the parent block ended in a SWITCH_EXPR.
      We can only know the value of the switch's condition if the dominator
      parent is also the only predecessor of this block.  */
-  else if (bb->pred->src == parent
+  else if (EDGE_PRED (bb, 0)->src == parent
 	   && TREE_CODE (parent_block_last_stmt) == SWITCH_EXPR)
     {
       tree switch_cond = SWITCH_COND (parent_block_last_stmt);
@@ -2265,7 +2266,8 @@ cprop_into_successor_phis (basic_block b
 
   /* This can get rather expensive if the implementation is naive in
      how it finds the phi alternative associated with a particular edge.  */
-  for (e = bb->succ; e; e = e->succ_next)
+
+  FOR_EACH_EDGE (e, bb->succs)
     {
       tree phi;
       int phi_num_args;
@@ -2341,6 +2343,7 @@ cprop_into_successor_phis (basic_block b
 	    }
 	}
     }
+  END_FOR_EACH_EDGE;
 }
 
 
Index: gcc/tree-ssa-live.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-live.c,v
retrieving revision 2.19
diff -u -p -w -r2.19 tree-ssa-live.c
--- gcc/tree-ssa-live.c	10 Sep 2004 15:09:39 -0000	2.19
+++ gcc/tree-ssa-live.c	13 Sep 2004 04:39:45 -0000
@@ -503,7 +503,8 @@ live_worklist (tree_live_info_p live, va
       b = VARRAY_TOP_INT (stack);
       VARRAY_POP (stack);
 
-      for (e = BASIC_BLOCK (b)->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, BASIC_BLOCK (b)->preds)
+	{
         if (e->src != ENTRY_BLOCK_PTR)
 	  {
 	    /* Its not live on entry to the block its defined in.  */
@@ -516,6 +517,8 @@ live_worklist (tree_live_info_p live, va
 	      }
 	  }
     }
+      END_FOR_EACH_EDGE;
+    }
 }
 
 
@@ -640,7 +643,7 @@ calculate_live_on_entry (var_map map)
 
   bb = ENTRY_BLOCK_PTR;
   num = 0;
-  for (e = bb->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, bb->succs)
     {
       int entry_block = e->dest->index;
       if (e->dest == EXIT_BLOCK_PTR)
@@ -714,6 +717,7 @@ calculate_live_on_entry (var_map map)
 	      }
 	}
     }
+  END_FOR_EACH_EDGE;
   gcc_assert (num <= 0);
 #endif
 
@@ -761,9 +765,12 @@ calculate_live_on_exit (tree_live_info_p
       on_entry = live_entry_blocks (liveinfo, i);
       EXECUTE_IF_SET_IN_BITMAP (on_entry, 0, b,
         {
-	  for (e = BASIC_BLOCK(b)->pred; e; e = e->pred_next)
+	  FOR_EACH_EDGE (e, BASIC_BLOCK (b)->preds)
+	    {
 	    if (e->src != ENTRY_BLOCK_PTR)
 	      bitmap_set_bit (on_exit[e->src->index], i);
+	    }
+	  END_FOR_EACH_EDGE;
 	});
     }
 
Index: gcc/tree-ssa-loop-ch.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ch.c,v
retrieving revision 2.5
diff -u -p -w -r2.5 tree-ssa-loop-ch.c
--- gcc/tree-ssa-loop-ch.c	9 Sep 2004 07:54:12 -0000	2.5
+++ gcc/tree-ssa-loop-ch.c	13 Sep 2004 04:39:45 -0000
@@ -59,19 +59,16 @@ should_duplicate_loop_header_p (basic_bl
   if (header->aux)
     return false;
 
-  gcc_assert (header->succ);
-  if (!header->succ->succ_next)
+  gcc_assert (EDGE_COUNT (header->succs) > 0);
+  if (EDGE_COUNT (header->succs) == 1)
     return false;
-  if (header->succ->succ_next->succ_next)
-    return false;
-  if (flow_bb_inside_loop_p (loop, header->succ->dest)
-      && flow_bb_inside_loop_p (loop, header->succ->succ_next->dest))
+  if (flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 0)->dest)
+      && flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 1)->dest))
     return false;
 
   /* If this is not the original loop header, we want it to have just
      one predecessor in order to match the && pattern.  */
-  if (header != loop->header
-      && header->pred->pred_next)
+  if (header != loop->header && EDGE_COUNT (header->preds) >= 2)
     return false;
 
   last = last_stmt (header);
@@ -104,7 +101,7 @@ static void
 duplicate_blocks (varray_type bbs_to_duplicate)
 {
   unsigned i;
-  edge preheader_edge, e, e1;
+  edge preheader_edge, e;
   basic_block header, new_header;
   tree phi, new_phi, var;
 
@@ -133,10 +130,17 @@ duplicate_blocks (varray_type bbs_to_dup
       PENDING_STMT (preheader_edge) = NULL;
 
       /* Add the phi arguments to the outgoing edges.  */
-      for (e = header->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, header->succs)
 	{
-	  for (e1 = new_header->succ; e1->dest != e->dest; e1 = e1->succ_next)
-	    continue;
+	  edge e1;
+	  FOR_EACH_EDGE (e1, new_header->succs)
+	    {
+	      if (e1->dest == e->dest)
+		break;
+	    }
+	  END_FOR_EACH_EDGE;
+	  if (e1 == NULL)
+	    abort ();
 
 	  for (phi = phi_nodes (e->dest); phi; phi = TREE_CHAIN (phi))
 	    {
@@ -144,6 +148,7 @@ duplicate_blocks (varray_type bbs_to_dup
 	      add_phi_arg (&phi, def, e1);
 	    }
 	}
+      END_FOR_EACH_EDGE;
     }
 
   calculate_dominance_info (CDI_DOMINATORS);
@@ -240,10 +245,10 @@ copy_loop_headers (void)
 
 	  /* Find a successor of header that is inside a loop; i.e. the new
 	     header after the condition is copied.  */
-	  if (flow_bb_inside_loop_p (loop, header->succ->dest))
-	    preheader_edge = header->succ;
+	  if (flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 0)->dest))
+	    preheader_edge = EDGE_SUCC (header, 0);
 	  else
-	    preheader_edge = header->succ->succ_next;
+	    preheader_edge = EDGE_SUCC (header, 1);
 	  header = preheader_edge->dest;
 	}
     }
Index: gcc/tree-ssa-loop-im.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-im.c,v
retrieving revision 2.12
diff -u -p -w -r2.12 tree-ssa-loop-im.c
--- gcc/tree-ssa-loop-im.c	11 Sep 2004 20:42:06 -0000	2.12
+++ gcc/tree-ssa-loop-im.c	13 Sep 2004 04:39:45 -0000
@@ -591,8 +591,8 @@ loop_commit_inserts (void)
     {
       bb = BASIC_BLOCK (i);
       add_bb_to_loop (bb,
-		      find_common_loop (bb->succ->dest->loop_father,
-					bb->pred->src->loop_father));
+		      find_common_loop (EDGE_SUCC (bb, 0)->dest->loop_father,
+					EDGE_PRED (bb, 0)->src->loop_father));
     }
 }
 
@@ -1310,9 +1310,13 @@ fill_always_executed_in (struct loop *lo
 	  if (TEST_BIT (contains_call, bb->index))
 	    break;
 
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
+	    {
 	    if (!flow_bb_inside_loop_p (loop, e->dest))
 	      break;
+	    }
+	  END_FOR_EACH_EDGE;
+
 	  if (e)
 	    break;
 
Index: gcc/tree-ssa-loop-ivcanon.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivcanon.c,v
retrieving revision 2.3
diff -u -p -w -r2.3 tree-ssa-loop-ivcanon.c
--- gcc/tree-ssa-loop-ivcanon.c	3 Sep 2004 02:19:37 -0000	2.3
+++ gcc/tree-ssa-loop-ivcanon.c	13 Sep 2004 04:39:46 -0000
@@ -74,9 +74,9 @@ create_canonical_iv (struct loop *loop, 
     }
 
   cond = last_stmt (exit->src);
-  in = exit->src->succ;
+  in = EDGE_SUCC (exit->src, 0);
   if (in == exit)
-    in = in->succ_next;
+    in = EDGE_SUCC (exit->src, 1);
 
   /* Note that we do not need to worry about overflows, since
      type of niter is always unsigned and all comparisons are
Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.9
diff -u -p -w -r2.9 tree-ssa-loop-ivopts.c
--- gcc/tree-ssa-loop-ivopts.c	10 Sep 2004 08:56:36 -0000	2.9
+++ gcc/tree-ssa-loop-ivopts.c	13 Sep 2004 04:39:47 -0000
@@ -1397,10 +1397,13 @@ find_interesting_uses (struct ivopts_dat
     {
       bb = body[i];
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
+	{
 	if (e->dest != EXIT_BLOCK_PTR
 	    && !flow_bb_inside_loop_p (data->current_loop, e->dest))
 	  find_interesting_uses_outside (data, e);
+        }
+      END_FOR_EACH_EDGE;
 
       for (phi = phi_nodes (bb); phi; phi = TREE_CHAIN (phi))
 	find_interesting_uses_stmt (data, phi);
@@ -4053,7 +4056,7 @@ compute_phi_arg_on_exit (edge exit, tree
   block_stmt_iterator bsi;
   tree phi, stmt, def, next;
 
-  if (exit->dest->pred->pred_next)
+  if (EDGE_COUNT (exit->dest->preds) > 1)
     split_loop_exit_edge (exit);
 
   if (TREE_CODE (stmts) == STATEMENT_LIST)
Index: gcc/tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-manip.c,v
retrieving revision 2.6
diff -u -p -w -r2.6 tree-ssa-loop-manip.c
--- gcc/tree-ssa-loop-manip.c	12 Sep 2004 20:20:58 -0000	2.6
+++ gcc/tree-ssa-loop-manip.c	13 Sep 2004 04:39:47 -0000
@@ -126,20 +126,22 @@ add_exit_phis_edge (basic_block exit, tr
 
   /* Check that some of the edges entering the EXIT block exits a loop in
      that USE is defined.  */
-  for (e = exit->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, exit->preds)
     {
       def_loop = find_common_loop (def_bb->loop_father, e->src->loop_father);
       if (!flow_bb_inside_loop_p (def_loop, e->dest))
 	break;
     }
+  END_FOR_EACH_EDGE;
 
   if (!e)
     return;
 
   phi = create_phi_node (use, exit);
 
-  for (e = exit->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, exit->preds)
     add_phi_arg (&phi, use, e);
+  END_FOR_EACH_EDGE;
 
   SSA_NAME_DEF_STMT (use) = def_stmt;
 }
@@ -191,13 +193,14 @@ get_loops_exits (void)
 
   FOR_EACH_BB (bb)
     {
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	if (e->src != ENTRY_BLOCK_PTR
 	    && !flow_bb_inside_loop_p (e->src->loop_father, bb))
 	  {
 	    bitmap_set_bit (exits, bb->index);
 	    break;
 	  }
+      END_FOR_EACH_EDGE;
     }
 
   return exits;
@@ -400,7 +403,7 @@ split_loop_exit_edge (edge exit)
 
   for (phi = phi_nodes (dest); phi; phi = TREE_CHAIN (phi))
     {
-      op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, bb->succ);
+      op_p = PHI_ARG_DEF_PTR_FROM_EDGE (phi, EDGE_SUCC (bb, 0));
 
       name = USE_FROM_PTR (op_p);
 
@@ -464,17 +467,17 @@ ip_normal_pos (struct loop *loop)
   basic_block bb;
   edge exit;
 
-  if (loop->latch->pred->pred_next)
+  if (EDGE_COUNT (loop->latch->preds) > 1)
     return NULL;
 
-  bb = loop->latch->pred->src;
+  bb = EDGE_PRED (loop->latch, 0)->src;
   last = last_stmt (bb);
   if (TREE_CODE (last) != COND_EXPR)
     return NULL;
 
-  exit = bb->succ;
+  exit = EDGE_SUCC (bb, 0);
   if (exit->dest == loop->latch)
-    exit = exit->succ_next;
+    exit = EDGE_SUCC (bb, 1);
 
   if (flow_bb_inside_loop_p (loop, exit->dest))
     return NULL;
Index: gcc/tree-ssa-loop-niter.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-niter.c,v
retrieving revision 2.7
diff -u -p -w -r2.7 tree-ssa-loop-niter.c
--- gcc/tree-ssa-loop-niter.c	5 Sep 2004 15:24:15 -0000	2.7
+++ gcc/tree-ssa-loop-niter.c	13 Sep 2004 04:39:48 -0000
@@ -582,8 +582,8 @@ simplify_using_initial_conditions (struc
        bb != ENTRY_BLOCK_PTR;
        bb = get_immediate_dominator (CDI_DOMINATORS, bb))
     {
-      e = bb->pred;
-      if (e->pred_next)
+      e = EDGE_PRED (bb, 0);
+      if (EDGE_COUNT (bb->preds) > 1)
 	continue;
 
       if (!(e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
Index: gcc/tree-ssa-phiopt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-phiopt.c,v
retrieving revision 2.12
diff -u -p -w -r2.12 tree-ssa-phiopt.c
--- gcc/tree-ssa-phiopt.c	6 Sep 2004 10:08:09 -0000	2.12
+++ gcc/tree-ssa-phiopt.c	13 Sep 2004 04:39:48 -0000
@@ -185,39 +185,35 @@ candidate_bb_for_phi_optimization (basic
 
   /* One of the alternatives must come from a block ending with
      a COND_EXPR.  */
-  last0 = last_stmt (bb->pred->src);
-  last1 = last_stmt (bb->pred->pred_next->src);
+  last0 = last_stmt (EDGE_PRED (bb, 0)->src);
+  last1 = last_stmt (EDGE_PRED (bb, 1)->src);
   if (last0 && TREE_CODE (last0) == COND_EXPR)
     {
-      cond_block = bb->pred->src;
-      other_block = bb->pred->pred_next->src;
+      cond_block = EDGE_PRED (bb, 0)->src;
+      other_block = EDGE_PRED (bb, 1)->src;
     }
   else if (last1 && TREE_CODE (last1) == COND_EXPR)
     {
-      other_block = bb->pred->src;
-      cond_block = bb->pred->pred_next->src;
+      other_block = EDGE_PRED (bb, 0)->src;
+      cond_block = EDGE_PRED (bb, 1)->src;
     }
   else
     return false;
   
   /* COND_BLOCK must have precisely two successors.  We indirectly
      verify that those successors are BB and OTHER_BLOCK.  */
-  if (!cond_block->succ
-      || !cond_block->succ->succ_next
-      || cond_block->succ->succ_next->succ_next
-      || (cond_block->succ->flags & EDGE_ABNORMAL) != 0
-      || (cond_block->succ->succ_next->flags & EDGE_ABNORMAL) != 0)
+  if (EDGE_COUNT (cond_block->succs) != 2
+      || (EDGE_SUCC (cond_block, 0)->flags & EDGE_ABNORMAL) != 0
+      || (EDGE_SUCC (cond_block, 1)->flags & EDGE_ABNORMAL) != 0)
     return false;
   
   /* OTHER_BLOCK must have a single predecessor which is COND_BLOCK,
      OTHER_BLOCK must have a single successor which is BB and
      OTHER_BLOCK must have no PHI nodes.  */
-  if (!other_block->pred
-      || other_block->pred->src != cond_block
-      || other_block->pred->pred_next
-      || !other_block->succ
-      || other_block->succ->dest != bb
-      || other_block->succ->succ_next
+  if (EDGE_COUNT (other_block->preds) != 1
+      || EDGE_PRED (other_block, 0)->src != cond_block
+      || EDGE_COUNT (other_block->succs) != 1
+      || EDGE_SUCC (other_block, 0)->dest != bb
       || phi_nodes (other_block))
     return false;
   
@@ -252,20 +248,20 @@ replace_phi_with_stmt (block_stmt_iterat
   bb_ann (bb)->phi_nodes = NULL;
   
   /* Remove the empty basic block.  */
-  if (cond_block->succ->dest == bb)
+  if (EDGE_SUCC (cond_block, 0)->dest == bb)
     {
-      cond_block->succ->flags |= EDGE_FALLTHRU;
-      cond_block->succ->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
+      EDGE_SUCC (cond_block, 0)->flags |= EDGE_FALLTHRU;
+      EDGE_SUCC (cond_block, 0)->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
 
-      block_to_remove = cond_block->succ->succ_next->dest;
+      block_to_remove = EDGE_SUCC (cond_block, 1)->dest;
     }
   else
     {
-      cond_block->succ->succ_next->flags |= EDGE_FALLTHRU;
-      cond_block->succ->succ_next->flags
+      EDGE_SUCC (cond_block, 1)->flags |= EDGE_FALLTHRU;
+      EDGE_SUCC (cond_block, 1)->flags
 	&= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
 
-      block_to_remove = cond_block->succ->dest;
+      block_to_remove = EDGE_SUCC (cond_block, 0)->dest;
     }
   delete_basic_block (block_to_remove);
   
@@ -477,7 +473,7 @@ value_replacement (basic_block bb, tree 
 	 edge from OTHER_BLOCK which reaches BB and represents the desired
 	 path from COND_BLOCK.  */
       if (e->dest == other_block)
-	e = e->dest->succ;
+	e = EDGE_SUCC (e->dest, 0);
 
       /* Now we know the incoming edge to BB that has the argument for the
 	 RHS of our new assignment statement.  */
Index: gcc/tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-pre.c,v
retrieving revision 2.35
diff -u -p -w -r2.35 tree-ssa-pre.c
--- gcc/tree-ssa-pre.c	11 Sep 2004 21:14:38 -0000	2.35
+++ gcc/tree-ssa-pre.c	13 Sep 2004 04:39:49 -0000
@@ -1128,13 +1128,16 @@ compute_antic_aux (basic_block block)
      setting the BB_VISITED flag.  */
   if (! (block->flags & BB_VISITED))
     {
-      for (e = block->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, block->preds)
+	{
  	if (e->flags & EDGE_ABNORMAL)
  	  {
  	    block->flags |= BB_VISITED;
  	    break;
  	  }
     }
+      END_FOR_EACH_EDGE;
+    }
   if (block->flags & BB_VISITED)
     {
       S = NULL;
@@ -1148,14 +1151,14 @@ compute_antic_aux (basic_block block)
 
   /* If the block has no successors, ANTIC_OUT is empty, because it is
      the exit block.  */
-  if (block->succ == NULL);
+  if (EDGE_COUNT (block->succs) == 0);
 
   /* If we have one successor, we could have some phi nodes to
      translate through.  */
-  else if (block->succ->succ_next == NULL)
+  else if (EDGE_COUNT (block->succs) == 1)
     {
-      phi_translate_set (ANTIC_OUT, ANTIC_IN(block->succ->dest),
-			 block, block->succ->dest);
+      phi_translate_set (ANTIC_OUT, ANTIC_IN(EDGE_SUCC (block, 0)->dest),
+			 block, EDGE_SUCC (block, 0)->dest);
     }
   /* If we have multiple successors, we take the intersection of all of
      them.  */
@@ -1167,12 +1170,12 @@ compute_antic_aux (basic_block block)
       basic_block bprime, first;
 
       VARRAY_BB_INIT (worklist, 1, "succ");
-      e = block->succ;
-      while (e)
+      FOR_EACH_EDGE (e, block->succs)
 	{
 	  VARRAY_PUSH_BB (worklist, e->dest);
-	  e = e->succ_next;
 	}
+      END_FOR_EACH_EDGE;
+
       first = VARRAY_BB (worklist, 0);
       set_copy (ANTIC_OUT, ANTIC_IN (first));
 
@@ -1416,7 +1419,7 @@ insert_aux (basic_block block)
 	    bitmap_insert_into_set (NEW_SETS (block), ssa_name (i));
 	    bitmap_value_replace_in_set (AVAIL_OUT (block), ssa_name (i));
 	  });
-	  if (block->pred->pred_next)
+	  if (EDGE_COUNT (block->preds) >= 2)
 	    {
 	      value_set_node_t node;
 	      for (node = ANTIC_IN (block)->head;
@@ -1447,9 +1450,8 @@ insert_aux (basic_block block)
 			}
 		    		    
 		      avail = xcalloc (last_basic_block, sizeof (tree));
-		      for (pred = block->pred;
-			   pred;
-			   pred = pred->pred_next)
+
+		      FOR_EACH_EDGE (pred, block->preds)
 			{
 			  tree vprime;
 			  tree edoubleprime;
@@ -1504,13 +1506,15 @@ insert_aux (basic_block block)
 					      (first_s, edoubleprime, 0));
 			    }
 			}
+		      END_FOR_EACH_EDGE;
+
 		      /* If we can insert it, it's not the same value
 			 already existing along every predecessor, and
 			 it's defined by some predecessor, it is
 			 partially redundant.  */
 		      if (!cant_insert && !all_same && by_some)
 			{
-			  tree type = TREE_TYPE (avail[block->pred->src->index]);
+			  tree type = TREE_TYPE (avail[EDGE_PRED (block, 0)->src->index]);
 			  tree temp;
 			  if (dump_file && (dump_flags & TDF_DETAILS))
 			    {
@@ -1520,9 +1524,7 @@ insert_aux (basic_block block)
 			    }
 
 			  /* Make the necessary insertions.  */
-			  for (pred = block->pred;
-			       pred;
-			       pred = pred->pred_next)
+			  FOR_EACH_EDGE (pred, block->preds)
 			    {
 			      tree stmts = alloc_stmt_list ();
 			      tree builtexpr;
@@ -1539,6 +1541,8 @@ insert_aux (basic_block block)
 				  avail[bprime->index] = builtexpr;
 				}			      
 			    } 
+			  END_FOR_EACH_EDGE;
+
 			  /* Now build a phi for the new variable.  */
 			  temp = create_tmp_var (type, "prephitmp");
 			  add_referenced_tmp_var (temp);
@@ -1553,13 +1557,14 @@ insert_aux (basic_block block)
 #endif
 			    bitmap_value_replace_in_set (AVAIL_OUT (block), 
 							 PHI_RESULT (temp));
-			  for (pred = block->pred;
-			       pred;
-			       pred = pred->pred_next)
+
+			  FOR_EACH_EDGE (pred, block->preds)
 			    {
 			      add_phi_arg (&temp, avail[pred->src->index],
 					   pred);
 			    }
+			  END_FOR_EACH_EDGE;
+
 			  if (dump_file && (dump_flags & TDF_DETAILS))
 			    {
 			      fprintf (dump_file, "Created phi ");
@@ -1918,9 +1923,9 @@ init_pre (void)
      ENTRY_BLOCK_PTR (FIXME, if ENTRY_BLOCK_PTR had an index number
      different than -1 we wouldn't have to hack this.  tree-ssa-dce.c
      needs a similar change).  */
-  if (ENTRY_BLOCK_PTR->succ->dest->pred->pred_next)
-    if (!(ENTRY_BLOCK_PTR->succ->flags & EDGE_ABNORMAL))
-      split_edge (ENTRY_BLOCK_PTR->succ);
+  if (EDGE_COUNT (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest->preds) > 1)
+    if (!(EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->flags & EDGE_ABNORMAL))
+      split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
 
   FOR_ALL_BB (bb)
     bb->aux = xcalloc (1, sizeof (struct bb_value_sets));
Index: gcc/tree-ssa-propagate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-propagate.c,v
retrieving revision 2.4
diff -u -p -w -r2.4 tree-ssa-propagate.c
--- gcc/tree-ssa-propagate.c	9 Sep 2004 07:54:12 -0000	2.4
+++ gcc/tree-ssa-propagate.c	13 Sep 2004 04:39:49 -0000
@@ -319,8 +319,9 @@ simulate_stmt (tree stmt)
 	{
 	  edge e;
 	  basic_block bb = bb_for_stmt (stmt);
-	  for (e = bb->succ; e; e = e->succ_next)
+	  FOR_EACH_EDGE (e, bb->succs)
 	    add_control_edge (e);
+	  END_FOR_EACH_EDGE;
 	}
     }
   else if (val == SSA_PROP_INTERESTING)
@@ -434,7 +435,7 @@ simulate_block (basic_block block)
 	 worklist.  */
       normal_edge_count = 0;
       normal_edge = NULL;
-      for (e = block->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, block->succs)
 	{
 	  if (e->flags & EDGE_ABNORMAL)
 	    add_control_edge (e);
@@ -444,6 +445,7 @@ simulate_block (basic_block block)
 	      normal_edge = e;
 	    }
 	}
+      END_FOR_EACH_EDGE;
 
       if (normal_edge_count == 1)
 	add_control_edge (normal_edge);
@@ -482,13 +484,14 @@ ssa_prop_init (void)
       for (si = bsi_start (bb); !bsi_end_p (si); bsi_next (&si))
 	STMT_IN_SSA_EDGE_WORKLIST (bsi_stmt (si)) = 0;
 
-      for (e = bb->succ; e; e = e->succ_next)
+      FOR_EACH_EDGE (e, bb->succs)
 	e->flags &= ~EDGE_EXECUTABLE;
+      END_FOR_EACH_EDGE;
     }
 
   /* Seed the algorithm by adding the successors of the entry block to the
      edge worklist.  */
-  for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+  FOR_EACH_EDGE (e, ENTRY_BLOCK_PTR->succs)
     {
       if (e->dest != EXIT_BLOCK_PTR)
 	{
@@ -496,6 +499,7 @@ ssa_prop_init (void)
 	  cfg_blocks_add (e->dest);
 	}
     }
+  END_FOR_EACH_EDGE;
 }
 
 
Index: gcc/tree-ssa-threadupdate.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-threadupdate.c,v
retrieving revision 2.5
diff -u -p -w -r2.5 tree-ssa-threadupdate.c
--- gcc/tree-ssa-threadupdate.c	10 Sep 2004 10:44:47 -0000	2.5
+++ gcc/tree-ssa-threadupdate.c	13 Sep 2004 04:39:49 -0000
@@ -141,7 +141,8 @@ static void
 remove_last_stmt_and_useless_edges (basic_block bb, basic_block dest_bb)
 {
   block_stmt_iterator bsi;
-  edge e, next;
+  edge e;
+  unsigned ix;
 
   bsi = bsi_last (bb);
 
@@ -150,19 +151,18 @@ remove_last_stmt_and_useless_edges (basi
 
   bsi_remove (&bsi);
 
-  next = NULL;
-  for (e = bb->succ; e; e = next)
+  for (ix = 0; VEC_iterate (edge, bb->succs, ix, e); )
     {
-      next = e->succ_next;
-
       if (e->dest != dest_bb)
 	ssa_remove_edge (e);
+      else
+	ix++;
     }
 
   /* BB now has a single outgoing edge. We need to update the flags for
      that single outgoing edge.  */
-  bb->succ->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
-  bb->succ->flags |= EDGE_FALLTHRU;
+  EDGE_SUCC (bb, 0)->flags &= ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
+  EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
 }
 
 /* Create a duplicate of BB which only reaches the destination of the edge
@@ -187,11 +187,12 @@ create_block_for_threading (basic_block 
      from the duplicate block, then we will need to add a new argument
      to them.  The argument should have the same value as the argument
      associated with the outgoing edge stored in RD.  */
-  for (phi = phi_nodes (rd->dup_block->succ->dest); phi;
+  for (phi = phi_nodes (EDGE_SUCC (rd->dup_block, 0)->dest); phi;
        phi = PHI_CHAIN (phi))
     {
       int indx = phi_arg_from_edge (phi, rd->outgoing_edge);
-      add_phi_arg (&phi, PHI_ARG_DEF_TREE (phi, indx), rd->dup_block->succ);
+      add_phi_arg (&phi, PHI_ARG_DEF_TREE (phi, indx),
+		   EDGE_SUCC (rd->dup_block, 0));
     }
 }
 
@@ -231,22 +232,18 @@ thread_block (basic_block bb)
      redirect to a duplicate of BB.  */
   edge e;
 
-  /* The next edge in a predecessor list.  Used in loops where E->pred_next
-     may change within the loop.  */
-  edge next;
-
   /* ALL indicates whether or not all incoming edges into BB should
      be threaded to a duplicate of BB.  */
   bool all = true;
 
-  unsigned int i;
+  unsigned int i, ix;
 
   VARRAY_GENERIC_PTR_INIT (redirection_data, 2, "redirection data");
 
   /* Look at each incoming edge into BB.  Record each unique outgoing
      edge that we want to thread an incoming edge to.  Also note if
      all incoming edges are threaded or not.  */
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     {
       if (!e->aux)
 	{
@@ -282,6 +279,7 @@ thread_block (basic_block bb)
 	    }
 	}
     }
+  END_FOR_EACH_EDGE;
 
   /* Now create duplicates of BB.  Note that if all incoming edges are
      threaded, then BB is going to become unreachable.  In that case
@@ -304,16 +302,17 @@ thread_block (basic_block bb)
      If this turns out to be a performance problem, then we could create
      a list of incoming edges associated with each entry in 
      REDIRECTION_DATA and walk over that list of edges instead.  */
-  next = NULL;
-  for (e = bb->pred; e; e = next)
+
+  for (ix = 0; VEC_iterate (edge, bb->preds, ix, e); )
     {
       edge new_dest = e->aux;
 
-      next = e->pred_next;
-
       /* E was not threaded, then there is nothing to do.  */
       if (!new_dest)
+	{
+	  ix++;
 	continue;
+	}
 
       /* Go ahead and clear E->aux.  It's not needed anymore and failure
          to clear it will cause all kinds of unpleasant problems later.  */
@@ -365,7 +364,8 @@ thread_block (basic_block bb)
 
       if (dump_file && (dump_flags & TDF_DETAILS))
 	fprintf (dump_file, "  Threaded jump %d --> %d to %d\n",
-		 bb->pred->src->index, bb->index, bb->succ->dest->index);
+		 EDGE_PRED (bb, 0)->src->index, bb->index,
+		 EDGE_SUCC (bb, 0)->dest->index);
 
       remove_last_stmt_and_useless_edges (bb, rd->outgoing_edge->dest);
     }
Index: gcc/tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa.c,v
retrieving revision 2.35
diff -u -p -w -r2.35 tree-ssa.c
--- gcc/tree-ssa.c	11 Sep 2004 20:42:06 -0000	2.35
+++ gcc/tree-ssa.c	13 Sep 2004 04:39:50 -0000
@@ -269,8 +269,11 @@ verify_phi_args (tree phi, basic_block b
   int i, phi_num_args = PHI_NUM_ARGS (phi);
 
   /* Mark all the incoming edges.  */
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
+    {
     e->aux = (void *) 1;
+    }
+  END_FOR_EACH_EDGE;
 
   for (i = 0; i < phi_num_args; i++)
     {
@@ -314,7 +317,7 @@ verify_phi_args (tree phi, basic_block b
       e->aux = (void *) 2;
     }
 
-  for (e = bb->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, bb->preds)
     {
       if (e->aux != (void *) 2)
 	{
@@ -325,6 +328,7 @@ verify_phi_args (tree phi, basic_block b
 	}
       e->aux = (void *) 0;
     }
+  END_FOR_EACH_EDGE;
 
 error:
   if (err)
@@ -565,7 +569,7 @@ verify_ssa (void)
       block_stmt_iterator bsi;
 
       /* Make sure that all edges have a clear 'aux' field.  */
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
 	{
 	  if (e->aux)
 	    {
@@ -574,6 +578,7 @@ verify_ssa (void)
 	      goto err;
 	    }
 	}
+      END_FOR_EACH_EDGE;
 
       /* Verify the arguments for every PHI node in the block.  */
       for (phi = phi_nodes (bb); phi; phi = PHI_CHAIN (phi))
Index: gcc/tree-tailcall.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-tailcall.c,v
retrieving revision 2.26
diff -u -p -w -r2.26 tree-tailcall.c
--- gcc/tree-tailcall.c	10 Sep 2004 12:00:28 -0000	2.26
+++ gcc/tree-tailcall.c	13 Sep 2004 04:39:50 -0000
@@ -200,7 +200,7 @@ independent_of_stmt_p (tree expr, tree a
   /* Mark the blocks in the chain leading to the end.  */
   at_bb = bb_for_stmt (at);
   call_bb = bb_for_stmt (bsi_stmt (bsi));
-  for (bb = call_bb; bb != at_bb; bb = bb->succ->dest)
+  for (bb = call_bb; bb != at_bb; bb = EDGE_SUCC (bb, 0)->dest)
     bb->aux = &bb->aux;
   bb->aux = &bb->aux;
 
@@ -230,9 +230,13 @@ independent_of_stmt_p (tree expr, tree a
 	  break;
 	}
 
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	if (e->src->aux)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
+
       gcc_assert (e);
 
       expr = PHI_ARG_DEF_FROM_EDGE (at, e);
@@ -244,7 +248,7 @@ independent_of_stmt_p (tree expr, tree a
     }
 
   /* Unmark the blocks.  */
-  for (bb = call_bb; bb != at_bb; bb = bb->succ->dest)
+  for (bb = call_bb; bb != at_bb; bb = EDGE_SUCC (bb, 0)->dest)
     bb->aux = NULL;
   bb->aux = NULL;
 
@@ -371,7 +375,7 @@ find_tail_calls (basic_block bb, struct 
   basic_block abb;
   stmt_ann_t ann;
 
-  if (bb->succ->succ_next)
+  if (EDGE_COUNT (bb->succs) > 1)
     return;
 
   for (bsi = bsi_last (bb); !bsi_end_p (bsi); bsi_prev (&bsi))
@@ -413,9 +417,11 @@ find_tail_calls (basic_block bb, struct 
   if (bsi_end_p (bsi))
     {
       /* Recurse to the predecessors.  */
-      for (e = bb->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, bb->preds)
+	{
 	find_tail_calls (e->src, ret);
-
+	}
+      END_FOR_EACH_EDGE;
       return;
     }
 
@@ -458,8 +464,8 @@ find_tail_calls (basic_block bb, struct 
 
       while (bsi_end_p (absi))
 	{
-	  ass_var = propagate_through_phis (ass_var, abb->succ);
-	  abb = abb->succ->dest;
+	  ass_var = propagate_through_phis (ass_var, EDGE_SUCC (abb, 0));
+	  abb = EDGE_SUCC (abb, 0)->dest;
 	  absi = bsi_start (abb);
 	}
 
@@ -677,7 +683,7 @@ eliminate_tail_call (struct tailcall *t)
   if (TREE_CODE (stmt) == MODIFY_EXPR)
     stmt = TREE_OPERAND (stmt, 1);
 
-  first = ENTRY_BLOCK_PTR->succ->dest;
+  first = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest;
 
   /* Remove the code after call_bsi that will become unreachable.  The
      possibly unreachable code in other blocks is removed later in
@@ -695,7 +701,7 @@ eliminate_tail_call (struct tailcall *t)
     }
 
   /* Replace the call by a jump to the start of function.  */
-  e = redirect_edge_and_branch (t->call_block->succ, first);
+  e = redirect_edge_and_branch (EDGE_SUCC (t->call_block, 0), first);
   gcc_assert (e);
   PENDING_STMT (e) = NULL_TREE;
 
@@ -750,12 +756,12 @@ eliminate_tail_call (struct tailcall *t)
 	  var_ann (param)->default_def = new_name;
 	  phi = create_phi_node (name, first);
 	  SSA_NAME_DEF_STMT (name) = phi;
-	  add_phi_arg (&phi, new_name, ENTRY_BLOCK_PTR->succ);
+	  add_phi_arg (&phi, new_name, EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
 
 	  /* For all calls the same set of variables should be clobbered.  This
 	     means that there always should be the appropriate phi node except
 	     for the first time we eliminate the call.  */
-	  gcc_assert (!first->pred->pred_next->pred_next);
+	  gcc_assert (EDGE_COUNT (first->preds) <= 2);
 	}
 
       add_phi_arg (&phi, V_MAY_DEF_OP (v_may_defs, i), e);
@@ -816,7 +822,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
   bool phis_constructed = false;
   struct tailcall *tailcalls = NULL, *act, *next;
   bool changed = false;
-  basic_block first = ENTRY_BLOCK_PTR->succ->dest;
+  basic_block first = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest;
   tree stmt, param, ret_type, tmp, phi;
 
   if (!suitable_for_tail_opt_p ())
@@ -824,7 +830,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
   if (opt_tailcalls)
     opt_tailcalls = suitable_for_tail_call_opt_p ();
 
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
     {
       /* Only traverse the normal exits, i.e. those that end with return
 	 statement.  */
@@ -834,6 +840,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
 	  && TREE_CODE (stmt) == RETURN_EXPR)
 	find_tail_calls (e->src, &tailcalls);
     }
+  END_FOR_EACH_EDGE;
 
   /* Construct the phi nodes and accumulators if necessary.  */
   a_acc = m_acc = NULL_TREE;
@@ -845,8 +852,8 @@ tree_optimize_tail_calls_1 (bool opt_tai
       if (!phis_constructed)
 	{
 	  /* Ensure that there is only one predecessor of the block.  */
-	  if (first->pred->pred_next)
-	    first = split_edge (ENTRY_BLOCK_PTR->succ);
+	  if (EDGE_COUNT (first->preds) > 1)
+	    first = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
 
 	  /* Copy the args if needed.  */
 	  for (param = DECL_ARGUMENTS (current_function_decl);
@@ -865,7 +872,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
 	      var_ann (param)->default_def = new_name;
 	      phi = create_phi_node (name, first);
 	      SSA_NAME_DEF_STMT (name) = phi;
-	      add_phi_arg (&phi, new_name, first->pred);
+	      add_phi_arg (&phi, new_name, EDGE_PRED (first, 0));
 	    }
 	  phis_constructed = true;
 	}
@@ -878,7 +885,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
 	  add_referenced_tmp_var (tmp);
 
 	  phi = create_phi_node (tmp, first);
-	  add_phi_arg (&phi, build_int_cst (ret_type, 0), first->pred);
+	  add_phi_arg (&phi, build_int_cst (ret_type, 0), EDGE_PRED (first, 0));
 	  a_acc = PHI_RESULT (phi);
 	}
 
@@ -890,7 +897,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
 	  add_referenced_tmp_var (tmp);
 
 	  phi = create_phi_node (tmp, first);
-	  add_phi_arg (&phi, build_int_cst (ret_type, 1), first->pred);
+	  add_phi_arg (&phi, build_int_cst (ret_type, 1), EDGE_PRED (first, 0));
 	  m_acc = PHI_RESULT (phi);
 	}
     }
@@ -905,7 +912,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
   if (a_acc || m_acc)
     {
       /* Modify the remaining return statements.  */
-      for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+      FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
 	{
 	  stmt = last_stmt (e->src);
 
@@ -913,6 +920,7 @@ tree_optimize_tail_calls_1 (bool opt_tai
 	      && TREE_CODE (stmt) == RETURN_EXPR)
 	    adjust_return_value (e->src, m_acc, a_acc);
 	}
+      END_FOR_EACH_EDGE;
     }
 
   if (changed)
Index: gcc/tree-vectorizer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vectorizer.c,v
retrieving revision 2.8
diff -u -p -w -r2.8 tree-vectorizer.c
--- gcc/tree-vectorizer.c	10 Sep 2004 10:44:47 -0000	2.8
+++ gcc/tree-vectorizer.c	13 Sep 2004 04:39:51 -0000
@@ -1445,8 +1445,7 @@ vect_transform_loop (loop_vec_info loop_
   /* 1) Make sure the loop header has exactly two entries
      2) Make sure we have a preheader basic block.  */
 
-  gcc_assert (loop->header->pred->pred_next);
-  gcc_assert (!loop->header->pred->pred_next->pred_next);
+  gcc_assert (EDGE_COUNT (loop->header->preds) == 2);
 
   loop_split_edge_with (loop_preheader_edge (loop), NULL);
 
Index: gcc/var-tracking.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/var-tracking.c,v
retrieving revision 2.21
diff -u -p -w -r2.21 var-tracking.c
--- gcc/var-tracking.c	21 Jul 2004 17:03:47 -0000	2.21
+++ gcc/var-tracking.c	13 Sep 2004 04:39:52 -0000
@@ -526,30 +526,33 @@ prologue_stack_adjust (void)
 static bool
 vt_stack_adjustments (void)
 {
-  edge *stack;
+  struct edge_stack *stack;
   int sp;
+  unsigned ix;
 
   /* Initialize entry block.  */
   VTI (ENTRY_BLOCK_PTR)->visited = true;
   VTI (ENTRY_BLOCK_PTR)->out.stack_adjust = frame_stack_adjust;
 
   /* Allocate stack for back-tracking up CFG.  */
-  stack = xmalloc ((n_basic_blocks + 1) * sizeof (edge));
+  stack = xmalloc ((n_basic_blocks + 1) * sizeof (struct edge_stack));
   sp = 0;
 
   /* Push the first edge on to the stack.  */
-  stack[sp++] = ENTRY_BLOCK_PTR->succ;
+  stack[sp].ev = ENTRY_BLOCK_PTR->succs;
+  stack[sp++].ix = 0;
 
   while (sp)
     {
-      edge e;
+      VEC(edge) *ev;
       basic_block src;
       basic_block dest;
 
       /* Look at the edge on the top of the stack.  */
-      e = stack[sp - 1];
-      src = e->src;
-      dest = e->dest;
+      ev = stack[sp - 1].ev;
+      ix = stack[sp - 1].ix;
+      src = EDGE_I (ev, ix)->src;
+      dest = EDGE_I (ev, ix)->dest;
 
       /* Check if the edge destination has been visited yet.  */
       if (!VTI (dest)->visited)
@@ -558,10 +561,13 @@ vt_stack_adjustments (void)
 	  VTI (dest)->in.stack_adjust = VTI (src)->out.stack_adjust;
 	  bb_stack_adjust_offset (dest);
 
-	  if (dest->succ)
+	  if (EDGE_COUNT (dest->succs) > 0)
+	    {
 	    /* Since the DEST node has been visited for the first
 	       time, check its successors.  */
-	    stack[sp++] = dest->succ;
+	      stack[sp].ev = dest->succs;
+	      stack[sp++].ix = 0;
+	    }
 	}
       else
 	{
@@ -572,9 +578,9 @@ vt_stack_adjustments (void)
 	      return false;
 	    }
 
-	  if (e->succ_next)
+	  if (EDGE_COUNT (ev) > (ix + 1))
 	    /* Go to the next edge.  */
-	    stack[sp - 1] = e->succ_next;
+	    stack[sp - 1].ix++;
 	  else
 	    /* Return to previous level if there are no more edges.  */
 	    sp--;
@@ -1728,15 +1734,16 @@ vt_find_locations (void)
 
 	      /* Calculate the IN set as union of predecessor OUT sets.  */
 	      dataflow_set_clear (&VTI (bb)->in);
-	      for (e = bb->pred; e; e = e->pred_next)
+	      FOR_EACH_EDGE (e, bb->preds)
 		{
 		  dataflow_set_union (&VTI (bb)->in, &VTI (e->src)->out);
 		}
+	      END_FOR_EACH_EDGE;
 
 	      changed = compute_bb_dataflow (bb);
 	      if (changed)
 		{
-		  for (e = bb->succ; e; e = e->succ_next)
+		  FOR_EACH_EDGE (e, bb->succs)
 		    {
 		      if (e->dest == EXIT_BLOCK_PTR)
 			continue;
@@ -1763,6 +1770,7 @@ vt_find_locations (void)
 					  e->dest);
 			}
 		    }
+		  END_FOR_EACH_EDGE;
 		}
 	    }
 	}
Index: gcc/config/frv/frv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.c,v
retrieving revision 1.69
diff -u -p -w -r1.69 frv.c
--- gcc/config/frv/frv.c	10 Sep 2004 11:55:13 -0000	1.69
+++ gcc/config/frv/frv.c	13 Sep 2004 04:39:56 -0000
@@ -6715,7 +6715,7 @@ frv_ifcvt_modify_tests (ce_if_block_t *c
       while (multiple_test_bb != test_bb)
 	{
 	  bb[num_bb++] = multiple_test_bb;
-	  multiple_test_bb = multiple_test_bb->pred->src;
+	  multiple_test_bb = EDGE_PRED (multiple_test_bb, 0)->src;
 	}
     }
 
Index: gcc/config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.726
diff -u -p -w -r1.726 i386.c
--- gcc/config/i386/i386.c	12 Sep 2004 23:31:29 -0000	1.726
+++ gcc/config/i386/i386.c	13 Sep 2004 04:40:03 -0000
@@ -14879,7 +14879,7 @@ ix86_pad_returns (void)
 {
   edge e;
 
-  for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+  FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
   {
     basic_block bb = e->src;
     rtx ret = BB_END (bb);
@@ -14895,11 +14895,15 @@ ix86_pad_returns (void)
     if (prev && GET_CODE (prev) == CODE_LABEL)
       {
 	edge e;
-	for (e = bb->pred; e; e = e->pred_next)
+
+	  FOR_EACH_EDGE (e, bb->preds)
+	    {
 	  if (EDGE_FREQUENCY (e) && e->src->index >= 0
 	      && !(e->flags & EDGE_FALLTHRU))
 	    replace = true;
       }
+	  END_FOR_EACH_EDGE;
+	}
     if (!replace)
       {
 	prev = prev_active_insn (ret);
@@ -14918,6 +14922,7 @@ ix86_pad_returns (void)
 	delete_insn (ret);
       }
   }
+  END_FOR_EACH_EDGE;
 }
 
 /* Implement machine specific optimizations.  We implement padding of returns
Index: gcc/config/ia64/ia64.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/ia64/ia64.c,v
retrieving revision 1.322
diff -u -p -w -r1.322 ia64.c
--- gcc/config/ia64/ia64.c	9 Sep 2004 16:33:25 -0000	1.322
+++ gcc/config/ia64/ia64.c	13 Sep 2004 04:40:05 -0000
@@ -2030,10 +2030,13 @@ ia64_expand_prologue (void)
     {
       edge e;
 
-      for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next)
+      FOR_EACH_EDGE (e, EXIT_BLOCK_PTR->preds)
+	{
 	if ((e->flags & EDGE_FAKE) == 0
 	    && (e->flags & EDGE_FALLTHRU) != 0)
 	  break;
+	}
+      END_FOR_EACH_EDGE;
       epilogue_p = (e != NULL);
     }
   else
Index: gcc/config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.708
diff -u -p -w -r1.708 rs6000.c
--- gcc/config/rs6000/rs6000.c	10 Sep 2004 18:56:10 -0000	1.708
+++ gcc/config/rs6000/rs6000.c	13 Sep 2004 04:40:11 -0000
@@ -13445,7 +13445,7 @@ rs6000_emit_prologue (void)
 				    && DEFAULT_ABI != ABI_AIX
 				    && flag_pic
 				    && ! info->lr_save_p
-				    && EXIT_BLOCK_PTR->pred != NULL);
+				    && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0);
     if (save_LR_around_toc_setup)
       {
 	rtx lr = gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]