From fab27f52895115e2986e7bc6a3c376411f847df7 Mon Sep 17 00:00:00 2001 From: Mikhail Maltsev Date: Tue, 19 May 2015 04:24:31 +0000 Subject: [PATCH] Use std::swap instead of explicit swaps gcc/ * bb-reorder.c (fix_up_fall_thru_edges): Use std::swap instead of explicit swaps. * dojump.c (do_compare_rtx_and_jump): Likewise. * expmed.c (emit_store_flag_1): Likewise. * fibonacci_heap.h (fibonacci_heap::union_with): Likewise. * final.c (sprint_ul): Use std::reverse for reversing a string. * fold-const.c (extract_muldiv_1): Use std::swap. * genmodes.c (emit_mode_int_n): Likewise. * ifcvt.c (dead_or_predicable): Likewise. * ira-build.c (ira_merge_live_ranges): Likewise. (swap_allocno_copy_ends_if_necessary): Likewise. * ira.c (ira_setup_alts): Likewise. * loop-iv.c (iv_analyze_expr): Likewise. (implies_p): Likewise. (canon_condition): Likewise. * lra-constraints.c (swap_operands): Likewise. * lra-lives.c (lra_merge_live_ranges): Likewise. * omega.c (swap): Remove. (bswap): Remove. (omega_unprotect_1): Use std::swap. (omega_solve_geq): Likewise. * optabs.c (expand_binop_directly): Likewise. (expand_binop): Likewise. (emit_conditional_move): Likewise. (emit_conditional_add): Likewise. * postreload.c (reload_cse_simplify_operands): Likewise. * reg-stack.c (emit_swap_insn): Likewise. (swap_to_top): Likewise. (compare_for_stack_reg): Likewise. (subst_asm_stack_regs): Likewise. * reload.c (find_reloads): Likewise. * reload1.c (gen_reload_chain_without_interm_reg_p): Likewise. * sel-sched.c (invoke_reorder_hooks): Likewise. (create_block_for_bookkeeping): Likewise. * tree-data-ref.c (lambda_matrix_row_exchange): Remove. (lambda_matrix_right_hermite): Use std::swap. * tree-ssa-coalesce.c (sort_coalesce_list): Likewise. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-loop-ivopts.c (iv_ca_delta_reverse): Likewise. * tree-ssa-math-opts.c (is_widening_mult_p): Likewise. * tree-ssa-phiopt.c (hoist_adjacent_loads): Likewise. * tree-ssa-reassoc.c (linearize_expr_tree): Likewise. * tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise. * tree-vrp.c (compare_ranges): Likewise. * var-tracking.c (add_with_sets): Likewise. (vt_find_locations): Likewise. gcc/c/ * c-typeck.c (build_array_ref): Use std::swap instead of explicit swaps gcc/cp/ * typeck.c (composite_pointer_type): Use std::swap instead of explicit swaps. gcc/c-family/ * c-common.c (shorten_compare): Use std::swap instead of explicit swaps. gcc/fortran/ * interface.c (compare_actual_formal): Use std::swap instead of explicit swaps. * trans-array.c (gfc_trans_scalarized_loop_end): Likewise. * trans-intrinsic.c (walk_inline_intrinsic_transpose): Likewise. From-SVN: r223332 --- gcc/ChangeLog | 49 +++++++++++++++++++++++++++++ gcc/bb-reorder.c | 5 +-- gcc/c-family/ChangeLog | 4 +++ gcc/c-family/c-common.c | 16 +++------- gcc/c/ChangeLog | 5 +++ gcc/c/c-typeck.c | 5 +-- gcc/cp/ChangeLog | 5 +++ gcc/cp/typeck.c | 7 +---- gcc/dojump.c | 5 +-- gcc/expmed.c | 10 +++--- gcc/fibonacci_heap.h | 6 ++-- gcc/final.c | 19 ++---------- gcc/fold-const.c | 8 ++--- gcc/fortran/ChangeLog | 7 +++++ gcc/fortran/interface.c | 11 ++----- gcc/fortran/trans-array.c | 6 +--- gcc/fortran/trans-intrinsic.c | 6 +--- gcc/genmodes.c | 6 +--- gcc/ifcvt.c | 12 +++----- gcc/ira-build.c | 27 ++++------------ gcc/ira.c | 9 ++---- gcc/loop-iv.c | 31 +++++-------------- gcc/lra-constraints.c | 12 ++------ gcc/lra-lives.c | 11 +++---- gcc/omega.c | 53 +++++++------------------------- gcc/optabs.c | 35 +++++---------------- gcc/postreload.c | 5 +-- gcc/reg-stack.c | 28 +++++------------ gcc/reload.c | 58 +++++++++++------------------------ gcc/reload1.c | 9 ++---- gcc/sel-sched.c | 29 ++++++------------ gcc/tree-data-ref.c | 16 ++-------- gcc/tree-ssa-coalesce.c | 10 +++--- gcc/tree-ssa-ifcombine.c | 20 +++--------- gcc/tree-ssa-loop-ivopts.c | 5 +-- gcc/tree-ssa-math-opts.c | 9 ++---- gcc/tree-ssa-phiopt.c | 12 +++----- gcc/tree-ssa-reassoc.c | 6 +--- gcc/tree-ssa-threadedge.c | 5 +-- gcc/tree-vrp.c | 5 +-- gcc/var-tracking.c | 43 +++++--------------------- 41 files changed, 207 insertions(+), 423 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c00a8789d45..44017c18067 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,52 @@ +2015-05-19 Mikhail Maltsev + + * bb-reorder.c (fix_up_fall_thru_edges): Use std::swap instead of + explicit swaps. + * dojump.c (do_compare_rtx_and_jump): Likewise. + * expmed.c (emit_store_flag_1): Likewise. + * fibonacci_heap.h (fibonacci_heap::union_with): Likewise. + * final.c (sprint_ul): Use std::reverse for reversing a string. + * fold-const.c (extract_muldiv_1): Use std::swap. + * genmodes.c (emit_mode_int_n): Likewise. + * ifcvt.c (dead_or_predicable): Likewise. + * ira-build.c (ira_merge_live_ranges): Likewise. + (swap_allocno_copy_ends_if_necessary): Likewise. + * ira.c (ira_setup_alts): Likewise. + * loop-iv.c (iv_analyze_expr): Likewise. + (implies_p): Likewise. + (canon_condition): Likewise. + * lra-constraints.c (swap_operands): Likewise. + * lra-lives.c (lra_merge_live_ranges): Likewise. + * omega.c (swap): Remove. + (bswap): Remove. + (omega_unprotect_1): Use std::swap. + (omega_solve_geq): Likewise. + * optabs.c (expand_binop_directly): Likewise. + (expand_binop): Likewise. + (emit_conditional_move): Likewise. + (emit_conditional_add): Likewise. + * postreload.c (reload_cse_simplify_operands): Likewise. + * reg-stack.c (emit_swap_insn): Likewise. + (swap_to_top): Likewise. + (compare_for_stack_reg): Likewise. + (subst_asm_stack_regs): Likewise. + * reload.c (find_reloads): Likewise. + * reload1.c (gen_reload_chain_without_interm_reg_p): Likewise. + * sel-sched.c (invoke_reorder_hooks): Likewise. + (create_block_for_bookkeeping): Likewise. + * tree-data-ref.c (lambda_matrix_row_exchange): Remove. + (lambda_matrix_right_hermite): Use std::swap. + * tree-ssa-coalesce.c (sort_coalesce_list): Likewise. + * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. + * tree-ssa-loop-ivopts.c (iv_ca_delta_reverse): Likewise. + * tree-ssa-math-opts.c (is_widening_mult_p): Likewise. + * tree-ssa-phiopt.c (hoist_adjacent_loads): Likewise. + * tree-ssa-reassoc.c (linearize_expr_tree): Likewise. + * tree-ssa-threadedge.c (simplify_control_stmt_condition): Likewise. + * tree-vrp.c (compare_ranges): Likewise. + * var-tracking.c (add_with_sets): Likewise. + (vt_find_locations): Likewise. + 2015-05-18 Andreas Tobler * config/freebsd-spec.h (FBSD_STARTFILE_SPEC): Add the bits to build diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index c1347121f51..a97c2cd4c97 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -1812,7 +1812,6 @@ fix_up_fall_thru_edges (void) edge succ2; edge fall_thru; edge cond_jump = NULL; - edge e; bool cond_jump_crosses; int invert_worked; rtx_insn *old_jump; @@ -1901,9 +1900,7 @@ fix_up_fall_thru_edges (void) fall_thru->flags &= ~EDGE_FALLTHRU; cond_jump->flags |= EDGE_FALLTHRU; update_br_prob_note (cur_bb); - e = fall_thru; - fall_thru = cond_jump; - cond_jump = e; + std::swap (fall_thru, cond_jump); cond_jump->flags |= EDGE_CROSSING; fall_thru->flags &= ~EDGE_CROSSING; } diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index a6abd601b08..bf403ce57c7 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,7 @@ +2015-05-19 Mikhail Maltsev + + * c-common.c (shorten_compare): Use std::swap instead of explicit swaps. + 2015-05-18 Tom de Vries * c-common.c (build_va_arg_1): New function. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 6d8504905d1..3998b23b00b 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -4372,20 +4372,12 @@ shorten_compare (location_t loc, tree *op0_ptr, tree *op1_ptr, && !integer_zerop (primop1) && !real_zerop (primop1) && !fixed_zerop (primop1)) { - tree tem = primop0; - int temi = unsignedp0; - primop0 = primop1; - primop1 = tem; - tem = op0; - op0 = op1; - op1 = tem; + std::swap (primop0, primop1); + std::swap (op0, op1); *op0_ptr = op0; *op1_ptr = op1; - unsignedp0 = unsignedp1; - unsignedp1 = temi; - temi = real1; - real1 = real2; - real2 = temi; + std::swap (unsignedp0, unsignedp1); + std::swap (real1, real2); switch (code) { diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 6ef290f7933..d573d7ab6d4 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,8 @@ +2015-05-19 Mikhail Maltsev + + * c-typeck.c (build_array_ref): Use std::swap instead of explicit + swaps + 2015-05-16 Manuel López-Ibáñez PR fortran/44054 diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 9b883a22f2b..7f544902bb1 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -2474,7 +2474,6 @@ build_array_ref (location_t loc, tree array, tree index) /* Allow vector[index] but not index[vector]. */ && TREE_CODE (TREE_TYPE (array)) != VECTOR_TYPE) { - tree temp; if (TREE_CODE (TREE_TYPE (index)) != ARRAY_TYPE && TREE_CODE (TREE_TYPE (index)) != POINTER_TYPE) { @@ -2483,9 +2482,7 @@ build_array_ref (location_t loc, tree array, tree index) return error_mark_node; } - temp = array; - array = index; - index = temp; + std::swap (array, index); swapped = true; } diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b21e6a07974..3271a5491f6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2015-05-19 Mikhail Maltsev + + * typeck.c (composite_pointer_type): Use std::swap instead of explicit + swaps. + 2015-05-18 Jason Merrill * pt.c (retrieve_specialization): Make sure our arguments have diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 549e4b161f5..a4d702b2a1d 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -606,12 +606,7 @@ composite_pointer_type (tree t1, tree t2, tree arg1, tree arg2, If either type is a pointer to void, make sure it is T1. */ if (TYPE_PTR_P (t2) && VOID_TYPE_P (TREE_TYPE (t2))) - { - tree t; - t = t1; - t1 = t2; - t2 = t; - } + std::swap (t1, t2); /* Now, if T1 is a pointer to void, merge the qualifiers. */ if (TYPE_PTR_P (t1) && VOID_TYPE_P (TREE_TYPE (t1))) diff --git a/gcc/dojump.c b/gcc/dojump.c index 0790c77d239..b564d6417bf 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -1096,11 +1096,8 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp, && ! can_compare_p (code, mode, ccp_jump) && can_compare_p (swap_condition (code), mode, ccp_jump)) { - rtx tmp; code = swap_condition (code); - tmp = op0; - op0 = op1; - op1 = tmp; + std::swap (op0, op1); } else if (SCALAR_FLOAT_MODE_P (mode) && ! can_compare_p (code, mode, ccp_jump) diff --git a/gcc/expmed.c b/gcc/expmed.c index 6679f501c2c..2da9a6552a0 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -5256,7 +5256,6 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, machine_mode compare_mode; enum mode_class mclass; enum rtx_code scode; - rtx tem; if (unsignedp) code = unsigned_condition (code); @@ -5267,9 +5266,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, if (swap_commutative_operands_p (op0, op1)) { - tem = op0; - op0 = op1; - op1 = tem; + std::swap (op0, op1); code = swap_condition (code); } @@ -5316,6 +5313,7 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, && GET_MODE_CLASS (mode) == MODE_INT && (!MEM_P (op0) || ! MEM_VOLATILE_P (op0))) { + rtx tem; if ((code == EQ || code == NE) && (op1 == const0_rtx || op1 == constm1_rtx)) { @@ -5415,8 +5413,8 @@ emit_store_flag_1 (rtx target, enum rtx_code code, rtx op0, rtx op1, if (icode != CODE_FOR_nothing) { do_pending_stack_adjust (); - tem = emit_cstore (target, icode, code, mode, compare_mode, - unsignedp, op0, op1, normalizep, target_mode); + rtx tem = emit_cstore (target, icode, code, mode, compare_mode, + unsignedp, op0, op1, normalizep, target_mode); if (tem) return tem; diff --git a/gcc/fibonacci_heap.h b/gcc/fibonacci_heap.h index 0d9226bbca9..2e74176f58a 100644 --- a/gcc/fibonacci_heap.h +++ b/gcc/fibonacci_heap.h @@ -457,7 +457,7 @@ fibonacci_heap::union_with (fibonacci_heap *heapb) { fibonacci_heap *heapa = this; - fibonacci_node *a_root, *b_root, *temp; + fibonacci_node *a_root, *b_root; /* If one of the heaps is empty, the union is just the other heap. */ if ((a_root = heapa->m_root) == NULL) @@ -474,9 +474,7 @@ fibonacci_heap::union_with (fibonacci_heap *heapb) /* Merge them to the next nodes on the opposite chain. */ a_root->m_left->m_right = b_root; b_root->m_left->m_right = a_root; - temp = a_root->m_left; - a_root->m_left = b_root->m_left; - b_root->m_left = temp; + std::swap (a_root->m_left, b_root->m_left); heapa->m_nodes += heapb->m_nodes; /* And set the new minimum, if it's changed. */ diff --git a/gcc/final.c b/gcc/final.c index 0c91095bae4..aaeececc0b4 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -4131,25 +4131,10 @@ fprint_ul (FILE *f, unsigned long value) int sprint_ul (char *s, unsigned long value) { - int len; - char tmp_c; - int i; - int j; - - len = sprint_ul_rev (s, value); + int len = sprint_ul_rev (s, value); s[len] = '\0'; - /* Reverse the string. */ - i = 0; - j = len - 1; - while (i < j) - { - tmp_c = s[i]; - s[i] = s[j]; - s[j] = tmp_c; - i++; j--; - } - + std::reverse (s, s + len); return len; } diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3654fd670b0..1476ee0b1ed 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -6139,12 +6139,8 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type, /* If OP1 was not easily negatable, the constant may be OP0. */ if (TREE_CODE (op0) == INTEGER_CST) { - tree tem = op0; - op0 = op1; - op1 = tem; - tem = t1; - t1 = t2; - t2 = tem; + std::swap (op0, op1); + std::swap (t1, t2); } } diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index de7be7aa65d..6b3ad092987 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2015-05-19 Mikhail Maltsev + + * interface.c (compare_actual_formal): Use std::swap instead of + explicit swaps. + * trans-array.c (gfc_trans_scalarized_loop_end): Likewise. + * trans-intrinsic.c (walk_inline_intrinsic_transpose): Likewise. + 2015-05-18 Steven G. Kargl PR fortran/66106 diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c index d011d846d31..9f55f0a19f9 100644 --- a/gcc/fortran/interface.c +++ b/gcc/fortran/interface.c @@ -2566,7 +2566,7 @@ static int compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, int ranks_must_agree, int is_elemental, locus *where) { - gfc_actual_arglist **new_arg, *a, *actual, temp; + gfc_actual_arglist **new_arg, *a, *actual; gfc_formal_arglist *f; int i, n, na; unsigned long actual_size, formal_size; @@ -3029,13 +3029,8 @@ compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal, if (na != 0) { - temp = *new_arg[0]; - *new_arg[0] = *actual; - *actual = temp; - - a = new_arg[0]; - new_arg[0] = new_arg[na]; - new_arg[na] = a; + std::swap (*new_arg[0], *actual); + std::swap (new_arg[0], new_arg[na]); } for (i = 0; i < n - 1; i++) diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index 8267f6a41f9..e6edf742377 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -3644,11 +3644,7 @@ gfc_trans_scalarized_loop_end (gfc_loopinfo * loop, int n, loopbody = gfc_finish_block (pbody); if (reverse_loop) - { - tmp = loop->from[n]; - loop->from[n] = loop->to[n]; - loop->to[n] = tmp; - } + std::swap (loop->from[n], loop->to[n]); /* Initialize the loopvar. */ if (loop->loopvar[n] != loop->from[n]) diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index 20e5b37e240..323c600c99c 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -8324,14 +8324,10 @@ walk_inline_intrinsic_transpose (gfc_ss *ss, gfc_expr *expr) if (tmp_ss->info->type != GFC_SS_SCALAR && tmp_ss->info->type != GFC_SS_REFERENCE) { - int tmp_dim; - gcc_assert (tmp_ss->dimen == 2); /* We just invert dimensions. */ - tmp_dim = tmp_ss->dim[0]; - tmp_ss->dim[0] = tmp_ss->dim[1]; - tmp_ss->dim[1] = tmp_dim; + std::swap (tmp_ss->dim[0], tmp_ss->dim[1]); } /* Stop when tmp_ss points to the last valid element of the chain... */ diff --git a/gcc/genmodes.c b/gcc/genmodes.c index 45681f5db3f..af1fe4f6c93 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -1600,11 +1600,7 @@ emit_mode_int_n (void) for (i = 0; iint_n > mode_sort[j]->int_n) - { - m = mode_sort[i]; - mode_sort[i] = mode_sort[j]; - mode_sort[j] = m; - } + std::swap (mode_sort[i], mode_sort[j]); for (i = 0; i < n_modes; i ++) { diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index fc7c4f1f518..afeb034fc06 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -4462,14 +4462,10 @@ dead_or_predicable (basic_block test_bb, basic_block merge_bb, redirect_edge_succ (BRANCH_EDGE (test_bb), new_dest); if (reversep) { - gcov_type count, probability; - count = BRANCH_EDGE (test_bb)->count; - BRANCH_EDGE (test_bb)->count = FALLTHRU_EDGE (test_bb)->count; - FALLTHRU_EDGE (test_bb)->count = count; - probability = BRANCH_EDGE (test_bb)->probability; - BRANCH_EDGE (test_bb)->probability - = FALLTHRU_EDGE (test_bb)->probability; - FALLTHRU_EDGE (test_bb)->probability = probability; + std::swap (BRANCH_EDGE (test_bb)->count, + FALLTHRU_EDGE (test_bb)->count); + std::swap (BRANCH_EDGE (test_bb)->probability, + FALLTHRU_EDGE (test_bb)->probability); update_br_prob_note (test_bb); } } diff --git a/gcc/ira-build.c b/gcc/ira-build.c index 189f340800a..8b6b9564fcb 100644 --- a/gcc/ira-build.c +++ b/gcc/ira-build.c @@ -1000,7 +1000,7 @@ ira_copy_live_range_list (live_range_t r) live_range_t ira_merge_live_ranges (live_range_t r1, live_range_t r2) { - live_range_t first, last, temp; + live_range_t first, last; if (r1 == NULL) return r2; @@ -1009,18 +1009,14 @@ ira_merge_live_ranges (live_range_t r1, live_range_t r2) for (first = last = NULL; r1 != NULL && r2 != NULL;) { if (r1->start < r2->start) - { - temp = r1; - r1 = r2; - r2 = temp; - } + std::swap (r1, r2); if (r1->start <= r2->finish + 1) { /* Intersected ranges: merge r1 and r2 into r1. */ r1->start = r2->start; if (r1->finish < r2->finish) r1->finish = r2->finish; - temp = r2; + live_range_t temp = r2; r2 = r2->next; ira_finish_live_range (temp); if (r2 == NULL) @@ -1479,23 +1475,12 @@ add_allocno_copy_to_list (ira_copy_t cp) static void swap_allocno_copy_ends_if_necessary (ira_copy_t cp) { - ira_allocno_t temp; - ira_copy_t temp_cp; - if (ALLOCNO_NUM (cp->first) <= ALLOCNO_NUM (cp->second)) return; - temp = cp->first; - cp->first = cp->second; - cp->second = temp; - - temp_cp = cp->prev_first_allocno_copy; - cp->prev_first_allocno_copy = cp->prev_second_allocno_copy; - cp->prev_second_allocno_copy = temp_cp; - - temp_cp = cp->next_first_allocno_copy; - cp->next_first_allocno_copy = cp->next_second_allocno_copy; - cp->next_second_allocno_copy = temp_cp; + std::swap (cp->first, cp->second); + std::swap (cp->prev_first_allocno_copy, cp->prev_second_allocno_copy); + std::swap (cp->next_first_allocno_copy, cp->next_second_allocno_copy); } /* Create (or update frequency if the copy already exists) and return diff --git a/gcc/ira.c b/gcc/ira.c index 07d6c6951f2..a4108872c28 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -1808,7 +1808,6 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) int nop, nalt; bool curr_swapped; const char *p; - rtx op; int commutative = -1; extract_insn (insn); @@ -1850,7 +1849,7 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) { int c, len; - op = recog_data.operand[nop]; + rtx op = recog_data.operand[nop]; p = insn_constraints[nop * recog_data.n_alternatives + nalt]; if (*p == 0 || *p == ',') continue; @@ -1923,10 +1922,8 @@ ira_setup_alts (rtx_insn *insn, HARD_REG_SET &alts) break; if (curr_swapped) break; - op = recog_data.operand[commutative]; - recog_data.operand[commutative] = recog_data.operand[commutative + 1]; - recog_data.operand[commutative + 1] = op; - + std::swap (recog_data.operand[commutative], + recog_data.operand[commutative + 1]); } } diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index bf6359da4a0..8c3ef7784e6 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -977,7 +977,7 @@ bool iv_analyze_expr (rtx_insn *insn, rtx rhs, machine_mode mode, struct rtx_iv *iv) { - rtx mby = NULL_RTX, tmp; + rtx mby = NULL_RTX; rtx op0 = NULL_RTX, op1 = NULL_RTX; struct rtx_iv iv0, iv1; enum rtx_code code = GET_CODE (rhs); @@ -1028,11 +1028,7 @@ iv_analyze_expr (rtx_insn *insn, rtx rhs, machine_mode mode, op0 = XEXP (rhs, 0); mby = XEXP (rhs, 1); if (!CONSTANT_P (mby)) - { - tmp = op0; - op0 = mby; - mby = tmp; - } + std::swap (op0, mby); if (!CONSTANT_P (mby)) return false; break; @@ -1544,7 +1540,7 @@ replace_in_expr (rtx *expr, rtx dest, rtx src) static bool implies_p (rtx a, rtx b) { - rtx op0, op1, opb0, opb1, r; + rtx op0, op1, opb0, opb1; machine_mode mode; if (rtx_equal_p (a, b)) @@ -1559,7 +1555,7 @@ implies_p (rtx a, rtx b) || (GET_CODE (op0) == SUBREG && REG_P (SUBREG_REG (op0)))) { - r = simplify_replace_rtx (b, op0, op1); + rtx r = simplify_replace_rtx (b, op0, op1); if (r == const_true_rtx) return true; } @@ -1568,7 +1564,7 @@ implies_p (rtx a, rtx b) || (GET_CODE (op1) == SUBREG && REG_P (SUBREG_REG (op1)))) { - r = simplify_replace_rtx (b, op1, op0); + rtx r = simplify_replace_rtx (b, op1, op0); if (r == const_true_rtx) return true; } @@ -1604,18 +1600,10 @@ implies_p (rtx a, rtx b) { if (GET_CODE (a) == GT) - { - r = op0; - op0 = op1; - op1 = r; - } + std::swap (op0, op1); if (GET_CODE (b) == GE) - { - r = opb0; - opb0 = opb1; - opb1 = r; - } + std::swap (opb0, opb1); if (SCALAR_INT_MODE_P (mode) && rtx_equal_p (op1, opb1) @@ -1707,7 +1695,6 @@ implies_p (rtx a, rtx b) rtx canon_condition (rtx cond) { - rtx tem; rtx op0, op1; enum rtx_code code; machine_mode mode; @@ -1719,9 +1706,7 @@ canon_condition (rtx cond) if (swap_commutative_operands_p (op0, op1)) { code = swap_condition (code); - tem = op0; - op0 = op1; - op1 = tem; + std::swap (op0, op1); } mode = GET_MODE (op0); diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index c8de418144e..b8e9d1f0c16 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -3293,15 +3293,9 @@ simple_move_p (void) static inline void swap_operands (int nop) { - machine_mode mode = curr_operand_mode[nop]; - curr_operand_mode[nop] = curr_operand_mode[nop + 1]; - curr_operand_mode[nop + 1] = mode; - mode = original_subreg_reg_mode[nop]; - original_subreg_reg_mode[nop] = original_subreg_reg_mode[nop + 1]; - original_subreg_reg_mode[nop + 1] = mode; - rtx x = *curr_id->operand_loc[nop]; - *curr_id->operand_loc[nop] = *curr_id->operand_loc[nop + 1]; - *curr_id->operand_loc[nop + 1] = x; + std::swap (curr_operand_mode[nop], curr_operand_mode[nop + 1]); + std::swap (original_subreg_reg_mode[nop], original_subreg_reg_mode[nop + 1]); + std::swap (*curr_id->operand_loc[nop], *curr_id->operand_loc[nop + 1]); /* Swap the duplicates too. */ lra_update_dup (curr_id, nop); lra_update_dup (curr_id, nop + 1); diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c index 47a9ba22b5a..085411ee7d0 100644 --- a/gcc/lra-lives.c +++ b/gcc/lra-lives.c @@ -192,7 +192,7 @@ lra_copy_live_range_list (lra_live_range_t r) lra_live_range_t lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2) { - lra_live_range_t first, last, temp; + lra_live_range_t first, last; if (r1 == NULL) return r2; @@ -201,16 +201,13 @@ lra_merge_live_ranges (lra_live_range_t r1, lra_live_range_t r2) for (first = last = NULL; r1 != NULL && r2 != NULL;) { if (r1->start < r2->start) - { - temp = r1; - r1 = r2; - r2 = temp; - } + std::swap (r1, r2); + if (r1->start == r2->finish + 1) { /* Joint ranges: merge r1 and r2 into r1. */ r1->start = r2->start; - temp = r2; + lra_live_range_t temp = r2; r2 = r2->next; pool_free (live_range_pool, temp); } diff --git a/gcc/omega.c b/gcc/omega.c index 321fa61d0d2..436d9f7178b 100644 --- a/gcc/omega.c +++ b/gcc/omega.c @@ -1882,28 +1882,6 @@ cleanout_wildcards (omega_pb pb) normalize_omega_problem (pb); } -/* Swap values contained in I and J. */ - -static inline void -swap (int *i, int *j) -{ - int tmp; - tmp = *i; - *i = *j; - *j = tmp; -} - -/* Swap values contained in I and J. */ - -static inline void -bswap (bool *i, bool *j) -{ - bool tmp; - tmp = *i; - *i = *j; - *j = tmp; -} - /* Make variable IDX unprotected in PB, by swapping its index at the PB->safe_vars rank. */ @@ -1920,19 +1898,19 @@ omega_unprotect_1 (omega_pb pb, int *idx, bool *unprotect) for (e = pb->num_geqs - 1; e >= 0; e--) { pb->geqs[e].touched = 1; - swap (&pb->geqs[e].coef[*idx], &pb->geqs[e].coef[j]); + std::swap (pb->geqs[e].coef[*idx], pb->geqs[e].coef[j]); } for (e = pb->num_eqs - 1; e >= 0; e--) - swap (&pb->eqs[e].coef[*idx], &pb->eqs[e].coef[j]); + std::swap (pb->eqs[e].coef[*idx], pb->eqs[e].coef[j]); for (e = pb->num_subs - 1; e >= 0; e--) - swap (&pb->subs[e].coef[*idx], &pb->subs[e].coef[j]); + std::swap (pb->subs[e].coef[*idx], pb->subs[e].coef[j]); if (unprotect) - bswap (&unprotect[*idx], &unprotect[j]); + std::swap (unprotect[*idx], unprotect[j]); - swap (&pb->var[*idx], &pb->var[j]); + std::swap (pb->var[*idx], pb->var[j]); pb->forwarding_address[pb->var[*idx]] = *idx; pb->forwarding_address[pb->var[j]] = j; (*idx)--; @@ -3999,7 +3977,6 @@ omega_solve_geq (omega_pb pb, enum omega_result desired_res) if (i != n_vars) { - int t; int j = pb->num_vars; if (dump_file && (dump_flags & TDF_DETAILS)) @@ -4008,24 +3985,18 @@ omega_solve_geq (omega_pb pb, enum omega_result desired_res) omega_print_problem (dump_file, pb); } - swap (&pb->var[i], &pb->var[j]); + std::swap (pb->var[i], pb->var[j]); for (e = pb->num_geqs - 1; e >= 0; e--) if (pb->geqs[e].coef[i] != pb->geqs[e].coef[j]) { pb->geqs[e].touched = 1; - t = pb->geqs[e].coef[i]; - pb->geqs[e].coef[i] = pb->geqs[e].coef[j]; - pb->geqs[e].coef[j] = t; + std::swap (pb->geqs[e].coef[i], pb->geqs[e].coef[j]); } for (e = pb->num_subs - 1; e >= 0; e--) if (pb->subs[e].coef[i] != pb->subs[e].coef[j]) - { - t = pb->subs[e].coef[i]; - pb->subs[e].coef[i] = pb->subs[e].coef[j]; - pb->subs[e].coef[j] = t; - } + std::swap (pb->subs[e].coef[i], pb->subs[e].coef[j]); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -4624,16 +4595,14 @@ omega_solve_geq (omega_pb pb, enum omega_result desired_res) /* Sort array LOWER_BOUND. */ for (j = 0; j < lower_bounds; j++) { - int k, smallest = j; + int smallest = j; - for (k = j + 1; k < lower_bounds; k++) + for (int k = j + 1; k < lower_bounds; k++) if (pb->geqs[lower_bound[smallest]].coef[i] > pb->geqs[lower_bound[k]].coef[i]) smallest = k; - k = lower_bound[smallest]; - lower_bound[smallest] = lower_bound[j]; - lower_bound[j] = k; + std::swap (lower_bound[smallest], lower_bound[j]); } if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/optabs.c b/gcc/optabs.c index bd03fc1f5fe..d883b000f04 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -1418,7 +1418,6 @@ expand_binop_directly (machine_mode mode, optab binoptab, bool commutative_p; rtx pat; rtx xop0 = op0, xop1 = op1; - rtx swap; /* If it is a commutative operator and the modes would match if we would swap the operands, we can save the conversions. */ @@ -1426,11 +1425,7 @@ expand_binop_directly (machine_mode mode, optab binoptab, if (commutative_p && GET_MODE (xop0) != xmode0 && GET_MODE (xop1) != xmode1 && GET_MODE (xop0) == xmode1 && GET_MODE (xop1) == xmode1) - { - swap = xop0; - xop0 = xop1; - xop1 = swap; - } + std::swap (xop0, xop1); /* If we are optimizing, force expensive constants into a register. */ xop0 = avoid_expensive_constant (xmode0, binoptab, 0, xop0, unsignedp); @@ -1463,11 +1458,7 @@ expand_binop_directly (machine_mode mode, optab binoptab, Also try to make the last operand a constant. */ if (commutative_p && swap_commutative_operands_with_target (target, xop0, xop1)) - { - swap = xop1; - xop1 = xop0; - xop0 = swap; - } + std::swap (xop0, xop1); /* Now, if insn's predicates don't allow our operands, put them into pseudo regs. */ @@ -1722,11 +1713,7 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1, Also try to make the last operand a constant. */ if (commutative_optab_p (binoptab) && swap_commutative_operands_with_target (target, op0, op1)) - { - temp = op1; - op1 = op0; - op0 = temp; - } + std::swap (op0, op1); /* These can be done a word at a time. */ if ((binoptab == and_optab || binoptab == ior_optab || binoptab == xor_optab) @@ -4553,7 +4540,7 @@ emit_conditional_move (rtx target, enum rtx_code code, rtx op0, rtx op1, machine_mode cmode, rtx op2, rtx op3, machine_mode mode, int unsignedp) { - rtx tem, comparison; + rtx comparison; rtx_insn *last; enum insn_code icode; enum rtx_code reversed; @@ -4563,9 +4550,7 @@ emit_conditional_move (rtx target, enum rtx_code code, rtx op0, rtx op1, if (swap_commutative_operands_p (op0, op1)) { - tem = op0; - op0 = op1; - op1 = tem; + std::swap (op0, op1); code = swap_condition (code); } @@ -4584,9 +4569,7 @@ emit_conditional_move (rtx target, enum rtx_code code, rtx op0, rtx op1, && ((reversed = reversed_comparison_code_parts (code, op0, op1, NULL)) != UNKNOWN)) { - tem = op2; - op2 = op3; - op3 = tem; + std::swap (op2, op3); code = reversed; } @@ -4675,7 +4658,7 @@ emit_conditional_add (rtx target, enum rtx_code code, rtx op0, rtx op1, machine_mode cmode, rtx op2, rtx op3, machine_mode mode, int unsignedp) { - rtx tem, comparison; + rtx comparison; rtx_insn *last; enum insn_code icode; @@ -4684,9 +4667,7 @@ emit_conditional_add (rtx target, enum rtx_code code, rtx op0, rtx op1, if (swap_commutative_operands_p (op0, op1)) { - tem = op0; - op0 = op1; - op1 = tem; + std::swap (op0, op1); code = swap_condition (code); } diff --git a/gcc/postreload.c b/gcc/postreload.c index 99b1fc26900..b12ef5b1028 100644 --- a/gcc/postreload.c +++ b/gcc/postreload.c @@ -632,7 +632,6 @@ reload_cse_simplify_operands (rtx_insn *insn, rtx testreg) int best = i; int best_reject = alternative_reject[alternative_order[i]]; int best_nregs = alternative_nregs[alternative_order[i]]; - int tmp; for (j = i + 1; j < recog_data.n_alternatives; j++) { @@ -648,9 +647,7 @@ reload_cse_simplify_operands (rtx_insn *insn, rtx testreg) } } - tmp = alternative_order[best]; - alternative_order[best] = alternative_order[i]; - alternative_order[i] = tmp; + std::swap (alternative_order[best], alternative_order[i]); } /* Substitute the operands as determined by op_alt_regno for the best diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c index c5d52c1d686..a8637005dd7 100644 --- a/gcc/reg-stack.c +++ b/gcc/reg-stack.c @@ -812,7 +812,7 @@ emit_swap_insn (rtx_insn *insn, stack_ptr regstack, rtx reg) { int hard_regno; rtx swap_rtx; - int tmp, other_reg; /* swap regno temps */ + int other_reg; /* swap regno temps */ rtx_insn *i1; /* the stack-reg insn prior to INSN */ rtx i1set = NULL_RTX; /* the SET rtx within I1 */ @@ -833,10 +833,7 @@ emit_swap_insn (rtx_insn *insn, stack_ptr regstack, rtx reg) gcc_assert (hard_regno >= FIRST_STACK_REG); other_reg = regstack->top - (hard_regno - FIRST_STACK_REG); - - tmp = regstack->reg[other_reg]; - regstack->reg[other_reg] = regstack->reg[regstack->top]; - regstack->reg[regstack->top] = tmp; + std::swap (regstack->reg[regstack->top], regstack->reg[other_reg]); /* Find the previous insn involving stack regs, but don't pass a block boundary. */ @@ -918,7 +915,7 @@ static void swap_to_top (rtx_insn *insn, stack_ptr regstack, rtx src1, rtx src2) { struct stack_def temp_stack; - int regno, j, k, temp; + int regno, j, k; temp_stack = *regstack; @@ -930,9 +927,7 @@ swap_to_top (rtx_insn *insn, stack_ptr regstack, rtx src1, rtx src2) k = temp_stack.top - (regno - FIRST_STACK_REG); j = temp_stack.top; - temp = temp_stack.reg[k]; - temp_stack.reg[k] = temp_stack.reg[j]; - temp_stack.reg[j] = temp; + std::swap (temp_stack.reg[j], temp_stack.reg[k]); } /* Place operand 2 next on the stack. */ @@ -943,9 +938,7 @@ swap_to_top (rtx_insn *insn, stack_ptr regstack, rtx src1, rtx src2) k = temp_stack.top - (regno - FIRST_STACK_REG); j = temp_stack.top - 1; - temp = temp_stack.reg[k]; - temp_stack.reg[k] = temp_stack.reg[j]; - temp_stack.reg[j] = temp; + std::swap (temp_stack.reg[j], temp_stack.reg[k]); } change_stack (insn, regstack, &temp_stack, EMIT_BEFORE); @@ -1261,10 +1254,7 @@ compare_for_stack_reg (rtx_insn *insn, stack_ptr regstack, rtx pat_src) && get_hard_regnum (regstack, *src2) == FIRST_STACK_REG)) && swap_rtx_condition (insn)) { - rtx temp; - temp = XEXP (pat_src, 0); - XEXP (pat_src, 0) = XEXP (pat_src, 1); - XEXP (pat_src, 1) = temp; + std::swap (XEXP (pat_src, 0), XEXP (pat_src, 1)); src1 = get_true_reg (&XEXP (pat_src, 0)); src2 = get_true_reg (&XEXP (pat_src, 1)); @@ -2139,15 +2129,13 @@ subst_asm_stack_regs (rtx_insn *insn, stack_ptr regstack) it and swap it with whatever is already in I's place. K is where recog_data.operand[i] is now. J is where it should be. */ - int j, k, temp; + int j, k; k = temp_stack.top - (regno - FIRST_STACK_REG); j = (temp_stack.top - (REGNO (recog_data.operand[i]) - FIRST_STACK_REG)); - temp = temp_stack.reg[k]; - temp_stack.reg[k] = temp_stack.reg[j]; - temp_stack.reg[j] = temp; + std::swap (temp_stack.reg[j], temp_stack.reg[k]); } } diff --git a/gcc/reload.c b/gcc/reload.c index dde70b2bcd8..a3edb15d4be 100644 --- a/gcc/reload.c +++ b/gcc/reload.c @@ -3064,9 +3064,6 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, if (swapped) { - enum reg_class tclass; - int t; - recog_data.operand[commutative] = substed_operand[commutative + 1]; recog_data.operand[commutative + 1] = substed_operand[commutative]; /* Swap the duplicates too. */ @@ -3076,17 +3073,12 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, *recog_data.dup_loc[i] = recog_data.operand[(int) recog_data.dup_num[i]]; - tclass = preferred_class[commutative]; - preferred_class[commutative] = preferred_class[commutative + 1]; - preferred_class[commutative + 1] = tclass; - - t = pref_or_nothing[commutative]; - pref_or_nothing[commutative] = pref_or_nothing[commutative + 1]; - pref_or_nothing[commutative + 1] = t; - - t = address_reloaded[commutative]; - address_reloaded[commutative] = address_reloaded[commutative + 1]; - address_reloaded[commutative + 1] = t; + std::swap (preferred_class[commutative], + preferred_class[commutative + 1]); + std::swap (pref_or_nothing[commutative], + pref_or_nothing[commutative + 1]); + std::swap (address_reloaded[commutative], + address_reloaded[commutative + 1]); } this_earlyclobber = 0; @@ -3818,9 +3810,6 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, if (swapped) { - enum reg_class tclass; - int t; - /* If the commutative operands have been swapped, swap them back in order to check the next alternative. */ recog_data.operand[commutative] = substed_operand[commutative]; @@ -3833,17 +3822,12 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, = recog_data.operand[(int) recog_data.dup_num[i]]; /* Unswap the operand related information as well. */ - tclass = preferred_class[commutative]; - preferred_class[commutative] = preferred_class[commutative + 1]; - preferred_class[commutative + 1] = tclass; - - t = pref_or_nothing[commutative]; - pref_or_nothing[commutative] = pref_or_nothing[commutative + 1]; - pref_or_nothing[commutative + 1] = t; - - t = address_reloaded[commutative]; - address_reloaded[commutative] = address_reloaded[commutative + 1]; - address_reloaded[commutative + 1] = t; + std::swap (preferred_class[commutative], + preferred_class[commutative + 1]); + std::swap (pref_or_nothing[commutative], + pref_or_nothing[commutative + 1]); + std::swap (address_reloaded[commutative], + address_reloaded[commutative + 1]); } } } @@ -3892,18 +3876,12 @@ find_reloads (rtx_insn *insn, int replace, int ind_levels, int live_known, if (goal_alternative_swapped) { - rtx tem; - - tem = substed_operand[commutative]; - substed_operand[commutative] = substed_operand[commutative + 1]; - substed_operand[commutative + 1] = tem; - tem = recog_data.operand[commutative]; - recog_data.operand[commutative] = recog_data.operand[commutative + 1]; - recog_data.operand[commutative + 1] = tem; - tem = *recog_data.operand_loc[commutative]; - *recog_data.operand_loc[commutative] - = *recog_data.operand_loc[commutative + 1]; - *recog_data.operand_loc[commutative + 1] = tem; + std::swap (substed_operand[commutative], + substed_operand[commutative + 1]); + std::swap (recog_data.operand[commutative], + recog_data.operand[commutative + 1]); + std::swap (*recog_data.operand_loc[commutative], + *recog_data.operand_loc[commutative + 1]); for (i = 0; i < n_reloads; i++) { diff --git a/gcc/reload1.c b/gcc/reload1.c index d2c5524ddcf..3ac8c2da764 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -5707,18 +5707,15 @@ gen_reload_chain_without_interm_reg_p (int r1, int r2) /* Assume other cases in gen_reload are not possible for chain reloads or do need an intermediate hard registers. */ bool result = true; - int regno, n, code; + int regno, code; rtx out, in; rtx_insn *insn; rtx_insn *last = get_last_insn (); /* Make r2 a component of r1. */ if (reg_mentioned_p (rld[r1].in, rld[r2].in)) - { - n = r1; - r1 = r2; - r2 = n; - } + std::swap (r1, r2); + gcc_assert (reg_mentioned_p (rld[r2].in, rld[r1].in)); regno = rld[r1].regno >= 0 ? rld[r1].regno : rld[r2].regno; gcc_assert (regno >= 0); diff --git a/gcc/sel-sched.c b/gcc/sel-sched.c index b8ed356a2a2..6a58b2c4a8a 100644 --- a/gcc/sel-sched.c +++ b/gcc/sel-sched.c @@ -4142,16 +4142,12 @@ invoke_reorder_hooks (fence_t fence) for (i = 0, n = ready.n_ready; i < n; i++) if (EXPR_INSN_RTX (vec[i]) != arr[i]) { - expr_t tmp; - for (j = i; j < n; j++) if (EXPR_INSN_RTX (vec[j]) == arr[i]) break; gcc_assert (j < n); - tmp = vec[i]; - vec[i] = vec[j]; - vec[j] = tmp; + std::swap (vec[i], vec[j]); } } @@ -4610,15 +4606,12 @@ create_block_for_bookkeeping (edge e1, edge e2) { sel_global_bb_info_def gbi; sel_region_bb_info_def rbi; - int i; if (sched_verbose >= 2) sel_print ("Swapping block ids %i and %i\n", new_bb->index, succ->index); - i = new_bb->index; - new_bb->index = succ->index; - succ->index = i; + std::swap (new_bb->index, succ->index); SET_BASIC_BLOCK_FOR_FN (cfun, new_bb->index, new_bb); SET_BASIC_BLOCK_FOR_FN (cfun, succ->index, succ); @@ -4633,15 +4626,13 @@ create_block_for_bookkeeping (edge e1, edge e2) sizeof (rbi)); memcpy (SEL_REGION_BB_INFO (succ), &rbi, sizeof (rbi)); - i = BLOCK_TO_BB (new_bb->index); - BLOCK_TO_BB (new_bb->index) = BLOCK_TO_BB (succ->index); - BLOCK_TO_BB (succ->index) = i; + std::swap (BLOCK_TO_BB (new_bb->index), + BLOCK_TO_BB (succ->index)); - i = CONTAINING_RGN (new_bb->index); - CONTAINING_RGN (new_bb->index) = CONTAINING_RGN (succ->index); - CONTAINING_RGN (succ->index) = i; + std::swap (CONTAINING_RGN (new_bb->index), + CONTAINING_RGN (succ->index)); - for (i = 0; i < current_nr_blocks; i++) + for (int i = 0; i < current_nr_blocks; i++) if (BB_TO_BLOCK (i) == succ->index) BB_TO_BLOCK (i) = new_bb->index; else if (BB_TO_BLOCK (i) == new_bb->index) @@ -4666,10 +4657,8 @@ create_block_for_bookkeeping (edge e1, edge e2) CODE_LABEL_NUMBER (BB_HEAD (new_bb)), CODE_LABEL_NUMBER (BB_HEAD (succ))); - i = CODE_LABEL_NUMBER (BB_HEAD (new_bb)); - CODE_LABEL_NUMBER (BB_HEAD (new_bb)) - = CODE_LABEL_NUMBER (BB_HEAD (succ)); - CODE_LABEL_NUMBER (BB_HEAD (succ)) = i; + std::swap (CODE_LABEL_NUMBER (BB_HEAD (new_bb)), + CODE_LABEL_NUMBER (BB_HEAD (succ))); } } } diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 3d1d5f8c0fe..505d63b0083 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2411,18 +2411,6 @@ lambda_matrix_row_add (lambda_matrix mat, int n, int r1, int r2, int const1) mat[r2][i] += const1 * mat[r1][i]; } -/* Swap rows R1 and R2 in matrix MAT. */ - -static void -lambda_matrix_row_exchange (lambda_matrix mat, int r1, int r2) -{ - lambda_vector row; - - row = mat[r1]; - mat[r1] = mat[r2]; - mat[r2] = row; -} - /* Multiply vector VEC1 of length SIZE by a constant CONST1, and store the result in VEC2. */ @@ -2503,10 +2491,10 @@ lambda_matrix_right_hermite (lambda_matrix A, int m, int n, factor = sigma * (a / b); lambda_matrix_row_add (S, n, i, i-1, -factor); - lambda_matrix_row_exchange (S, i, i-1); + std::swap (S[i], S[i-1]); lambda_matrix_row_add (U, m, i, i-1, -factor); - lambda_matrix_row_exchange (U, i, i-1); + std::swap (U[i], U[i-1]); } } } diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index eeac5a46ab9..b05a86086ef 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -433,15 +433,13 @@ sort_coalesce_list (coalesce_list_p cl) if (num == 2) { if (cl->sorted[0]->cost > cl->sorted[1]->cost) - { - p = cl->sorted[0]; - cl->sorted[0] = cl->sorted[1]; - cl->sorted[1] = p; - } + std::swap (cl->sorted[0], cl->sorted[1]); return; } - /* Only call qsort if there are more than 2 items. */ + /* Only call qsort if there are more than 2 items. + ??? Maybe std::sort will do better, provided that compare_pairs + can be inlined. */ if (num > 2) qsort (cl->sorted, num, sizeof (coalesce_pair_p), compare_pairs); } diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c index 0ac13b565a8..4170c9be3af 100644 --- a/gcc/tree-ssa-ifcombine.c +++ b/gcc/tree-ssa-ifcombine.c @@ -438,25 +438,13 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv, ; else if (bits1 == bits2) { - t = name2; - name2 = bits2; - bits2 = t; - t = name1; - name1 = bits1; - bits1 = t; + std::swap (name2, bits2); + std::swap (name1, bits1); } else if (name1 == bits2) - { - t = name2; - name2 = bits2; - bits2 = t; - } + std::swap (name2, bits2); else if (bits1 == name2) - { - t = name1; - name1 = bits1; - bits1 = t; - } + std::swap (name1, bits1); else return false; diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 44219d259e1..3ed32d8e2fb 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -5587,7 +5587,6 @@ static struct iv_ca_delta * iv_ca_delta_reverse (struct iv_ca_delta *delta) { struct iv_ca_delta *act, *next, *prev = NULL; - struct cost_pair *tmp; for (act = delta; act; act = next) { @@ -5595,9 +5594,7 @@ iv_ca_delta_reverse (struct iv_ca_delta *delta) act->next_change = prev; prev = act; - tmp = act->old_cp; - act->old_cp = act->new_cp; - act->new_cp = tmp; + std::swap (act->old_cp, act->new_cp); } return prev; diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c index 11288b1b56b..98e2c495333 100644 --- a/gcc/tree-ssa-math-opts.c +++ b/gcc/tree-ssa-math-opts.c @@ -3013,13 +3013,8 @@ is_widening_mult_p (gimple stmt, /* Ensure that the larger of the two operands comes first. */ if (TYPE_PRECISION (*type1_out) < TYPE_PRECISION (*type2_out)) { - tree tmp; - tmp = *type1_out; - *type1_out = *type2_out; - *type2_out = tmp; - tmp = *rhs1_out; - *rhs1_out = *rhs2_out; - *rhs2_out = tmp; + std::swap (*type1_out, *type2_out); + std::swap (*rhs1_out, *rhs2_out); } return true; diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 7c846c2b6e2..09d6f674910 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1911,8 +1911,8 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1, for (gsi = gsi_start_phis (bb3); !gsi_end_p (gsi); gsi_next (&gsi)) { gphi *phi_stmt = gsi.phi (); - gimple def1, def2, defswap; - tree arg1, arg2, ref1, ref2, field1, field2, fieldswap; + gimple def1, def2; + tree arg1, arg2, ref1, ref2, field1, field2; tree tree_offset1, tree_offset2, tree_size2, next; int offset1, offset2, size2; unsigned align1; @@ -1987,12 +1987,8 @@ hoist_adjacent_loads (basic_block bb0, basic_block bb1, if (next != field1) continue; - fieldswap = field1; - field1 = field2; - field2 = fieldswap; - defswap = def1; - def1 = def2; - def2 = defswap; + std::swap (field1, field2); + std::swap (def1, def2); } bb_for_def1 = gimple_bb (def1); diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index f79303b67e4..0c67379a5be 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -4117,8 +4117,6 @@ linearize_expr_tree (vec *ops, gimple stmt, if (!binlhsisreassoc) { - tree temp; - /* If this is not a associative operation like division, give up. */ if (!is_associative) { @@ -4170,9 +4168,7 @@ linearize_expr_tree (vec *ops, gimple stmt, /* We want to make it so the lhs is always the reassociative op, so swap. */ - temp = binlhs; - binlhs = binrhs; - binrhs = temp; + std::swap (binlhs, binrhs); } else if (binrhsisreassoc) { diff --git a/gcc/tree-ssa-threadedge.c b/gcc/tree-ssa-threadedge.c index acbbb671dcc..932b443d2cd 100644 --- a/gcc/tree-ssa-threadedge.c +++ b/gcc/tree-ssa-threadedge.c @@ -544,11 +544,8 @@ simplify_control_stmt_condition (edge e, miss threading opportunities. */ if (tree_swap_operands_p (op0, op1, false)) { - tree tmp; cond_code = swap_tree_comparison (cond_code); - tmp = op0; - op0 = op1; - op1 = tmp; + std::swap (op0, op1); } /* Stuff the operator and operands into our dummy conditional diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index c0b381df648..22587d00bc5 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4556,11 +4556,8 @@ compare_ranges (enum tree_code comp, value_range_t *vr0, value_range_t *vr1, operands around and change the comparison code. */ if (comp == GT_EXPR || comp == GE_EXPR) { - value_range_t *tmp; comp = (comp == GT_EXPR) ? LT_EXPR : LE_EXPR; - tmp = vr0; - vr0 = vr1; - vr1 = tmp; + std::swap (vr0, vr1); } if (comp == EQ_EXPR) diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 460f6e75278..0db43584f02 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -6509,13 +6509,7 @@ add_with_sets (rtx_insn *insn, struct cselib_set *sets, int n_sets) while (n1 < n2 && mos[n2].type != MO_USE) n2--; if (n1 < n2) - { - micro_operation sw; - - sw = mos[n1]; - mos[n1] = mos[n2]; - mos[n2] = sw; - } + std::swap (mos[n1], mos[n2]); } n2 = VTI (bb)->mos.length () - 1; @@ -6526,13 +6520,7 @@ add_with_sets (rtx_insn *insn, struct cselib_set *sets, int n_sets) while (n1 < n2 && mos[n2].type == MO_VAL_LOC) n2--; if (n1 < n2) - { - micro_operation sw; - - sw = mos[n1]; - mos[n1] = mos[n2]; - mos[n2] = sw; - } + std::swap (mos[n1], mos[n2]); } if (CALL_P (insn)) @@ -6568,13 +6556,7 @@ add_with_sets (rtx_insn *insn, struct cselib_set *sets, int n_sets) while (n1 < n2 && mos[n2].type != MO_VAL_USE) n2--; if (n1 < n2) - { - micro_operation sw; - - sw = mos[n1]; - mos[n1] = mos[n2]; - mos[n2] = sw; - } + std::swap (mos[n1], mos[n2]); } n2 = VTI (bb)->mos.length () - 1; @@ -6585,13 +6567,7 @@ add_with_sets (rtx_insn *insn, struct cselib_set *sets, int n_sets) while (n1 < n2 && mos[n2].type != MO_CLOBBER) n2--; if (n1 < n2) - { - micro_operation sw; - - sw = mos[n1]; - mos[n1] = mos[n2]; - mos[n2] = sw; - } + std::swap (mos[n1], mos[n2]); } } @@ -6982,8 +6958,7 @@ vt_find_locations (void) { bb_heap_t *worklist = new bb_heap_t (LONG_MIN); bb_heap_t *pending = new bb_heap_t (LONG_MIN); - bb_heap_t *fibheap_swap = NULL; - sbitmap visited, in_worklist, in_pending, sbitmap_swap; + sbitmap visited, in_worklist, in_pending; basic_block bb; edge e; int *bb_order; @@ -7014,12 +6989,8 @@ vt_find_locations (void) while (success && !pending->empty ()) { - fibheap_swap = pending; - pending = worklist; - worklist = fibheap_swap; - sbitmap_swap = in_pending; - in_pending = in_worklist; - in_worklist = sbitmap_swap; + std::swap (worklist, pending); + std::swap (in_worklist, in_pending); bitmap_clear (visited); -- 2.30.2