From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id AB1343858D28 for ; Mon, 18 Jul 2022 10:30:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AB1343858D28 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CB9841042; Mon, 18 Jul 2022 03:30:53 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7D9763F70D; Mon, 18 Jul 2022 03:30:52 -0700 (PDT) From: Richard Sandiford To: Richard Ball Mail-Followup-To: Richard Ball , gcc-patches@gcc.gnu.org, richard.earnshaw@arm.com, marcus.shawcroft@arm.com, kyrylo.tkachov@arm.com, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org, richard.earnshaw@arm.com, marcus.shawcroft@arm.com, kyrylo.tkachov@arm.com Subject: Re: [PATCH] aarch64: Replace manual swapping idiom with std::swap in aarch64.cc References: Date: Mon, 18 Jul 2022 11:30:51 +0100 In-Reply-To: (Richard Ball's message of "Fri, 15 Jul 2022 15:53:41 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-53.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2022 10:30:55 -0000 Richard Ball 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;