This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][AArch64] Properly cost sign_extend+ashiftrt version of sbfx


Hi all,

One of the pattens that maps to an sbfx instruction is *extend<GPI:mode>_ashr<SHORT:mode> which is a sign-extend of a shift-right operation.
This is not handled in the rtx costs for sign-extend. This patch adds handling of that form.

Bootstrapped and tested on aarch64-linux.

Ok for trunk?

Thanks,
Kyrill

2015-05-01  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

    * config/aarch64/aarch64.c (aarch64_rtx_costs, SIGN_EXTEND case):
    Handle sign_extend-ashiftrt form of sbfx.
commit 06e8a74a8e6194095bd53618caf2f5845a32419c
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Mon Mar 2 17:39:20 2015 +0000

    [AArch64] Properly cost sign_extend+ashiftrt version of sbfx

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ed8dc4d..0345b93 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -6190,6 +6190,26 @@ cost_plus:
 	  return true;
 	}
 
+      if (GET_CODE (XEXP (x, 0)) == ASHIFTRT)
+        {
+           /* SBFX.  */
+           machine_mode shft_mode = GET_MODE (XEXP (x, 0));
+
+           op0 = XEXP (XEXP (x, 0), 0);
+           op1 = XEXP (XEXP (x, 0), 1);
+
+           if (CONST_INT_P (op1)
+               && UINTVAL (op1) < GET_MODE_BITSIZE (shft_mode))
+             {
+               *cost += rtx_cost (op0, ASHIFTRT, 0, speed);
+
+               if (speed)
+                 *cost += extra_cost->alu.bfx;
+
+               return true;
+             }
+        }
+
       if (speed)
 	*cost += extra_cost->alu.extend;
       return false;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]