diff mbox

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

Message ID 53CE49BD.9080009@arm.com
State New
Headers show

Commit Message

Kyrylo Tkachov July 22, 2014, 11:23 a.m. UTC
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.

Comments

Marcus Shawcroft July 22, 2014, 1:25 p.m. UTC | #1
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
diff mbox

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: