public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: James Greenhalgh <james.greenhalgh@arm.com>
To: <gcc-patches@gcc.gnu.org>
Cc: <nd@arm.com>, <bin.cheng@arm.com>, <marcus.shawrcroft@arm.com>,
	<richard.earnshaw@arm.com>
Subject: [Patch AArch64 2/2] Some more cleanup of ldp/stp generation
Date: Tue, 17 May 2016 09:23:00 -0000	[thread overview]
Message-ID: <1463476951-1567-3-git-send-email-james.greenhalgh@arm.com> (raw)
In-Reply-To: <1463476951-1567-1-git-send-email-james.greenhalgh@arm.com>

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


This is another refactoring patch to clean up more of the ldp/stp handling
code and avoid duplicating quite as much code.

Much like the other refactoring patch, this reduces the use of reg_1, reg_2,
etc. leading to a cleaner implementation.

Bootstrapped on AArch64 with no issues.

OK?

Thanks,
James

---
2016-05-17  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/aarch64/aarch64.c (aarch64_gen_adjusted_ldpstp): Refactor.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-Patch-AArch64-2-2-Some-more-cleanup-of-ldp-stp-gener.patch --]
[-- Type: text/x-patch;  name=0002-Patch-AArch64-2-2-Some-more-cleanup-of-ldp-stp-gener.patch, Size: 3761 bytes --]

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 434c154..01bbe81 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -13549,26 +13549,18 @@ aarch64_gen_adjusted_ldpstp (rtx *operands, bool load,
 			     enum machine_mode mode, RTX_CODE code)
 {
   rtx base, offset, t1, t2;
-  rtx mem_1, mem_2, mem_3, mem_4;
+  rtx mem[4];
   HOST_WIDE_INT off_val, abs_off, adj_off, new_off, stp_off_limit, msize;
 
-  if (load)
-    {
-      mem_1 = operands[1];
-      mem_2 = operands[3];
-      mem_3 = operands[5];
-      mem_4 = operands[7];
-    }
-  else
-    {
-      mem_1 = operands[0];
-      mem_2 = operands[2];
-      mem_3 = operands[4];
-      mem_4 = operands[6];
-      gcc_assert (code == UNKNOWN);
-    }
+  unsigned op_offset = load ? 1 : 0;
+
+  for (int i = 0; i < 4; i++)
+    mem[i] = operands[(2 * i) + op_offset];
 
-  extract_base_offset_in_addr (mem_1, &base, &offset);
+  if (!load)
+    gcc_assert (code == UNKNOWN);
+
+  extract_base_offset_in_addr (mem[0], &base, &offset);
   gcc_assert (base != NULL_RTX && offset != NULL_RTX);
 
   /* Adjust offset thus it can fit in ldp/stp instruction.  */
@@ -13597,59 +13589,32 @@ aarch64_gen_adjusted_ldpstp (rtx *operands, bool load,
     }
 
   /* Create new memory references.  */
-  mem_1 = change_address (mem_1, VOIDmode,
-			  plus_constant (DImode, operands[8], new_off));
+  mem[0] = change_address (mem[0], VOIDmode,
+			  plus_constant (Pmode, operands[8], new_off));
 
   /* Check if the adjusted address is OK for ldp/stp.  */
-  if (!aarch64_mem_pair_operand (mem_1, mode))
+  if (!aarch64_mem_pair_operand (mem[0], mode))
     return false;
 
   msize = GET_MODE_SIZE (mode);
-  mem_2 = change_address (mem_2, VOIDmode,
-			  plus_constant (DImode,
-					 operands[8],
-					 new_off + msize));
-  mem_3 = change_address (mem_3, VOIDmode,
-			  plus_constant (DImode,
-					 operands[8],
-					 new_off + msize * 2));
-  mem_4 = change_address (mem_4, VOIDmode,
-			  plus_constant (DImode,
-					 operands[8],
-					 new_off + msize * 3));
-
-  if (code == ZERO_EXTEND)
-    {
-      mem_1 = gen_rtx_ZERO_EXTEND (DImode, mem_1);
-      mem_2 = gen_rtx_ZERO_EXTEND (DImode, mem_2);
-      mem_3 = gen_rtx_ZERO_EXTEND (DImode, mem_3);
-      mem_4 = gen_rtx_ZERO_EXTEND (DImode, mem_4);
-    }
-  else if (code == SIGN_EXTEND)
-    {
-      mem_1 = gen_rtx_SIGN_EXTEND (DImode, mem_1);
-      mem_2 = gen_rtx_SIGN_EXTEND (DImode, mem_2);
-      mem_3 = gen_rtx_SIGN_EXTEND (DImode, mem_3);
-      mem_4 = gen_rtx_SIGN_EXTEND (DImode, mem_4);
-    }
 
-  if (load)
-    {
-      operands[1] = mem_1;
-      operands[3] = mem_2;
-      operands[5] = mem_3;
-      operands[7] = mem_4;
-    }
-  else
-    {
-      operands[0] = mem_1;
-      operands[2] = mem_2;
-      operands[4] = mem_3;
-      operands[6] = mem_4;
-    }
+  for (int i = 1; i < 4; i++)
+    mem[i] = change_address (mem[i], VOIDmode,
+			     plus_constant (Pmode,
+					    operands[8],
+					    new_off + (msize * i)));
+
+  for (int i = 0; i < 4; i++)
+    if (code == ZERO_EXTEND)
+      mem[i] = gen_rtx_ZERO_EXTEND (Pmode, mem[i]);
+    else if (code == SIGN_EXTEND)
+      mem[i] = gen_rtx_SIGN_EXTEND (Pmode, mem[i]);
+
+  for (int i = 0; i < 4; i++)
+    operands[(2 * i) + op_offset] = mem[i];
 
   /* Emit adjusting instruction.  */
-  emit_insn (gen_rtx_SET (operands[8], plus_constant (DImode, base, adj_off)));
+  emit_insn (gen_rtx_SET (operands[8], plus_constant (Pmode, base, adj_off)));
   /* Emit ldp/stp instructions.  */
   t1 = gen_rtx_SET (operands[0], operands[1]);
   t2 = gen_rtx_SET (operands[2], operands[3]);

  reply	other threads:[~2016-05-17  9:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17  9:23 [Patch AArch64 0/2] Refactor ldp/stp code James Greenhalgh
2016-05-17  9:23 ` James Greenhalgh [this message]
2016-06-03  8:46   ` [Patch AArch64 2/2] Some more cleanup of ldp/stp generation James Greenhalgh
2016-05-17  9:23 ` [AArch64 1/2] Refactor aarch64_operands_ok_for_ldpstp, aarch64_operands_adjust_ok_for_ldpstp James Greenhalgh
2016-06-03  8:45   ` James Greenhalgh
2016-06-03  8:59   ` Kyrill Tkachov

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=1463476951-1567-3-git-send-email-james.greenhalgh@arm.com \
    --to=james.greenhalgh@arm.com \
    --cc=bin.cheng@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=marcus.shawrcroft@arm.com \
    --cc=nd@arm.com \
    --cc=richard.earnshaw@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).