From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 6C2F7385703A for ; Wed, 26 May 2021 13:23:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6C2F7385703A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 14QDMbpN026036; Wed, 26 May 2021 08:22:37 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 14QDMYGO026033; Wed, 26 May 2021 08:22:34 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 26 May 2021 08:22:34 -0500 From: Segher Boessenkool To: Richard Biener Cc: Jiufu Guo , gcc-patches@gcc.gnu.org, wschmidt@linux.ibm.com, dje.gcc@gmail.com, jlaw@tachyum.com, bin.cheng@linux.alibaba.com Subject: Re: [PATCH V2] Split loop for NE condition. Message-ID: <20210526132233.GJ10366@gate.crashing.org> References: <20210517020143.60075-1-guojiufu@linux.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 26 May 2021 13:23:39 -0000 On Wed, May 26, 2021 at 11:50:07AM +0200, Richard Biener wrote: > > We can split the loop into two loops: > > > > while (++k > n) > > a[k] = b[k] + 1; > > while (l++ < n) > > a[k] = b[k] + 1; > > > > then for the second loop, it could be optimized. > > Btw, I think even the first loop should be vectorized. I see we do > not handle it in niter analysis: > > Analyzing loop at t.c:3 > t.c:3:14: note: === analyze_loop_nest === > t.c:3:14: note: === vect_analyze_loop_form === > t.c:3:14: note: === get_loop_niters === > t.c:3:14: missed: not vectorized: number of iterations cannot be > computed. > > but the number of iterations should be UINT_MAX - k (unless I'm > missing sth), may_be_zero would be sth like k < n. It would be > nice to not split this into loops that niter analysis cannot handle ... As long as it doesn't do that for signed loop counters, because that would be a waste -- ever executing such code is UB, so vectorising it will only cost extra insns (usually). Segher