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 AD4FE3858D1E for ; Tue, 2 May 2023 10:11:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD4FE3858D1E 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 9AB34C14; Tue, 2 May 2023 03:12:29 -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 EA6C13F64C; Tue, 2 May 2023 03:11:44 -0700 (PDT) From: Richard Sandiford To: Michael Collison Mail-Followup-To: Michael Collison ,gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH v5 07/10] vect: Verify that GET_MODE_NUNITS is a multiple of 2. References: <20230426214514.3355280-1-collison@rivosinc.com> <20230426214514.3355280-8-collison@rivosinc.com> Date: Tue, 02 May 2023 11:11:43 +0100 In-Reply-To: <20230426214514.3355280-8-collison@rivosinc.com> (Michael Collison's message of "Wed, 26 Apr 2023 17:45:11 -0400") 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=-30.3 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,T_SCC_BODY_TEXT_LINE 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: Michael Collison writes: > While working on autovectorizing for the RISCV port I encountered an issue > where can_duplicate_and_interleave_p assumes that GET_MODE_NUNITS is a > evenly divisible by two. The RISC-V target has vector modes (e.g. VNx1DImode), > where GET_MODE_NUNITS is equal to one. > > Tested on RISCV and x86_64-linux-gnu. Okay? > > 2023-03-09 Michael Collison > > * tree-vect-slp.cc (can_duplicate_and_interleave_p): > Check that GET_MODE_NUNITS is a multiple of 2. OK, thanks. Doesn't need to wait for any other of the other patches in the series. Richard > --- > gcc/tree-vect-slp.cc | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc > index d73deaecce0..a64fe454e19 100644 > --- a/gcc/tree-vect-slp.cc > +++ b/gcc/tree-vect-slp.cc > @@ -423,10 +423,13 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, > (GET_MODE_BITSIZE (int_mode), 1); > tree vector_type > = get_vectype_for_scalar_type (vinfo, int_type, count); > + poly_int64 half_nelts; > if (vector_type > && VECTOR_MODE_P (TYPE_MODE (vector_type)) > && known_eq (GET_MODE_SIZE (TYPE_MODE (vector_type)), > - GET_MODE_SIZE (base_vector_mode))) > + GET_MODE_SIZE (base_vector_mode)) > + && multiple_p (GET_MODE_NUNITS (TYPE_MODE (vector_type)), > + 2, &half_nelts)) > { > /* Try fusing consecutive sequences of COUNT / NVECTORS elements > together into elements of type INT_TYPE and using the result > @@ -434,7 +437,7 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, > poly_uint64 nelts = GET_MODE_NUNITS (TYPE_MODE (vector_type)); > vec_perm_builder sel1 (nelts, 2, 3); > vec_perm_builder sel2 (nelts, 2, 3); > - poly_int64 half_nelts = exact_div (nelts, 2); > + > for (unsigned int i = 0; i < 3; ++i) > { > sel1.quick_push (i);