From 076701b69d3a1f02e46df451ab9cb092863e5baa Mon Sep 17 00:00:00 2001 From: Kyrylo Tkachov Date: Wed, 18 Mar 2015 12:01:24 +0000 Subject: [PATCH] [expmed][cleanup] Use std::swap instead of manual swapping * expmed.c (synth_mult): Use std::swap instead of manually swapping algorithms. From-SVN: r221486 --- gcc/ChangeLog | 5 +++++ gcc/expmed.c | 27 +++++++++------------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 77abe6739f9..d2ff5c0a5f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-03-18 Kyrylo Tkachov + + * expmed.c (synth_mult): Use std::swap instead of manually + swapping algorithms. + 2015-03-18 Jakub Jelinek PR target/65078 diff --git a/gcc/expmed.c b/gcc/expmed.c index 0034203c2f7..8d4f9640934 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -2551,9 +2551,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_shift; } @@ -2582,9 +2581,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_shift; } @@ -2624,9 +2622,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = 0; best_alg->op[best_alg->ops] = alg_sub_t_m2; } @@ -2644,9 +2641,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = 0; best_alg->op[best_alg->ops] = alg_add_t_m2; } @@ -2667,9 +2663,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_sub_t_m2; } @@ -2723,9 +2718,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency = op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_add_factor; } @@ -2762,9 +2756,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency = op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_sub_factor; } @@ -2793,9 +2786,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_add_t2_m; } @@ -2818,9 +2810,8 @@ synth_mult (struct algorithm *alg_out, unsigned HOST_WIDE_INT t, alg_in->cost.latency += op_cost; if (CHEAPER_MULT_COST (&alg_in->cost, &best_cost)) { - struct algorithm *x; best_cost = alg_in->cost; - x = alg_in, alg_in = best_alg, best_alg = x; + std::swap (alg_in, best_alg); best_alg->log[best_alg->ops] = m; best_alg->op[best_alg->ops] = alg_sub_t2_m; } -- 2.30.2