From: Trevor Saunders <tbsaunde+...@tbsaunde.org> gcc/ChangeLog:
2016-04-19 Trevor Saunders <tbsaunde+...@tbsaunde.org> * store-motion.c (struct st_expr): Make antic_stores a vector. (st_expr_entry): Adjust. (free_st_expr_entry): Likewise. (print_store_motion_mems): Likewise. (find_moveable_store): Likewise. (compute_store_table): Likewise. (remove_reachable_equiv_notes): Likewise. (replace_store_insn): Likewise. (build_store_vectors): Likewise. --- gcc/store-motion.c | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/gcc/store-motion.c b/gcc/store-motion.c index 6646065..a349180 100644 --- a/gcc/store-motion.c +++ b/gcc/store-motion.c @@ -45,7 +45,6 @@ along with GCC; see the file COPYING3. If not see a compile time hog that needs a rewrite (maybe cache st_exprs to invalidate REG_EQUAL/REG_EQUIV notes for?). - pattern_regs in st_expr should be a regset (on its own obstack). - - antic_stores and avail_stores should be VECs instead of lists. - store_motion_mems should be a vec instead of a list. - there should be an alloc pool for struct st_expr objects. - investigate whether it is helpful to make the address of an st_expr @@ -65,7 +64,7 @@ struct st_expr /* List of registers mentioned by the mem. */ rtx pattern_regs; /* INSN list of stores that are locally anticipatable. */ - rtx_insn_list *antic_stores; + vec<rtx_insn *> antic_stores; /* INSN list of stores that are locally available. */ vec<rtx_insn *> avail_stores; /* Next in the list. */ @@ -147,7 +146,7 @@ st_expr_entry (rtx x) ptr->next = store_motion_mems; ptr->pattern = x; ptr->pattern_regs = NULL_RTX; - ptr->antic_stores = NULL; + ptr->antic_stores.create (0); ptr->avail_stores.create (0); ptr->reaching_reg = NULL_RTX; ptr->index = 0; @@ -163,7 +162,7 @@ st_expr_entry (rtx x) static void free_st_expr_entry (struct st_expr * ptr) { - free_INSN_LIST_list (& ptr->antic_stores); + ptr->antic_stores.release (); ptr->avail_stores.release (); free (ptr); @@ -232,11 +231,7 @@ print_store_motion_mems (FILE * file) print_rtl (file, ptr->pattern); fprintf (file, "\n ANTIC stores : "); - - if (ptr->antic_stores) - print_rtl (file, ptr->antic_stores); - else - fprintf (file, "(nil)"); + print_rtx_insn_vec (file, ptr->antic_stores); fprintf (file, "\n AVAIL stores : "); @@ -565,11 +560,11 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after) /* Do not check for anticipatability if we either found one anticipatable store already, or tested for one and found out that it was killed. */ check_anticipatable = 0; - if (!ptr->antic_stores) + if (ptr->antic_stores.is_empty ()) check_anticipatable = 1; else { - rtx_insn *tmp = ptr->antic_stores->insn (); + rtx_insn *tmp = ptr->antic_stores.last (); if (tmp != NULL_RTX && BLOCK_FOR_INSN (tmp) != bb) check_anticipatable = 1; @@ -581,7 +576,7 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after) tmp = NULL; else tmp = insn; - ptr->antic_stores = alloc_INSN_LIST (tmp, ptr->antic_stores); + ptr->antic_stores.safe_push (tmp); } /* It is not necessary to check whether store is available if we did @@ -682,9 +677,9 @@ compute_store_table (void) for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr)) { LAST_AVAIL_CHECK_FAILURE (ptr) = NULL_RTX; - if (ptr->antic_stores - && (tmp = ptr->antic_stores->insn ()) == NULL_RTX) - ptr->antic_stores = ptr->antic_stores->next (); + if (!ptr->antic_stores.is_empty () + && (tmp = ptr->antic_stores.last ()) == NULL) + ptr->antic_stores.pop (); } } @@ -830,7 +825,7 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr) int sp; edge act; sbitmap visited = sbitmap_alloc (last_basic_block_for_fn (cfun)); - rtx last, note; + rtx note; rtx_insn *insn; rtx mem = smexpr->pattern; @@ -865,13 +860,13 @@ remove_reachable_equiv_notes (basic_block bb, struct st_expr *smexpr) } bitmap_set_bit (visited, bb->index); + rtx_insn *last; if (bitmap_bit_p (st_antloc[bb->index], smexpr->index)) { - for (last = smexpr->antic_stores; - BLOCK_FOR_INSN (XEXP (last, 0)) != bb; - last = XEXP (last, 1)) - continue; - last = XEXP (last, 0); + unsigned int i; + FOR_EACH_VEC_ELT_REVERSE (smexpr->antic_stores, i, last) + if (BLOCK_FOR_INSN (last) == bb) + break; } else last = NEXT_INSN (BB_END (bb)); @@ -910,15 +905,17 @@ replace_store_insn (rtx reg, rtx_insn *del, basic_block bb, struct st_expr *smexpr) { rtx_insn *insn; - rtx mem, note, set, ptr; + rtx mem, note, set; mem = smexpr->pattern; insn = gen_move_insn (reg, SET_SRC (single_set (del))); - for (ptr = smexpr->antic_stores; ptr; ptr = XEXP (ptr, 1)) - if (XEXP (ptr, 0) == del) + unsigned int i; + rtx_insn *temp; + FOR_EACH_VEC_ELT_REVERSE (smexpr->antic_stores, i, temp) + if (temp == del) { - XEXP (ptr, 0) = insn; + smexpr->antic_stores[i] = insn; break; } @@ -1000,7 +997,6 @@ build_store_vectors (void) basic_block bb; int *regs_set_in_block; rtx_insn *insn; - rtx_insn_list *st; struct st_expr * ptr; unsigned int max_gcse_regno = max_reg_num (); @@ -1037,9 +1033,9 @@ build_store_vectors (void) bitmap_set_bit (st_avloc[bb->index], ptr->index); } - for (st = ptr->antic_stores; st != NULL; st = st->next ()) + unsigned int i; + FOR_EACH_VEC_ELT_REVERSE (ptr->antic_stores, i, insn) { - insn = st->insn (); bb = BLOCK_FOR_INSN (insn); bitmap_set_bit (st_antloc[bb->index], ptr->index); } -- 2.7.4