From: Bin Cheng Date: Fri, 4 Dec 2015 03:26:19 +0000 (+0000) Subject: aarch64.c (aarch64_legitimize_address): legitimize address expressions like Ra +... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e8426e0a22212f9b355364186c9d1748a38b0549;p=gcc.git aarch64.c (aarch64_legitimize_address): legitimize address expressions like Ra + Rb + CONST and Ra + Rb< From-SVN: r231244 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 900119a765a..977f7aed906 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-12-04 Bin Cheng + Jiong Wang + + * config/aarch64/aarch64.c (aarch64_legitimize_address): legitimize + address expressions like Ra + Rb + CONST and Ra + Rb< * alias.c (alias_set_subset_of, alias_sets_must_conflict_p) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index bfbfc2a836d..191ad6debb8 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4823,13 +4823,75 @@ aarch64_legitimize_address (rtx x, rtx /* orig_x */, machine_mode mode) We try to pick as large a range for the offset as possible to maximize the chance of a CSE. However, for aligned addresses we limit the range to 4k so that structures with different sized - elements are likely to use the same base. */ + elements are likely to use the same base. We need to be careful + not to split a CONST for some forms of address expression, otherwise + it will generate sub-optimal code. */ if (GET_CODE (x) == PLUS && CONST_INT_P (XEXP (x, 1))) { HOST_WIDE_INT offset = INTVAL (XEXP (x, 1)); HOST_WIDE_INT base_offset; + if (GET_CODE (XEXP (x, 0)) == PLUS) + { + rtx op0 = XEXP (XEXP (x, 0), 0); + rtx op1 = XEXP (XEXP (x, 0), 1); + + /* Address expressions of the form Ra + Rb + CONST. + + If CONST is within the range supported by the addressing + mode "reg+offset", do not split CONST and use the + sequence + Rt = Ra + Rb; + addr = Rt + CONST. */ + if (REG_P (op0) && REG_P (op1)) + { + machine_mode addr_mode = GET_MODE (x); + rtx base = gen_reg_rtx (addr_mode); + rtx addr = plus_constant (addr_mode, base, offset); + + if (aarch64_legitimate_address_hook_p (mode, addr, false)) + { + emit_insn (gen_adddi3 (base, op0, op1)); + return addr; + } + } + /* Address expressions of the form Ra + Rb< 16 || mode == TImode)