public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][AARCH64]Use mov for add with large immediate.
@ 2015-04-21 16:10 Renlin Li
  2015-05-01 10:19 ` Marcus Shawcroft
  0 siblings, 1 reply; 4+ messages in thread
From: Renlin Li @ 2015-04-21 16:10 UTC (permalink / raw)
  To: gcc-patches; +Cc: Marcus Shawcroft, Ramana.Radhakrishnan

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

Hi all,

This is a simple patch to generate a move instruction to temporarily 
hold the large immediate for a add instruction.

GCC regression test has been run using aarch64-none-elf toolchain. NO 
new issues.

Okay for trunk?

Regards,
Renlin Li

gcc/ChangeLog:

2015-04-21  Renlin Li  <renlin.li@arm.com>

     * config/aarch64/aarch64.md (add<mode>3): Use mov when allowed.

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

diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 1f4169e..9ea1939 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -1414,18 +1414,28 @@
   "
   if (! aarch64_plus_operand (operands[2], VOIDmode))
     {
-      rtx subtarget = ((optimize && can_create_pseudo_p ())
-		       ? gen_reg_rtx (<MODE>mode) : operands[0]);
       HOST_WIDE_INT imm = INTVAL (operands[2]);
-
-      if (imm < 0)
-	imm = -(-imm & ~0xfff);
+      if (aarch64_move_imm (imm, <MODE>mode)
+	  && can_create_pseudo_p ())
+      {
+	rtx tmp = gen_reg_rtx (<MODE>mode);
+	emit_move_insn (tmp, operands[2]);
+	operands[2] = tmp;
+      }
       else
-        imm &= ~0xfff;
+      {
+	rtx subtarget = ((optimize && can_create_pseudo_p ())
+			 ? gen_reg_rtx (<MODE>mode) : operands[0]);
+
+	if (imm < 0)
+	  imm = -(-imm & ~0xfff);
+	else
+	  imm &= ~0xfff;
 
-      emit_insn (gen_add<mode>3 (subtarget, operands[1], GEN_INT (imm)));
-      operands[1] = subtarget;
-      operands[2] = GEN_INT (INTVAL (operands[2]) - imm);
+	emit_insn (gen_add<mode>3 (subtarget, operands[1], GEN_INT (imm)));
+	operands[1] = subtarget;
+	operands[2] = GEN_INT (INTVAL (operands[2]) - imm);
+      }
     }
   "
 )

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

* Re: [PATCH][AARCH64]Use mov for add with large immediate.
  2015-04-21 16:10 [PATCH][AARCH64]Use mov for add with large immediate Renlin Li
@ 2015-05-01 10:19 ` Marcus Shawcroft
  2015-05-01 15:30   ` Renlin Li
  0 siblings, 1 reply; 4+ messages in thread
From: Marcus Shawcroft @ 2015-05-01 10:19 UTC (permalink / raw)
  To: Renlin Li; +Cc: gcc-patches

On 21 April 2015 at 17:10, Renlin Li <renlin.li@arm.com> wrote:
> Hi all,
>
> This is a simple patch to generate a move instruction to temporarily hold
> the large immediate for a add instruction.
>
> GCC regression test has been run using aarch64-none-elf toolchain. NO new
> issues.
>
> Okay for trunk?
>
> Regards,
> Renlin Li
>
> gcc/ChangeLog:
>
> 2015-04-21  Renlin Li  <renlin.li@arm.com>
>
>     * config/aarch64/aarch64.md (add<mode>3): Use mov when allowed.

A couple style nits:

       HOST_WIDE_INT imm = INTVAL (operands[2]);
-
-      if (imm < 0)

Don't remove the blank line between declarations and the first statement.

+      if (aarch64_move_imm (imm, <MODE>mode)
+  && can_create_pseudo_p ())
+      {

The indentation of { should conform to the gnu style guide.

It also  looks to me that  an unbroken line will fit within the 80
column limit, hence the break before && is unnecessary.

Cheers
/Marcus

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

* Re: [PATCH][AARCH64]Use mov for add with large immediate.
  2015-05-01 10:19 ` Marcus Shawcroft
