From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 713793858D20 for ; Fri, 28 Jul 2023 12:50:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 713793858D20 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id AA9402828DD; Fri, 28 Jul 2023 14:50:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1690548614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lbxR1cBr0Wl2hBBNz09G8owO9ocSnGDa7DMh5RTdFvs=; b=PSl0K1HmI/pIoSIUjsrsjQPXclR/Mj4bkx4pjXAwcOCPcOFjIzLOP7M264nYnykJTHQ1N9 Xo8uriY1+yfSFyCFjQ9C4Wbjydcfhulf5V1XvhNsNmJ+esimv0UUVrP2PAnkaw5wjKKdDv Tkn0cgoUUYgG0B4pe+JJzbMvGkUlW/M= Date: Fri, 28 Jul 2023 14:50:14 +0200 From: Jan Hubicka To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: Loop-split improvements, part 2 Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,JMQ_SPF_NEUTRAL,KAM_NUMSUBJECT,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > On Fri, Jul 28, 2023 at 9:58 AM Jan Hubicka via Gcc-patches > wrote: > > > > Hi, > > this patch fixes profile update in the first case of loop splitting. > > The pass still gives up on very basic testcases: > > > > __attribute__ ((noinline,noipa)) > > void test1 (int n) > > { > > if (n <= 0 || n > 100000) > > return; > > for (int i = 0; i <= n; i++) > > { > > if (i < n) > > do_something (); > > if (a[i]) > > do_something2(); > > } > > } > > Here I needed to do the conditoinal that enforces sane value range of n. > > The reason is that it gives up on: > > !number_of_iterations_exit (loop1, exit1, &niter, false, true) > > and without the conditonal we get assumption that n>=0 and not INT_MAX. > > I think from overflow we shold derive that INT_MAX test is not needed and since > > the loop does nothing for n<0 it is also just an paranoia. > > I only get n != 2147483647 (loop header copying does the n >= 0). Indeed > this test looks odd. It's because we turn i <= n into i < n + 1 and analyze > that (our canonical test is LT_EXPR), for this to work n may not be INT_MAX. Yep, I can't think on how that can disturb loop splitting. The loop above is similar to one in hmmer so people do loops like that. We should be able to use the fact that i can not overflow to get rid of this assumtion, but I am not that famililar with that code... I think it would help elsewhere too? > > In principle it could just look at the scalar evolution for the IV in > the exit test. > Aka use simple_iv () and check ->no_overflow? Yep, I tink that should be enough. It uses simple_iv to analyze the in-loop conditionals. I will look into that. Honza