Hi, this removes the XXXs I added with my prev/next shuffling. A reason for some conditionals in iterator setups is that ENTRY/EXIT bbs don't have il.gimple setup, while all other blocks have it always initialized (well, as long as !BB_RTL of course). That annoyed me, but instead of simply also allocating il.gimple for ENTRY/EXIT I folded gimple_bb_info directly into basic_block_def. The latter is only two pointers, so wasting a pointer just to point to them seems useless especially considering that we hold very many BBs in !BB_RTL state (all of them, except for the very few just being converted into RTL, one function at a time).
So, RTL BBs will be one word larger than before, while gimple BBs will be overall one word smaller, save an indirection and save several condionals in our low-level accessors. This patch also folds in the trivial removal of const_gimple_seq that Richi asked me for. Regstrapped on x86_64-linux, all langs, no regressions. Okay for trunk? Ciao, Michael. ---------------- 2012-05-02 Michael Matz <m...@suse.de> * basic-block.h (struct rtl_bb_info, struct gimple_bb_info): Move in front of basic_block_def. (struct basic_block_def): Make il.gimple the full struct, not a pointer. (__assert_gimple_bb_smaller_rtl_bb): Asserting typedef. * cfgexpand.c (expand_gimple_basic_block): Clear all il.gimple members. * gimple-iterator.c (gimple_stmt_iterator): Don't special case NULL il.gimple, which can't happen anymore. * gimple.h (bb_seq): il.gimple can't be NULL. (bb_seq_add): Ditto. (set_bb_seq): Adjust. (gsi_start_bb, gsi_last_bb): Tidy. * lto-streamer-in.c (make_new_block): Don't zero members that are zeroed already, don't allocate a gimple_bb_info. * tree-cfg.c (create_bb): Don't allocate a gimple_bb_info. (remove_bb): Clear all il.gimple members. (gimple_verify_flow_info): Adjust for flat il.gimple. * tree-flow-inline.h (phi_nodes, phi_nodes_ptr, set_phi_nodes): Adjust. * coretypes.h (const_gimple_seq): Remove typedef. * gimple.h (gimple_seq_first): Take gimple_seq. (gimple_seq_first_stmt): Ditto. (gimple_seq_last): Ditto. (gimple_seq_last_stmt): Ditto. (gimple_seq_empty_p): Ditto. Index: basic-block.h =================================================================== --- basic-block.h.orig 2012-04-19 14:54:41.000000000 +0200 +++ basic-block.h 2012-05-02 21:28:27.000000000 +0200 @@ -101,8 +101,27 @@ extern const struct gcov_ctr_summary *pr /* Declared in cfgloop.h. */ struct loop; -/* Declared in tree-flow.h. */ -struct rtl_bb_info; +struct GTY(()) rtl_bb_info { + /* The first and last insns of the block. */ + rtx head_; + rtx end_; + + /* In CFGlayout mode points to insn notes/jumptables to be placed just before + and after the block. */ + rtx header; + rtx footer; + + /* This field is used by the bb-reorder and tracer passes. */ + int visited; +}; + +struct GTY(()) gimple_bb_info { + /* Sequence of statements in this block. */ + gimple_seq seq; + + /* PHI nodes for this block. */ + gimple_seq phi_nodes; +}; /* A basic block is a sequence of instructions with only entry and only one exit. If any one of the instructions are executed, they @@ -149,7 +168,7 @@ struct GTY((chain_next ("%h.next_bb"), c struct basic_block_def *next_bb; union basic_block_il_dependent { - struct gimple_bb_info * GTY ((tag ("0"))) gimple; + struct gimple_bb_info GTY ((tag ("0"))) gimple; struct rtl_bb_info * GTY ((tag ("1"))) rtl; } GTY ((desc ("((%1.flags & BB_RTL) != 0)"))) il; @@ -172,27 +191,12 @@ struct GTY((chain_next ("%h.next_bb"), c int flags; }; -struct GTY(()) rtl_bb_info { - /* The first and last insns of the block. */ - rtx head_; - rtx end_; - - /* In CFGlayout mode points to insn notes/jumptables to be placed just before - and after the block. */ - rtx header; - rtx footer; - - /* This field is used by the bb-reorder and tracer passes. */ - int visited; -}; - -struct GTY(()) gimple_bb_info { - /* Sequence of statements in this block. */ - gimple_seq seq; - - /* PHI nodes for this block. */ - gimple_seq phi_nodes; -}; +/* This ensures that struct gimple_bb_info is smaller than + struct rtl_bb_info, so that inlining the former into basic_block_def + is the better choice. */ +typedef int __assert_gimple_bb_smaller_rtl_bb + [(int)sizeof(struct rtl_bb_info) + - (int)sizeof (struct gimple_bb_info)]; DEF_VEC_P(basic_block); DEF_VEC_ALLOC_P(basic_block,gc); Index: cfgexpand.c =================================================================== --- cfgexpand.c.orig 2012-05-02 18:21:44.000000000 +0200 +++ cfgexpand.c 2012-05-02 21:11:21.000000000 +0200 @@ -3730,7 +3730,8 @@ expand_gimple_basic_block (basic_block b block to be in GIMPLE, instead of RTL. Therefore, we need to access the BB sequence directly. */ stmts = bb_seq (bb); - bb->il.gimple = NULL; + bb->il.gimple.seq = NULL; + bb->il.gimple.phi_nodes = NULL; rtl_profile_for_bb (bb); init_rtl_bb_info (bb); bb->flags |= BB_RTL; Index: gimple-iterator.c =================================================================== --- gimple-iterator.c.orig 2012-05-02 18:31:37.000000000 +0200 +++ gimple-iterator.c 2012-05-02 21:11:21.000000000 +0200 @@ -865,6 +865,5 @@ gimple_stmt_iterator gsi_start_phis (basic_block bb) { gimple_seq *pseq = phi_nodes_ptr (bb); - /* XXX check only necessary because ENTRY/EXIT blocks don't have il.gimple */ - return pseq ? gsi_start_1 (pseq) : gsi_none (); + return gsi_start_1 (pseq); } Index: gimple.h =================================================================== --- gimple.h.orig 2012-05-02 18:31:37.000000000 +0200 +++ gimple.h 2012-05-02 21:37:15.000000000 +0200 @@ -1023,7 +1023,7 @@ extern bool types_compatible_p (tree, tr /* Return the first node in GIMPLE sequence S. */ static inline gimple_seq_node -gimple_seq_first (const_gimple_seq s) +gimple_seq_first (gimple_seq s) { return s; } @@ -1032,7 +1032,7 @@ gimple_seq_first (const_gimple_seq s) /* Return the first statement in GIMPLE sequence S. */ static inline gimple -gimple_seq_first_stmt (const_gimple_seq s) +gimple_seq_first_stmt (gimple_seq s) { gimple_seq_node n = gimple_seq_first (s); return n; @@ -1042,7 +1042,7 @@ gimple_seq_first_stmt (const_gimple_seq /* Return the last node in GIMPLE sequence S. */ static inline gimple_seq_node -gimple_seq_last (const_gimple_seq s) +gimple_seq_last (gimple_seq s) { return s ? s->gsbase.prev : NULL; } @@ -1051,7 +1051,7 @@ gimple_seq_last (const_gimple_seq s) /* Return the last statement in GIMPLE sequence S. */ static inline gimple -gimple_seq_last_stmt (const_gimple_seq s) +gimple_seq_last_stmt (gimple_seq s) { gimple_seq_node n = gimple_seq_last (s); return n; @@ -1079,7 +1079,7 @@ gimple_seq_set_first (gimple_seq *ps, gi /* Return true if GIMPLE sequence S is empty. */ static inline bool -gimple_seq_empty_p (const_gimple_seq s) +gimple_seq_empty_p (gimple_seq s) { return s == NULL; } @@ -1110,13 +1110,13 @@ gimple_seq_alloc_with_stmt (gimple stmt) static inline gimple_seq bb_seq (const_basic_block bb) { - return (!(bb->flags & BB_RTL) && bb->il.gimple) ? bb->il.gimple->seq : NULL; + return (!(bb->flags & BB_RTL)) ? bb->il.gimple.seq : NULL; } static inline gimple_seq * -bb_seq_addr (const_basic_block bb) +bb_seq_addr (basic_block bb) { - return (!(bb->flags & BB_RTL) && bb->il.gimple) ? &bb->il.gimple->seq : NULL; + return (!(bb->flags & BB_RTL)) ? &bb->il.gimple.seq : NULL; } /* Sets the sequence of statements in BB to SEQ. */ @@ -1125,7 +1125,7 @@ static inline void set_bb_seq (basic_block bb, gimple_seq seq) { gcc_checking_assert (!(bb->flags & BB_RTL)); - bb->il.gimple->seq = seq; + bb->il.gimple.seq = seq; } @@ -4975,20 +4975,9 @@ gsi_start_bb (basic_block bb) gimple_seq *seq; seq = bb_seq_addr (bb); - if (!seq) - /* XXX Only necessary because of ENTRY/EXIT block which don't have - il.gimple */ - { - i.ptr = NULL; - i.seq = NULL; - i.bb = NULL; - } - else - { - i.ptr = gimple_seq_first (*seq); - i.seq = seq; - i.bb = bb; - } + i.ptr = gimple_seq_first (*seq); + i.seq = seq; + i.bb = bb; return i; } @@ -5019,20 +5008,9 @@ gsi_last_bb (basic_block bb) gimple_seq *seq; seq = bb_seq_addr (bb); - if (!seq) - /* XXX Only necessary because of ENTRY/EXIT block which don't have - il.gimple */ - { - i.ptr = NULL; - i.seq = NULL; - i.bb = NULL; - } - else - { - i.ptr = gimple_seq_last (*seq); - i.seq = seq; - i.bb = bb; - } + i.ptr = gimple_seq_last (*seq); + i.seq = seq; + i.bb = bb; return i; } Index: lto-streamer-in.c =================================================================== --- lto-streamer-in.c.orig 2012-05-02 18:31:32.000000000 +0200 +++ lto-streamer-in.c 2012-05-02 21:11:21.000000000 +0200 @@ -599,10 +599,7 @@ make_new_block (struct function *fn, uns basic_block bb = alloc_block (); bb->index = index; SET_BASIC_BLOCK_FOR_FUNCTION (fn, index, bb); - bb->il.gimple = ggc_alloc_cleared_gimple_bb_info (); n_basic_blocks_for_function (fn)++; - bb->flags = 0; - set_bb_seq (bb, NULL); return bb; } Index: tree-cfg.c =================================================================== --- tree-cfg.c.orig 2012-05-02 18:31:32.000000000 +0200 +++ tree-cfg.c 2012-05-02 21:11:21.000000000 +0200 @@ -438,7 +438,6 @@ create_bb (void *h, void *e, basic_block bb->index = last_basic_block; bb->flags = BB_NEW; - bb->il.gimple = ggc_alloc_cleared_gimple_bb_info (); set_bb_seq (bb, h ? (gimple_seq) h : NULL); /* Add the new block to the linked list of blocks. */ @@ -1918,7 +1917,8 @@ remove_bb (basic_block bb) } remove_phi_nodes_and_edges_for_unreachable_block (bb); - bb->il.gimple = NULL; + bb->il.gimple.seq = NULL; + bb->il.gimple.phi_nodes = NULL; } @@ -4614,13 +4614,13 @@ gimple_verify_flow_info (void) edge e; edge_iterator ei; - if (ENTRY_BLOCK_PTR->il.gimple) + if (ENTRY_BLOCK_PTR->il.gimple.seq || ENTRY_BLOCK_PTR->il.gimple.phi_nodes) { error ("ENTRY_BLOCK has IL associated with it"); err = 1; } - if (EXIT_BLOCK_PTR->il.gimple) + if (EXIT_BLOCK_PTR->il.gimple.seq || EXIT_BLOCK_PTR->il.gimple.phi_nodes) { error ("EXIT_BLOCK has IL associated with it"); err = 1; Index: tree-flow-inline.h =================================================================== --- tree-flow-inline.h.orig 2012-05-02 18:31:32.000000000 +0200 +++ tree-flow-inline.h 2012-05-02 21:11:21.000000000 +0200 @@ -506,18 +506,14 @@ static inline gimple_seq phi_nodes (const_basic_block bb) { gcc_checking_assert (!(bb->flags & BB_RTL)); - if (!bb->il.gimple) - return NULL; - return bb->il.gimple->phi_nodes; + return bb->il.gimple.phi_nodes; } static inline gimple_seq * -phi_nodes_ptr (const_basic_block bb) +phi_nodes_ptr (basic_block bb) { gcc_checking_assert (!(bb->flags & BB_RTL)); - if (!bb->il.gimple) - return NULL; - return &bb->il.gimple->phi_nodes; + return &bb->il.gimple.phi_nodes; } /* Set PHI nodes of a basic block BB to SEQ. */ @@ -528,7 +524,7 @@ set_phi_nodes (basic_block bb, gimple_se gimple_stmt_iterator i; gcc_checking_assert (!(bb->flags & BB_RTL)); - bb->il.gimple->phi_nodes = seq; + bb->il.gimple.phi_nodes = seq; if (seq) for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i)) gimple_set_bb (gsi_stmt (i), bb); Index: coretypes.h =================================================================== --- coretypes.h.orig 2012-05-02 18:31:37.000000000 +0200 +++ coretypes.h 2012-05-02 21:36:58.000000000 +0200 @@ -73,7 +73,6 @@ struct cl_option_handlers; struct diagnostic_context; typedef struct diagnostic_context diagnostic_context; typedef gimple gimple_seq; -typedef gimple const_gimple_seq; /* Address space number for named address space support. */ typedef unsigned char addr_space_t;