[31/61] Improve aligned straight line memcpy

Message ID 20250131171232.1018281-33-aleksandar.rakic@htecgroup.com
State New
Headers
Series Improve Mips target |

Commit Message

Aleksandar Rakic Jan. 31, 2025, 5:13 p.m. UTC
  From: Robert Suchanek <robert.suchanek@imgtec.com>

Cherry-picked 4194c529fade9b3106d118cac63b71bc8b13f7be
from https://github.com/MIPS/gcc

Signed-off-by: Robert Suchanek <robert.suchanek@imgtec.com>
Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com>
Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
---
 gcc/config/mips/mips.cc | 8 +++++++-
 gcc/config/mips/mips.h  | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)
  

Comments

Richard Biener Feb. 3, 2025, 9:36 a.m. UTC | #1
On Fri, Jan 31, 2025 at 6:37 PM Aleksandar Rakic
<aleksandar.rakic@htecgroup.com> wrote:
>
> From: Robert Suchanek <robert.suchanek@imgtec.com>
>
> Cherry-picked 4194c529fade9b3106d118cac63b71bc8b13f7be
> from https://github.com/MIPS/gcc

This (and some other of the patches) lack the appropriate ChangeLog
entry embedded in the commit message.

> Signed-off-by: Robert Suchanek <robert.suchanek@imgtec.com>
> Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com>
> Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com>
> ---
>  gcc/config/mips/mips.cc | 8 +++++++-
>  gcc/config/mips/mips.h  | 5 +++++
>  2 files changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
> index 3185fa9633e..cd4bce71ae8 100644
> --- a/gcc/config/mips/mips.cc
> +++ b/gcc/config/mips/mips.cc
> @@ -9631,7 +9631,13 @@ mips_expand_block_move (rtx dest, rtx src, rtx length, rtx alignment)
>      {
>        if (ISA_HAS_COPY)
>           return mips16_expand_copy (dest, src, length, alignment);
> -      else if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER)
> +      else if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER
> +   /* We increase slightly the maximum number of bytes in
> +                 a straight-line block if the source and destination
> +                 are aligned to the register width.  */
> +   || (!optimize_size
> +                  && INTVAL (alignment) == UNITS_PER_WORD
> +                  && INTVAL (length) <= MIPS_MAX_MOVE_MEM_STRAIGHT))
>    {
>      mips_block_move_straight (dest, src, INTVAL (length),
>                                 INTVAL (alignment));
> diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
> index efd23a262f9..0245287f9bf 100644
> --- a/gcc/config/mips/mips.h
> +++ b/gcc/config/mips/mips.h
> @@ -3171,6 +3171,11 @@ while (0)
>  #define MIPS_MAX_MOVE_BYTES_STRAIGHT \
>    (MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER * 2)
>
> +/* The maximum number of bytes that can be copied by any expanded block move;
> +   see mips_expand_block_move.  */
> +#define MIPS_MAX_MOVE_MEM_STRAIGHT \
> +  (MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER * 3)
> +
>  /* The base cost of a memcpy call, for MOVE_RATIO and friends.  These
>     values were determined experimentally by benchmarking with CSiBE.
>     In theory, the call overhead is higher for TARGET_ABICALLS (especially
> --
> 2.34.1
  
Jakub Jelinek Feb. 3, 2025, 9:45 a.m. UTC | #2
On Mon, Feb 03, 2025 at 10:36:15AM +0100, Richard Biener wrote:
> > --- a/gcc/config/mips/mips.cc
> > +++ b/gcc/config/mips/mips.cc
> > @@ -9631,7 +9631,13 @@ mips_expand_block_move (rtx dest, rtx src, rtx length, rtx alignment)
> >      {
> >        if (ISA_HAS_COPY)
> >           return mips16_expand_copy (dest, src, length, alignment);
> > -      else if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER)
> > +      else if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER
> > +   /* We increase slightly the maximum number of bytes in
> > +                 a straight-line block if the source and destination
> > +                 are aligned to the register width.  */
> > +   || (!optimize_size
> > +                  && INTVAL (alignment) == UNITS_PER_WORD
> > +                  && INTVAL (length) <= MIPS_MAX_MOVE_MEM_STRAIGHT))

The formatting here doesn't follow the coding conventions.
Dunno if this is in the MUA say replacing a tab with spaces, but unlikely,
e.g. the || line should be indented by one tab and 7 spaces to go under
INTVAL in else if line.
See https://gcc.gnu.org/contribute.html#standards for details.

	Jakub
  

Patch

diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc
index 3185fa9633e..cd4bce71ae8 100644
--- a/gcc/config/mips/mips.cc
+++ b/gcc/config/mips/mips.cc
@@ -9631,7 +9631,13 @@  mips_expand_block_move (rtx dest, rtx src, rtx length, rtx alignment)
     {
       if (ISA_HAS_COPY)
 	  return mips16_expand_copy (dest, src, length, alignment);
-      else if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER)
+      else if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER
+   /* We increase slightly the maximum number of bytes in
+		  a straight-line block if the source and destination
+		  are aligned to the register width.  */
+   || (!optimize_size
+		   && INTVAL (alignment) == UNITS_PER_WORD
+		   && INTVAL (length) <= MIPS_MAX_MOVE_MEM_STRAIGHT))
   {
     mips_block_move_straight (dest, src, INTVAL (length),
 				INTVAL (alignment));
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index efd23a262f9..0245287f9bf 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -3171,6 +3171,11 @@  while (0)
 #define MIPS_MAX_MOVE_BYTES_STRAIGHT \
   (MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER * 2)
 
+/* The maximum number of bytes that can be copied by any expanded block move;
+   see mips_expand_block_move.  */
+#define MIPS_MAX_MOVE_MEM_STRAIGHT \
+  (MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER * 3)
+
 /* The base cost of a memcpy call, for MOVE_RATIO and friends.  These
    values were determined experimentally by benchmarking with CSiBE.
    In theory, the call overhead is higher for TARGET_ABICALLS (especially