@ 2015-05-01 15:30   ` Renlin Li
  2015-05-01 15:41     ` Marcus Shawcroft
  0 siblings, 1 reply; 4+ messages in thread
From: Renlin Li @ 2015-05-01 15:30 UTC (permalink / raw)
  To: Marcus Shawcroft; +Cc: gcc-patches

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

Hi Marcus,

On 01/05/15 11:19, Marcus Shawcroft wrote:
> On 21 April 2015 at 17:10, Renlin Li <renlin.li@arm.com> wrote:
>> Hi all,
>>
>> This is a simple patch to generate a move instruction to temporarily hold
>> the large immediate for a add instruction.
>>
>> GCC regression test has been run using aarch64-none-elf toolchain. NO new
>> issues.
>>
>> Okay for trunk?
>>
>> Regards,
>> Renlin Li
>>
>> gcc/ChangeLog:
>>
>> 2015-04-21  Renlin Li  <renlin.li@arm.com>
>>
>>      * config/aarch64/aarch64.md (add<mode>3): Use mov when allowed.
> A couple style nits:
>
>         HOST_WIDE_INT imm = INTVAL (operands[2]);
> -
> -      if (imm < 0)
>
> Don't remove the blank line between declarations and the first statement.
>
> +      if (aarch64_move_imm (imm, <MODE>mode)
> +  && can_create_pseudo_p ())
> +      {
>
> The indentation of { should conform to the gnu style guide.
>
> It also  looks to me that  an unbroken line will fit within the 80
> column limit, hence the break before && is unnecessary.

Thank you, Marcus. I have updated the patch accordingly, please check..

Regards,
Renlin Li

>
> Cheers
> /Marcus
>

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

diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 429c5ba..d0ceafa 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -1414,18 +1414,28 @@
   "
   if (! aarch64_plus_operand (operands[2], VOIDmode))
     {
-      rtx subtarget = ((optimize && can_create_pseudo_p ())
-		       ? gen_reg_rtx (<MODE>mode) : operands[0]);
       HOST_WIDE_INT imm = INTVAL (operands[2]);
 
-      if (imm < 0)
-	imm = -(-imm & ~0xfff);
+      if (aarch64_move_imm (imm, <MODE>mode) && can_create_pseudo_p ())
+        {
+	  rtx tmp = gen_reg_rtx (<MODE>mode);
+	  emit_move_insn (tmp, operands[2]);
+	  operands[2] = tmp;
+        }
       else
-        imm &= ~0xfff;
-
-      emit_insn (gen_add<mode>3 (subtarget, operands[1], GEN_INT (imm)));
-      operands[1] = subtarget;
-      operands[2] = GEN_INT (INTVAL (operands[2]) - imm);
+        {
+	  rtx subtarget = ((optimize && can_create_pseudo_p ())
+			   ? gen_reg_rtx (<MODE>mode) : operands[0]);
+
+	  if (imm < 0)
+	    imm = -(-imm & ~0xfff);
+	  else
+	    imm &= ~0xfff;
+
+	  emit_insn (gen_add<mode>3 (subtarget, operands[1], GEN_INT (imm)));
+	  operands[1] = subtarget;
+	  operands[2] = GEN_INT (INTVAL (operands[2]) - imm);
+        }
     }
   "
 )

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

* Re: [PATCH][AARCH64]Use mov for add with large immediate.
  2015-05-01 15:30   ` Renlin Li
@ 2015-05-01 15:41     ` Marcus Shawcroft
  0 siblings, 0 replies; 4+ messages in thread
From: Marcus Shawcroft @ 2015-05-01 15:41 UTC (permalink / raw)
  To: Renlin Li; +Cc: gcc-patches

On 1 May 2015 at 16:30, Renlin Li <renlin.li@arm.com> wrote:

> Thank you, Marcus. I have updated the patch accordingly, please check..
>
> Regards,
> Renlin Li

OK, thanks /Marcus

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

end of thread, other threads:[~2015-05-01 15:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-21 16:10 [PATCH][AARCH64]Use mov for add with large immediate Renlin Li
2015-05-01 10:19 ` Marcus Shawcroft
2015-05-01 15:30   ` Renlin Li
2015-05-01 15:41     ` Marcus Shawcroft

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