* Make more use of subreg_size_lowpart_offset
@ 2017-08-23 10:56 Richard Sandiford
2017-10-12 18:21 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2017-08-23 10:56 UTC (permalink / raw)
To: gcc-patches
This patch uses subreg_size_lowpart_offset in places that open-coded
the calculation. The reload use (and the LRA one that was based on it)
seemed to ignore the BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case; it's not
obvious whether that was deliberate or an oversight.
Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure
that there were no differences in testsuite assembly output for one
target per CPU. OK to install?
Richard
2017-08-23 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* lra-spills.c (assign_mem_slot): Use subreg_size_lowpart_offset.
* regcprop.c (maybe_mode_change): Likewise.
* reload1.c (alter_reg): Likewise.
Index: gcc/lra-spills.c
===================================================================
--- gcc/lra-spills.c 2017-05-18 07:51:05.680420976 +0100
+++ gcc/lra-spills.c 2017-08-23 10:46:45.029672093 +0100
@@ -153,9 +153,7 @@ assign_mem_slot (int i)
/* On a big endian machine, the "address" of the slot is the address
of the low part that fits its inherent mode. */
- if (BYTES_BIG_ENDIAN && inherent_size < total_size)
- adjust += (total_size - inherent_size);
-
+ adjust += subreg_size_lowpart_offset (inherent_size, total_size);
x = adjust_address_nv (x, GET_MODE (regno_reg_rtx[i]), adjust);
/* Set all of the memory attributes as appropriate for a spill. */
Index: gcc/regcprop.c
===================================================================
--- gcc/regcprop.c 2017-08-23 10:46:06.553156355 +0100
+++ gcc/regcprop.c 2017-08-23 10:46:45.029672093 +0100
@@ -410,13 +410,9 @@ maybe_mode_change (machine_mode orig_mod
int use_nregs = hard_regno_nregs[copy_regno][new_mode];
int copy_offset
= GET_MODE_SIZE (copy_mode) / copy_nregs * (copy_nregs - use_nregs);
- int offset
- = GET_MODE_SIZE (orig_mode) - GET_MODE_SIZE (new_mode) - copy_offset;
- int byteoffset = offset % UNITS_PER_WORD;
- int wordoffset = offset - byteoffset;
-
- offset = ((WORDS_BIG_ENDIAN ? wordoffset : 0)
- + (BYTES_BIG_ENDIAN ? byteoffset : 0));
+ unsigned int offset
+ = subreg_size_lowpart_offset (GET_MODE_SIZE (new_mode) + copy_offset,
+ GET_MODE_SIZE (orig_mode));
regno += subreg_regno_offset (regno, orig_mode, offset, new_mode);
if (HARD_REGNO_MODE_OK (regno, new_mode))
return gen_raw_REG (new_mode, regno);
Index: gcc/reload1.c
===================================================================
--- gcc/reload1.c 2017-08-22 17:14:30.339835581 +0100
+++ gcc/reload1.c 2017-08-23 10:46:45.030666964 +0100
@@ -2253,8 +2253,7 @@ alter_reg (int i, int from_reg, bool don
/* On a big endian machine, the "address" of the slot
is the address of the low part that fits its inherent mode. */
- if (BYTES_BIG_ENDIAN && inherent_size < total_size)
- adjust += (total_size - inherent_size);
+ adjust += subreg_size_lowpart_offset (inherent_size, total_size);
/* If we have any adjustment to make, or if the stack slot is the
wrong mode, make a new stack slot. */
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Make more use of subreg_size_lowpart_offset
2017-08-23 10:56 Make more use of subreg_size_lowpart_offset Richard Sandiford
@ 2017-10-12 18:21 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2017-10-12 18:21 UTC (permalink / raw)
To: gcc-patches, richard.sandiford
On 08/23/2017 04:52 AM, Richard Sandiford wrote:
> This patch uses subreg_size_lowpart_offset in places that open-coded
> the calculation. The reload use (and the LRA one that was based on it)
> seemed to ignore the BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN case; it's not
> obvious whether that was deliberate or an oversight.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure
> that there were no differences in testsuite assembly output for one
> target per CPU. OK to install?
>
> Richard
>
>
> 2017-08-23 Richard Sandiford <richard.sandiford@linaro.org>
> Alan Hayward <alan.hayward@arm.com>
> David Sherwood <david.sherwood@arm.com>
>
> gcc/
> * lra-spills.c (assign_mem_slot): Use subreg_size_lowpart_offset.
> * regcprop.c (maybe_mode_change): Likewise.
> * reload1.c (alter_reg): Likewise.
I'm pretty sure the lra/reload case is just an oversight. It's just
trying to get an adjustment so that it can make a MEM that covers the slot.
It's not absolutely clear to me that the regcprop bits are just an
open-coded subreg_size_lowpart_offset. But I'll willing to trust you on
that one.
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-10-12 18:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-23 10:56 Make more use of subreg_size_lowpart_offset Richard Sandiford
2017-10-12 18:21 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).