public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kyrill Tkachov <kyrylo.tkachov@arm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>,
	 Richard Earnshaw <Richard.Earnshaw@arm.com>
Subject: [PATCH][ARM][cleanup] Use std::sort rather than manually sorting in gen_ldm_seq
Date: Tue, 14 Apr 2015 12:39:00 -0000	[thread overview]
Message-ID: <552D0A6E.6080302@arm.com> (raw)

[-- 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)

                 reply	other threads:[~2015-04-14 12:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=552D0A6E.6080302@arm.com \
    --to=kyrylo.tkachov@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ramana.radhakrishnan@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).