aboutsummaryrefslogtreecommitdiff
path: root/gcc/rtlhooks.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-10-13 09:32:29 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-10-13 09:32:29 +0000
commit90f2b7e220df8ce298b2cd8f853a02aaecdbff0b (patch)
treee6e6b7a6cd37b119b1118babd9d53aa30d191bde /gcc/rtlhooks.c
parent610c45fcbfff43176beefefcea74c6137a432220 (diff)
downloadgcc-90f2b7e220df8ce298b2cd8f853a02aaecdbff0b.zip
gcc-90f2b7e220df8ce298b2cd8f853a02aaecdbff0b.tar.gz
gcc-90f2b7e220df8ce298b2cd8f853a02aaecdbff0b.tar.bz2
Make more use of byte_lowpart_offset
This patch uses byte_lowpart_offset in places that open-coded the calculation. 2017-10-13 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * caller-save.c (replace_reg_with_saved_mem): Use byte_lowpart_offset. * combine.c (gen_lowpart_for_combine): Likewise. * dwarf2out.c (rtl_for_decl_location): Likewise. * final.c (alter_subreg): Likewise. * rtlhooks.c (gen_lowpart_general): Likewise. (gen_lowpart_if_possible): Likewise. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r253714
Diffstat (limited to 'gcc/rtlhooks.c')
-rw-r--r--gcc/rtlhooks.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/gcc/rtlhooks.c b/gcc/rtlhooks.c
index 4d04ebd..d20815e 100644
--- a/gcc/rtlhooks.c
+++ b/gcc/rtlhooks.c
@@ -59,8 +59,6 @@ gen_lowpart_general (machine_mode mode, rtx x)
}
else
{
- int offset = 0;
-
/* The only additional case we can do is MEM. */
gcc_assert (MEM_P (x));
@@ -72,16 +70,7 @@ gen_lowpart_general (machine_mode mode, rtx x)
&& !reload_completed)
return gen_lowpart_general (mode, force_reg (xmode, x));
- if (WORDS_BIG_ENDIAN)
- offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
- - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
-
- if (BYTES_BIG_ENDIAN)
- /* Adjust the address so that the address-after-the-data
- is unchanged. */
- offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
- - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
-
+ HOST_WIDE_INT offset = byte_lowpart_offset (mode, GET_MODE (x));
return adjust_address (x, mode, offset);
}
}
@@ -126,19 +115,8 @@ gen_lowpart_if_possible (machine_mode mode, rtx x)
else if (MEM_P (x))
{
/* This is the only other case we handle. */
- int offset = 0;
- rtx new_rtx;
-
- if (WORDS_BIG_ENDIAN)
- offset = (MAX (GET_MODE_SIZE (GET_MODE (x)), UNITS_PER_WORD)
- - MAX (GET_MODE_SIZE (mode), UNITS_PER_WORD));
- if (BYTES_BIG_ENDIAN)
- /* Adjust the address so that the address-after-the-data is
- unchanged. */
- offset -= (MIN (UNITS_PER_WORD, GET_MODE_SIZE (mode))
- - MIN (UNITS_PER_WORD, GET_MODE_SIZE (GET_MODE (x))));
-
- new_rtx = adjust_address_nv (x, mode, offset);
+ HOST_WIDE_INT offset = byte_lowpart_offset (mode, GET_MODE (x));
+ rtx new_rtx = adjust_address_nv (x, mode, offset);
if (! memory_address_addr_space_p (mode, XEXP (new_rtx, 0),
MEM_ADDR_SPACE (x)))
return 0;