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 1E3ED3858D33 for ; Fri, 31 Mar 2023 09:58:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1E3ED3858D33 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 21BB42F4; Fri, 31 Mar 2023 02:58:48 -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 4ED2E3F6C4; Fri, 31 Mar 2023 02:58:03 -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] vect: Verify that GET_MODE_NUNITS is greater than one. References: <20230314215256.4153026-1-collison@rivosinc.com> Date: Fri, 31 Mar 2023 10:58:02 +0100 In-Reply-To: <20230314215256.4153026-1-collison@rivosinc.com> (Michael Collison's message of "Tue, 14 Mar 2023 21:52:56 +0000") 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=-31.6 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 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 greater than one. > --- > gcc/tree-vect-slp.cc | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc > index 9a4e000925e..add58113fa8 100644 > --- a/gcc/tree-vect-slp.cc > +++ b/gcc/tree-vect-slp.cc > @@ -426,7 +426,8 @@ can_duplicate_and_interleave_p (vec_info *vinfo, unsigned int count, > 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)) > + && known_gt (GET_MODE_NUNITS (TYPE_MODE (vector_type)), 1)) > { > /* Try fusing consecutive sequences of COUNT / NVECTORS elements > together into elements of type INT_TYPE and using the result FWIW, I think it'd better to remove: poly_int64 half_nelts = exact_div (nelts, 2); declare: poly_uint64 half_nelts; before the if condition, and use: && multiple_p (GET_MODE_NUNITS (TYPE_MODE (vector_type)), 2, &half_nelts) instead of the known_gt. In other words, now that we can't assert the exact_div, we should check it (using multiple_p) instead. Thanks, Richard