[AArch64] Fix cost of (plus ... (const_int -C))

The PLUS handling in aarch64_rtx_costs only checked for nonnegative
constants, meaning that simple immediate subtractions like:

  (set (reg R1) (plus (reg R2) (const_int -8)))

had a cost of two instructions.

2019-09-26  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* config/aarch64/aarch64.c (aarch64_rtx_costs): Use
	aarch64_plus_immediate rather than aarch64_uimm12_shift
	to test for valid PLUS immediates.

From-SVN: r276140
This commit is contained in:
Richard Sandiford 2019-09-26 07:38:21 +00:00 committed by Richard Sandiford
parent ec14f8abf0
commit 835d50c66a
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2019-09-26 Richard Sandiford <richard.sandiford@arm.com>
* config/aarch64/aarch64.c (aarch64_rtx_costs): Use
aarch64_plus_immediate rather than aarch64_uimm12_shift
to test for valid PLUS immediates.
2019-09-25 Martin Jambor <mjambor@suse.cz>
* tree-sra.c (no_accesses_p): Remove.

View File

@ -10753,7 +10753,7 @@ cost_plus:
}
if (GET_MODE_CLASS (mode) == MODE_INT
&& ((CONST_INT_P (op1) && aarch64_uimm12_shift (INTVAL (op1)))
&& (aarch64_plus_immediate (op1, mode)
|| aarch64_sve_addvl_addpl_immediate (op1, mode)))
{
*cost += rtx_cost (op0, mode, PLUS, 0, speed);