Patchwork [AArch64,2/2] Add rtx cost function handling of clz, clrsb, rbit

login
register
mail settings
Submitter Kyrylo Tkachov
Date July 22, 2014, 11:23 a.m.
Message ID <53CE49BD.9080009@arm.com>
Download mbox | patch
Permalink /patch/372442/
State New
Headers show

Comments

Kyrylo Tkachov - July 22, 2014, 11:23 a.m.
Hi all,

Following up on patch "[1/2] Remove UNSPEC_CLS and use clrsb RTL code in its' place" this patch adds rtx costs handling of the CLZ, CLRSB RTL codes as well as the UNSPEC_RBIT unspec.

The CLZ and CLRSB cases are handled identically (they are implemented by the clz and cls instructions respectively).

Bootstrapped and tested on aarch64-linux.

Ok for trunk?

Thanks,
Kyrill


2014-07-22  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

	* config/aarch64/aarch64.c (aarch64_rtx_costs): Handle CLRSB, CLZ.
	(case UNSPEC): Handle UNSPEC_RBIT.
Marcus Shawcroft - July 22, 2014, 1:25 p.m.
On 22 July 2014 12:23, Kyrill Tkachov <kyrylo.tkachov@arm.com> wrote:
> Hi all,
>
> Following up on patch "[1/2] Remove UNSPEC_CLS and use clrsb RTL code in
> its' place" this patch adds rtx costs handling of the CLZ, CLRSB RTL codes
> as well as the UNSPEC_RBIT unspec.
>
> The CLZ and CLRSB cases are handled identically (they are implemented by the
> clz and cls instructions respectively).
>
> Bootstrapped and tested on aarch64-linux.
>
> Ok for trunk?

OK /Marcus

Patch

commit 8f54ebbfb9622dc53c30db11fdcd4d4602aa9d69
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Tue Jul 15 15:10:19 2014 +0100

    [AArch64] RTX cost handling for clz, rbit, cls

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 9f42e20..7f67b6a 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5154,6 +5154,13 @@  aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED,
 
       return false;
 
+    case CLRSB:
+    case CLZ:
+      if (speed)
+        *cost += extra_cost->alu.clz;
+
+      return false;
+
     case COMPARE:
       op0 = XEXP (x, 0);
       op1 = XEXP (x, 1);
@@ -5799,6 +5806,14 @@  cost_plus:
 
           return false;
         }
+
+      if (XINT (x, 1) == UNSPEC_RBIT)
+        {
+          if (speed)
+            *cost += extra_cost->alu.rev;
+
+          return false;
+        }
       break;
 
     case TRUNCATE: