@@ -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;
}
@@ -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)
{
@@ -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;
}
@@ -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)))
@@ -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)
@@ -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;
@@ -457,7 +457,7 @@ fibonacci_heap<K,V>::union_with (fibonacci_heap<K,V> *heapb)
{
fibonacci_heap<K,V> *heapa = this;
- fibonacci_node<K,V> *a_root, *b_root, *temp;
+ fibonacci_node<K,V> *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,10 +474,7 @@ fibonacci_heap<K,V>::union_with (fibonacci_heap<K,V> *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;
- heapa->m_nodes += heapb->m_nodes;
+ std::swap (a_root->m_left, b_root->m_left);
/* And set the new minimum, if it's changed. */
if (heapb->min->compare (heapa->min) < 0)
@@ -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;
}
@@ -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);
}
}
@@ -2562,7 +2562,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;
@@ -3025,13 +3025,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++)
@@ -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])
@@ -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... */
@@ -1600,11 +1600,7 @@ emit_mode_int_n (void)
for (i = 0; i<n_modes - 1; i++)
for (j = i + 1; j < n_modes; j++)
if (mode_sort[i]->int_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 ++)
{
@@ -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);
}
}
@@ -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
@@ -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]);
}
}
@@ -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);
@@ -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);
@@ -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);
}
@@ -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))
@@ -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);
}
@@ -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
@@ -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]);
}
}
@@ -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,14 @@ 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;
+ std::swap (preferred_class[commutative],
+ preferred_class[commutative + 1]);
- t = pref_or_nothing[commutative];
- pref_or_nothing[commutative] = pref_or_nothing[commutative + 1];
- pref_or_nothing[commutative + 1] = t;
+ std::swap (pref_or_nothing[commutative],
+ pref_or_nothing[commutative + 1]);
- t = address_reloaded[commutative];
- address_reloaded[commutative] = address_reloaded[commutative + 1];
- address_reloaded[commutative + 1] = t;
+ std::swap (address_reloaded[commutative],
+ address_reloaded[commutative + 1]);
}
this_earlyclobber = 0;
@@ -3833,17 +3827,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 +3881,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++)
{
@@ -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);
@@ -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)));
}
}
}
@@ -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]);
}
}
}
@@ -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);
}
@@ -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;
@@ -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;
@@ -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;
@@ -1911,7 +1911,7 @@ 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;
+ gimple def1, def2;
tree arg1, arg2, ref1, ref2, field1, field2, fieldswap;
tree tree_offset1, tree_offset2, tree_size2, next;
int offset1, offset2, size2;
@@ -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);
@@ -4117,8 +4117,6 @@ linearize_expr_tree (vec<operand_entry_t> *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<operand_entry_t> *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)
{
@@ -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
@@ -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)
@@ -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);