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 B593F3858407 for ; Thu, 4 Aug 2022 10:09:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B593F3858407 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 E526A11FB; Thu, 4 Aug 2022 03:09:29 -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 A04293F67D; Thu, 4 Aug 2022 03:09:28 -0700 (PDT) From: Richard Sandiford To: Richard Biener Mail-Followup-To: Richard Biener , liuhongt , GCC Patches , richard.sandiford@arm.com Cc: liuhongt , GCC Patches Subject: Re: [RFC: PATCH] Extend vectorizer to handle nonlinear induction for neg, mul/lshift/rshift with a constant. References: <20220804042839.49603-1-hongtao.liu@intel.com> Date: Thu, 04 Aug 2022 11:09:27 +0100 In-Reply-To: (Richard Biener's message of "Thu, 4 Aug 2022 10:18:26 +0200") 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=-46.2 required=5.0 tests=BAYES_00, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no 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: Thu, 04 Aug 2022 10:09:31 -0000 Richard Biener writes: >> +/* Create vector init for vectorized iv. */ >> +static tree >> +vect_create_nonlinear_iv_init (gimple_seq* stmts, tree init_expr, >> + tree step_expr, poly_uint64 nunits, >> + tree vectype, >> + enum vect_induction_op_type induction_type) >> +{ >> + unsigned HOST_WIDE_INT const_nunits; >> + tree vec_shift, vec_init, new_name; >> + unsigned i; >> + >> + /* iv_loop is the loop to be vectorized. Create: >> + vec_init = [X, X+S, X+2*S, X+3*S] (S = step_expr, X = init_expr). */ >> + new_name = init_expr; >> + switch (induction_type) >> + { >> + case vect_step_op_shr: >> + case vect_step_op_shl: >> + /* Build the Initial value from shift_expr. */ >> + vec_init = gimple_build_vector_from_val (stmts, >> + vectype, >> + new_name); >> + vec_shift = gimple_build (stmts, VEC_SERIES_EXPR, vectype, >> + build_zero_cst (TREE_TYPE (step_expr)), >> + step_expr); > > There might be a more canonical way to build the series expr - Richard? build_vec_series is shorter if step_expr is known to be a constant. The above looks good for the general case. Thanks, Richard