From: Trevor Saunders <tbsaunde+...@tbsaunde.org> gcc/ChangeLog:
2016-04-19 Trevor Saunders <tbsaunde+...@tbsaunde.org> * loop-iv.c (simplify_using_initial_values): Make cond_list a vector. --- gcc/loop-iv.c | 55 ++++++++++++++++++------------------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index fecaf8f..7f000c7 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -1860,7 +1860,6 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) { bool expression_valid; rtx head, tail, last_valid_expr; - rtx_expr_list *cond_list; rtx_insn *insn; rtx neutral, aggr; regset altered, this_altered; @@ -1936,7 +1935,7 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) expression_valid = true; last_valid_expr = *expr; - cond_list = NULL; + auto_vec<rtx> cond_list; while (1) { insn = BB_END (e->src); @@ -1952,17 +1951,18 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) simplify_using_condition (cond, expr, altered); if (old != *expr) { - rtx note; if (CONSTANT_P (*expr)) goto out; - for (note = cond_list; note; note = XEXP (note, 1)) + + unsigned int len = cond_list.length (); + for (unsigned int i = len - 1; i < len; i--) { - simplify_using_condition (XEXP (note, 0), expr, altered); + simplify_using_condition (cond_list[i], expr, altered); if (CONSTANT_P (*expr)) goto out; } } - cond_list = alloc_EXPR_LIST (0, cond, cond_list); + cond_list.safe_push (cond); } } @@ -1988,39 +1988,30 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) if (suitable_set_for_replacement (insn, &dest, &src)) { - rtx_expr_list **pnote, **pnote_next; - replace_in_expr (expr, dest, src); if (CONSTANT_P (*expr)) goto out; - for (pnote = &cond_list; *pnote; pnote = pnote_next) + unsigned int len = cond_list.length (); + for (unsigned int i = len - 1; i < len; i--) { - rtx_expr_list *note = *pnote; - rtx old_cond = XEXP (note, 0); + rtx old_cond = cond_list[i]; - pnote_next = (rtx_expr_list **)&XEXP (note, 1); - replace_in_expr (&XEXP (note, 0), dest, src); + replace_in_expr (&cond_list[i], dest, src); /* We can no longer use a condition that has been simplified to a constant, and simplify_using_condition will abort if we try. */ - if (CONSTANT_P (XEXP (note, 0))) - { - *pnote = *pnote_next; - pnote_next = pnote; - free_EXPR_LIST_node (note); - } + if (CONSTANT_P (cond_list[i])) + cond_list.ordered_remove (i); /* Retry simplifications with this condition if either the expression or the condition changed. */ - else if (old_cond != XEXP (note, 0) || old != *expr) - simplify_using_condition (XEXP (note, 0), expr, altered); + else if (old_cond != cond_list[i] || old != *expr) + simplify_using_condition (cond_list[i], expr, altered); } } else { - rtx_expr_list **pnote, **pnote_next; - /* If we did not use this insn to make a replacement, any overlap between stores in this insn and our expression will cause the expression to become invalid. */ @@ -2028,19 +2019,10 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) goto out; /* Likewise for the conditions. */ - for (pnote = &cond_list; *pnote; pnote = pnote_next) - { - rtx_expr_list *note = *pnote; - rtx old_cond = XEXP (note, 0); - - pnote_next = (rtx_expr_list **)&XEXP (note, 1); - if (altered_reg_used (old_cond, this_altered)) - { - *pnote = *pnote_next; - pnote_next = pnote; - free_EXPR_LIST_node (note); - } - } + unsigned int len = cond_list.length (); + for (unsigned int i = len - 1; i < len; i--) + if (altered_reg_used (cond_list[i], this_altered)) + cond_list.ordered_remove (i); } if (CONSTANT_P (*expr)) @@ -2065,7 +2047,6 @@ simplify_using_initial_values (struct loop *loop, enum rtx_code op, rtx *expr) } out: - free_EXPR_LIST_list (&cond_list); if (!CONSTANT_P (*expr)) *expr = last_valid_expr; FREE_REG_SET (altered); -- 2.7.4