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 40ECD3858D33 for ; Fri, 29 Dec 2023 22:32:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40ECD3858D33 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 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 40ECD3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.113.20.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703889140; cv=none; b=L2AU76XoYIeFEZAMiP4saKSZW4mrN5IqZxgxTYj9be4eVtzznp/ewsnQ1vvvRk89aAoroDr0/TXLuC+65T6eEmfpOpU1UHL4GI4PS4b1E7nDsIlmbF230i/clGYg/i3uruAUdtlSTF97CVxeEr+NCvEWlk3kLTryXxQh7mBXDbc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703889140; c=relaxed/simple; bh=utdjMj2C61isUTkC+SI/QlQBijlPQ9IsOmxU3cTjgtU=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=vKiqV4yQ/o1q0jr9YDDNTtQhiOE/CFQXBJj0IvCToRM0HSqmPr9oBYwWL8YY2AH0A5+qP2bqcYc/XfkL2xRfct+JYXLD5BgmMyS3H+TddcS8cgajVleeCFAGS5eKhG6lb8s1KXGxv+WuxYeC1c/3fHvTfeinZDfPI4dAlEveV2Y= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 2BB8828C59A; Fri, 29 Dec 2023 23:32:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1703889137; 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: in-reply-to:in-reply-to:references:references; bh=ZQ7ltJkIQfU1VH3SxLxo7cEbq6F7HZp6tu1W2D+HZQA=; b=hMFzyTsxSt/6h55vMErgIQEkLGLj8eVUlr9au8a1yocbRKvqRhnY+OutNbh+vCMX8Mwgy+ 5ScvyFOf+CWFc+elR1+lPZbsdfZcjSXjSENjTc4nlt5pyQxcx8OfcacgetReTWhjRwhLhI 4zt/oTTabwqb6CDOnR8ow9MXQq0VLb4= Date: Fri, 29 Dec 2023 23:32:17 +0100 From: Jan Hubicka To: Tamar Christina Cc: "rguenther@suse.de" , GCC Patches , nd Subject: Re: skip vector profiles multiple exits Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,JMQ_SPF_NEUTRAL,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: > Hi Honza, Hi, > > I wasn't sure what to do here so I figured I'd ask. > > In adding support for multiple exits to the vectorizer I didn't know how to update this bit: > > https://github.com/gcc-mirror/gcc/blob/master/gcc/tree-vect-loop-manip.cc#L3363 > > Essentially, if skip_vector (i.e. not enough iteration to enter the vector loop) then the > previous code would update the new probability to be the same as that of the > exit edge. This made sense because that's the only edge which could bring you to > the next loop preheader. > > With multiple exits this is no longer the case since any exit can bring you to the > Preaheader node. I figured the new counts should simply be the sum of all exit > edges. But that gives quite large count values compared to the rest of the loop. The sum of all exit counts (not probabilities) relative to header count should give you estimated probability that the loop iterates at any given iteration. I am not sure how good estimate this is for loop preconditioning to be true (without profile histograms it is really hard to tell). > > I then thought I would need to scale the counts by the probability of the edge > being taken. The problem here is that the probabilities don't end up to 100% So you are summing exit_edge->count ()? I am not sure how useful would be summit probabilities since they are conditional (relative to probability of entering BB you go to). How complicated CFG we now handle with vectorization? Honza > > so the scaled counts also looked kinda wonkey. Any suggestions? > > If you want some small examples to look at, testcases > ./gcc/testsuite/gcc.dg/vect/vect-early-break_90.c to ./gcc/testsuite/gcc.dg/vect/vect-early-break_93.c > should be relevant here. > > Thanks, > Tamar