public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: Replace manual swapping idiom with std::swap in aarch64.cc
@ 2022-07-15 14:53 Richard Ball
  2022-07-18 10:30 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Ball @ 2022-07-15 14:53 UTC (permalink / raw)
  To: gcc-patches
  Cc: richard.earnshaw, richard.sandiford, marcus.shawcroft, kyrylo.tkachov

Replace manual swapping idiom with std::swap in aarch64.cc

gcc/config/aarch64/aarch64.cc has a few manual swapping idioms of the form:

x = in0, in0 = in1, in1 = x;

The preferred way is using the standard:

std::swap (in0, in1);

We should just fix these to use std::swap.
This will also allow us to eliminate the x temporary rtx.

gcc/ChangeLog:

         * config/aarch64/aarch64.cc (aarch64_evpc_trn): Use std:swap.
         (aarch64_evpc_uzp): Likewise.
         (aarch64_evpc_zip): Likewise.

---


diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 
d049f9a9819628a73bfd57114c3b89d848da7d9c..b75a032c2f2c55d71bcb6b4b6ef1bd7f42a97235 
100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -23498,7 +23498,7 @@ aarch64_evpc_trn (struct expand_vec_perm_d *d)
  {
    HOST_WIDE_INT odd;
    poly_uint64 nelt = d->perm.length ();
-  rtx out, in0, in1, x;
+  rtx out, in0, in1;
    machine_mode vmode = d->vmode;

    if (GET_MODE_UNIT_SIZE (vmode) > 8)
@@ -23522,7 +23522,7 @@ aarch64_evpc_trn (struct expand_vec_perm_d *d)
       at the head of aarch64-sve.md for details.  */
    if (BYTES_BIG_ENDIAN && d->vec_flags == VEC_ADVSIMD)
      {
-      x = in0, in0 = in1, in1 = x;
+      std::swap (in0, in1);
        odd = !odd;
      }
    out = d->target;
@@ -23592,7 +23592,7 @@ static bool
  aarch64_evpc_uzp (struct expand_vec_perm_d *d)
  {
    HOST_WIDE_INT odd;
-  rtx out, in0, in1, x;
+  rtx out, in0, in1;
    machine_mode vmode = d->vmode;

    if (GET_MODE_UNIT_SIZE (vmode) > 8)
@@ -23615,7 +23615,7 @@ aarch64_evpc_uzp (struct expand_vec_perm_d *d)
       at the head of aarch64-sve.md for details.  */
    if (BYTES_BIG_ENDIAN && d->vec_flags == VEC_ADVSIMD)
      {
-      x = in0, in0 = in1, in1 = x;
+      std::swap (in0, in1);
        odd = !odd;
      }
    out = d->target;
@@ -23631,7 +23631,7 @@ aarch64_evpc_zip (struct expand_vec_perm_d *d)
  {
    unsigned int high;
    poly_uint64 nelt = d->perm.length ();
-  rtx out, in0, in1, x;
+  rtx out, in0, in1;
    machine_mode vmode = d->vmode;

    if (GET_MODE_UNIT_SIZE (vmode) > 8)
@@ -23656,7 +23656,7 @@ aarch64_evpc_zip (struct expand_vec_perm_d *d)
       at the head of aarch64-sve.md for details.  */
    if (BYTES_BIG_ENDIAN && d->vec_flags == VEC_ADVSIMD)
      {
-      x = in0, in0 = in1, in1 = x;
+      std::swap (in0, in1);
        high = !high;
      }
    out = d->target;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] aarch64: Replace manual swapping idiom with std::swap in aarch64.cc
  2022-07-15 14:53 [PATCH] aarch64: Replace manual swapping idiom with std::swap in aarch64.cc Richard Ball
@ 2022-07-18 10:30 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2022-07-18 10:30 UTC (permalink / raw)
  To: Richard Ball
  Cc: gcc-patches, richard.earnshaw, marcus.shawcroft, kyrylo.tkachov

Richard Ball <richard.ball@arm.com> writes:
> Replace manual swapping idiom with std::swap in aarch64.cc
>
> gcc/config/aarch64/aarch64.cc has a few manual swapping idioms of the form:
>
> x = in0, in0 = in1, in1 = x;
>
> The preferred way is using the standard:
>
> std::swap (in0, in1);
>
> We should just fix these to use std::swap.
> This will also allow us to eliminate the x temporary rtx.
>
> gcc/ChangeLog:
>
>          * config/aarch64/aarch64.cc (aarch64_evpc_trn): Use std:swap.
>          (aarch64_evpc_uzp): Likewise.
>          (aarch64_evpc_zip): Likewise.

Thanks, pushed to trunk.

Richard

> ---
>
>
> diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
> index 
> d049f9a9819628a73bfd57114c3b89d848da7d9c..b75a032c2f2c55d71bcb6b4b6ef1bd7f42a97235 
> 100644
> --- a/gcc/config/aarch64/aarch64.cc
> +++ b/gcc/config/aarch64/aarch64.cc
> @@ -23498,7 +23498,7 @@ aarch64_evpc_trn (struct expand_vec_perm_d *d)
>   {
>     HOST_WIDE_INT odd;
>     poly_uint64 nelt = d->perm.length ();
> -  rtx out, in0, in1, x;
> +  rtx out, in0, in1;
>     machine_mode vmode = d->vmode;
>
>     if (GET_MODE_UNIT_SIZE (vmode) > 8)
> @@ -23522,7 +23522,7 @@ aarch64_evpc_trn (struct expand_vec_perm_d *d)
>        at the head of aarch64-sve.md for details.  */
>     if (BYTES_BIG_ENDIAN && d->vec_flags == VEC_ADVSIMD)
>       {
> -      x = in0, in0 = in1, in1 = x;
> +      std::swap (in0, in1);
>         odd = !odd;
>       }
>     out = d->target;
> @@ -23592,7 +23592,7 @@ static bool
>   aarch64_evpc_uzp (struct expand_vec_perm_d *d)
>   {
>     HOST_WIDE_INT odd;
> -  rtx out, in0, in1, x;
> +  rtx out, in0, in1;
>     machine_mode vmode = d->vmode;
>
>     if (GET_MODE_UNIT_SIZE (vmode) > 8)
> @@ -23615,7 +23615,7 @@ aarch64_evpc_uzp (struct expand_vec_perm_d *d)
>        at the head of aarch64-sve.md for details.  */
>     if (BYTES_BIG_ENDIAN && d->vec_flags == VEC_ADVSIMD)
>       {
> -      x = in0, in0 = in1, in1 = x;
> +      std::swap (in0, in1);
>         odd = !odd;
>       }
>     out = d->target;
> @@ -23631,7 +23631,7 @@ aarch64_evpc_zip (struct expand_vec_perm_d *d)
>   {
>     unsigned int high;
>     poly_uint64 nelt = d->perm.length ();
> -  rtx out, in0, in1, x;
> +  rtx out, in0, in1;
>     machine_mode vmode = d->vmode;
>
>     if (GET_MODE_UNIT_SIZE (vmode) > 8)
> @@ -23656,7 +23656,7 @@ aarch64_evpc_zip (struct expand_vec_perm_d *d)
>        at the head of aarch64-sve.md for details.  */
>     if (BYTES_BIG_ENDIAN && d->vec_flags == VEC_ADVSIMD)
>       {
> -      x = in0, in0 = in1, in1 = x;
> +      std::swap (in0, in1);
>         high = !high;
>       }
>     out = d->target;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-18 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 14:53 [PATCH] aarch64: Replace manual swapping idiom with std::swap in aarch64.cc Richard Ball
2022-07-18 10:30 ` Richard Sandiford

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).