public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][ARM][cleanup] Use std::sort rather than manually sorting in gen_ldm_seq
@ 2015-04-14 12:39 Kyrill Tkachov
  0 siblings, 0 replies; only message in thread
From: Kyrill Tkachov @ 2015-04-14 12:39 UTC (permalink / raw)
  To: GCC Patches; +Cc: Ramana Radhakrishnan, Richard Earnshaw

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

Hi all,

This patch replaces a manual ascending-order sort by a call to std::sort.
This makes the code simpler and more readable IMHO.

Bootstrapped and tested on arm.

Ok for trunk?

Thanks,
Kyrill

2015-04-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     * config/arm/arm.c (gen_ldm_seq): Use std::sort instead of sorting
     manually.

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

commit 1c51dda9a66fc997ab0ab1e4de66ff861b4a9545
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Wed Mar 18 14:53:13 2015 +0000

    [ARM][cleanup] Use std::sort rather than manually sorting in gen_ldm_seq

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 2925e09..21409a0 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -14407,7 +14407,7 @@ gen_ldm_seq (rtx *operands, int nops, bool sort_regs)
 {
   int regs[MAX_LDM_STM_OPS], mem_order[MAX_LDM_STM_OPS];
   rtx mems[MAX_LDM_STM_OPS];
-  int i, j, base_reg;
+  int i, base_reg;
   rtx base_reg_rtx;
   HOST_WIDE_INT offset;
   int write_back = FALSE;
@@ -14421,14 +14421,8 @@ gen_ldm_seq (rtx *operands, int nops, bool sort_regs)
     return false;
 
   if (sort_regs)
-    for (i = 0; i < nops - 1; i++)
-      for (j = i + 1; j < nops; j++)
-	if (regs[i] > regs[j])
-	  {
-	    int t = regs[i];
-	    regs[i] = regs[j];
-	    regs[j] = t;
-	  }
+    std::sort (regs, regs + nops);
+
   base_reg_rtx = gen_rtx_REG (Pmode, base_reg);
 
   if (TARGET_THUMB1)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-14 12:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-14 12:39 [PATCH][ARM][cleanup] Use std::sort rather than manually sorting in gen_ldm_seq 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).