From: jgreenhalgh Date: Fri, 16 May 2014 09:07:34 +0000 (+0000) Subject: [AArch64 costs 12/18] Improve costs for sign/zero extracts X-Git-Tag: accepted/tizen/3.0.2015.q2/common/20150615.160009~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6db0238926987ba3dc0dd7a0d791ed64ce087a14;p=platform%2Fupstream%2Fgcc49.git [AArch64 costs 12/18] Improve costs for sign/zero extracts git cherry-pick d515bbc gcc/ * config/aarch64/aarch64.c (aarch64_rtx_costs): Improve costs for SIGN/ZERO_EXTRACT. Change-Id: Ica7dd6d1721d38e1f8049d7be25db024ac7ed7b5 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210504 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b318f21..de89b7e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-03-16 James Greenhalgh + Philipp Tomsich + + * config/aarch64/aarch64.c (aarch64_rtx_arith_op_extract_p): New. + (aarch64_rtx_costs): Improve costs for SIGN/ZERO_EXTRACT. + 2014-05-16 James Greenhalgh Philipp Tomsich diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index ac7de2d..f687194 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4783,6 +4783,35 @@ aarch64_address_cost (rtx x, return cost; } +/* Return true if the RTX X in mode MODE is a zero or sign extract + usable in an ADD or SUB (extended register) instruction. */ +static bool +aarch64_rtx_arith_op_extract_p (rtx x, enum machine_mode mode) +{ + /* Catch add with a sign extract. + This is add__multp2. */ + if (GET_CODE (x) == SIGN_EXTRACT + || GET_CODE (x) == ZERO_EXTRACT) + { + rtx op0 = XEXP (x, 0); + rtx op1 = XEXP (x, 1); + rtx op2 = XEXP (x, 2); + + if (GET_CODE (op0) == MULT + && CONST_INT_P (op1) + && op2 == const0_rtx + && CONST_INT_P (XEXP (op0, 1)) + && aarch64_is_extend_from_extract (mode, + XEXP (op0, 1), + op1)) + { + return true; + } + } + + return false; +} + /* Calculate the cost of calculating X, storing it in *COST. Result is true if the total cost of the operation has now been calculated. */ static bool @@ -5047,6 +5076,18 @@ cost_minus: } + /* Look for SUB (extended register). */ + if (aarch64_rtx_arith_op_extract_p (op1, mode)) + { + if (speed) + *cost += extra_cost->alu.arith_shift; + + *cost += rtx_cost (XEXP (XEXP (op1, 0), 0), + (enum rtx_code) GET_CODE (op1), + 0, speed); + return true; + } + rtx new_op1 = aarch64_strip_extend (op1); /* Cost this as an FMA-alike operation. */ @@ -5103,6 +5144,18 @@ cost_minus: return true; } + /* Look for ADD (extended register). */ + if (aarch64_rtx_arith_op_extract_p (op0, mode)) + { + if (speed) + *cost += extra_cost->alu.arith_shift; + + *cost += rtx_cost (XEXP (XEXP (op0, 0), 0), + (enum rtx_code) GET_CODE (op0), + 0, speed); + return true; + } + /* Strip any extend, leave shifts behind as we will cost them through mult_cost. */ new_op0 = aarch64_strip_extend (op0); @@ -5338,7 +5391,13 @@ cost_minus: case ZERO_EXTRACT: case SIGN_EXTRACT: - *cost += rtx_cost (XEXP (x, 0), ZERO_EXTRACT, 0, speed); + /* UBFX/SBFX. */ + if (speed) + *cost += extra_cost->alu.bfx; + + /* We can trust that the immediates used will be correct (there + are no by-register forms), so we need only cost op0. */ + *cost += rtx_cost (XEXP (x, 0), (enum rtx_code) code, 0, speed); return true; case MULT: @@ -9145,7 +9204,7 @@ aarch64_cannot_change_mode_class (enum machine_mode from, #define TARGET_RETURN_IN_MSB aarch64_return_in_msb #undef TARGET_RTX_COSTS -#define TARGET_RTX_COSTS aarch64_rtx_costs +#define TARGET_RTX_COSTS aarch64_rtx_costs_wrapper #undef TARGET_SCHED_ISSUE_RATE #define TARGET_SCHED_ISSUE_RATE aarch64_sched_issue_rate