public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][expmed][cleanup] Use std::swap instead of manual swapping
@ 2015-03-16 10:11 Kyrill Tkachov
  2015-03-18 12:02 ` Kyrill Tkachov
  0 siblings, 1 reply; 2+ messages in thread
From: Kyrill Tkachov @ 2015-03-16 10:11 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

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.tkachov@arm.com>

     * expmed.c (synth_mult): Use std::swap instead of manually
     swapping algorithms.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: expmed-swap.patch --]
[-- Type: text/x-patch; name=expmed-swap.patch, Size: 4378 bytes --]

commit 20372baa835e35e365117b4e3f6bdc5e28a78a98
Author: Kyrylo Tkachov <kyrylo.tkachov@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;
 	    }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][expmed][cleanup] Use std::swap instead of manual swapping
  2015-03-16 10:11 [PATCH][expmed][cleanup] Use std::swap instead of manual swapping Kyrill Tkachov
@ 2015-03-18 12:02 ` Kyrill Tkachov
  0 siblings, 0 replies; 2+ messages in thread
From: Kyrill Tkachov @ 2015-03-18 12:02 UTC (permalink / raw)
  To: GCC Patches


On 16/03/15 10:10, Kyrill Tkachov wrote:
> 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

Committed with r221486 after re-bootstrapping on x86_64-linux-gnu.

Kyrill
>
> Tested aarch64-none-elf and bootstrapped on x86_64-linux-gnu.
>
> Thanks,
> Kyrill
>
> 2015-03-16  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
>
>       * expmed.c (synth_mult): Use std::swap instead of manually
>       swapping algorithms.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-18 12:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 10:11 [PATCH][expmed][cleanup] Use std::swap instead of manual swapping Kyrill Tkachov
2015-03-18 12:02 ` Kyrill Tkachov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).