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 9A6153858C5E for ; Tue, 11 Apr 2023 10:05:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A6153858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com 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 B5A15D75; Tue, 11 Apr 2023 03:06:30 -0700 (PDT) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A2BAB3F73F; Tue, 11 Apr 2023 03:05:45 -0700 (PDT) From: Richard Sandiford To: Richard Biener via Gcc-patches Mail-Followup-To: Richard Biener via Gcc-patches ,Kevin Lee , Richard Biener , collison@rivosinc.com, richard.sandiford@arm.com Cc: Kevin Lee , Richard Biener , collison@rivosinc.com Subject: Re: [PATCH v2][RFC] vect: Verify that GET_MODE_NUNITS is greater than one for vect_grouped_store_supported References: <20230327160157.4111747-1-kevinl@rivosinc.com> Date: Tue, 11 Apr 2023 11:05:44 +0100 In-Reply-To: (Richard Biener via Gcc-patches's message of "Tue, 11 Apr 2023 11:32:50 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-31.3 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,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 List-Id: Richard Biener via Gcc-patches writes: > On Mon, Mar 27, 2023 at 6:02=E2=80=AFPM Kevin Lee w= rote: >> >> This patch is a proper fix to the previous patch >> https://gcc.gnu.org/pipermail/gcc-patches/2023-March/614463.html >> vect_grouped_store_supported checks if the count is a power of 2, but >> doesn't check the size of the GET_MODE_NUNITS. >> This should handle the riscv case where the mode is VNx1DI since the >> nelt would be {1, 1}. >> It was tested on RISCV and x86_64-linux-gnu. Would this be correct >> for the vectors with size smaller than 2? >> >> --- >> gcc/tree-vect-data-refs.cc | 2 ++ >> 1 file changed, 2 insertions(+) >> >> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc >> index 8daf7bd7dd3..04ad12f7d04 100644 >> --- a/gcc/tree-vect-data-refs.cc >> +++ b/gcc/tree-vect-data-refs.cc >> @@ -5399,6 +5399,8 @@ vect_grouped_store_supported (tree vectype, unsign= ed HOST_WIDE_INT count) >> poly_uint64 nelt =3D GET_MODE_NUNITS (mode); >> >> /* The encoding has 2 interleaved stepped patterns. */ >> + if(!nelt.is_constant() && maybe_lt(nelt, (unsigned int) 2)) >> + return false; > > Indentation is off (or your MUA is broken). I think the nelt.is_constant= () > check is superfluous but with constant nelt we'd never end up with a > grouped store. > > Note the calls are guarded with > > && ! known_eq (TYPE_VECTOR_SUBPARTS (vectype), 1U) > > maybe the better fix is to change those to ! maybe_eq? I think the point of those checks is that a grouped store of N 1-element vectors is equivalent to a store of N scalars. Nothing needs to happen internally within the vectors. For a grouped store of VNx1 vectors, some permutation would be needed. But it's difficult to generate code for that case, because the minimum size reduces to two scalars while larger sizes need normal interleaves. But I think the better check for location above is: if (!multiple_p (nelt, 2)) return false; which then guards the assert in the later exact_div (nelt, 2). Thanks, Richard