Hi all,
This patch replaces manual swapping in synth_mult with std::swap.
Not much else to say about this. This code could arguably be refactored
a bit but that's another story.
I believe these are considered obvious at this point.
I'll apply it in 24 hours unless somebody objects
Tested aarch64-none-elf and bootstrapped on x86_64-linux-gnu.
Thanks,
Kyrill
2015-03-16 Kyrylo Tkachov <kyrylo.tkac...@arm.com>
* expmed.c (synth_mult): Use std::swap instead of manually
swapping algorithms.
commit 20372baa835e35e365117b4e3f6bdc5e28a78a98
Author: Kyrylo Tkachov <kyrylo.tkac...@arm.com>
Date: Thu Mar 12 16:22:58 2015 +0000
[expmed] Use std::swap instead of manual swapping
diff --git a/gcc/expmed.c b/gcc/expmed.c
index d2b2534..e84ab36 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;
}