diff mbox

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

Message ID 552D0A6E.6080302@arm.com
State New
Headers show

Commit Message

Kyrylo Tkachov April 14, 2015, 12:39 p.m. UTC
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.
diff mbox

Patch

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)