From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42317 invoked by alias); 5 May 2019 06:02:43 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 42303 invoked by uid 89); 5 May 2019 06:02:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 05 May 2019 06:02:41 +0000 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x45627Go004650 for ; Sun, 5 May 2019 02:02:39 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2s9qpnc569-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 05 May 2019 02:02:38 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 5 May 2019 07:02:36 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Sun, 5 May 2019 07:02:33 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4562Wdj47251636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 5 May 2019 06:02:32 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6CC0FAE057; Sun, 5 May 2019 06:02:32 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B0187AE04D; Sun, 5 May 2019 06:02:29 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.147.179]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Sun, 5 May 2019 06:02:29 +0000 (GMT) Subject: Re: [PATCH, RFC, rs6000] PR80791 Consider doloop in ivopts To: "Bin.Cheng" Cc: GCC Patches , "bin.cheng" , Segher Boessenkool , Bill Schmidt , Richard Guenther , Jakub Jelinek References: From: "Kewen.Lin" Date: Sun, 05 May 2019 06:02:00 -0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit x-cbid: 19050506-0016-0000-0000-000002787654 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19050506-0017-0000-0000-000032D51745 Message-Id: <3e5526ba-ed4d-c13b-9953-9b95340fcdcf@linux.ibm.com> X-IsSubscribed: yes X-SW-Source: 2019-05/txt/msg00164.txt.bz2 on 2019/5/5 下午12:04, Bin.Cheng wrote: > On Sun, May 5, 2019 at 11:23 AM Kewen.Lin wrote: >>>> + /* Some compare iv_use is probably useless once the doloop optimization >>>> + performs. */ >>>> + if (tailor_cmp_p) >>>> + tailor_cmp_uses (data); >>> Function tailor_cmp_uses sets iv_use->zero_cost_p under some >>> conditions. Once the flag is set, though the iv_use participates cost >>> computation in determine_group_iv_cost_cond, the result cost is >>> hard-wired to ZERO (which means cost computation for such iv_use is >>> waste of time). >> >> Yes, it can be improved by some early check and return. >> But it's still helpful to make it call with may_eliminate_iv. >> gcc.dg/no-strict-overflow-6.c is one example, with may_eliminate_iv >> consideration it exposes more opportunities for downstream optimization. > Hmm, I wasn't suggesting early check and return, on the contrary, we > can better integrate doloop/cost stuff in the overall model. See more > in following comments. Sorry, I didn't claim it clearly, the previous comment is to claim the call with may_eliminate_iv is not completely "waste of time", and early return can make it save time. :) And yes, it's not an issue any more with your proposed idea. >> >>> Also iv_use rewriting process is skipped for related >>> ivs preserved explicitly by preserve_ivs_for_use. >>> Note IVOPTs already adds candidate for original ivs. So why not >>> detecting doloop iv_use, adjust its cost with the corresponding >>> original iv candidate, then let the general cost model make the >>> decision? I believe this better fits existing infrastructure and >>> requires less change, for example, preserve_ivs_for_use won't be >>> necessary. >> I agree adjusting the cost of original iv candidate of the iv_use >> requires less change, but on one hand, I thought to remove interest >> cmp iv use or make it zero cost is close to the fact. Since it's >> eliminated eventually in doloop optimization, it should not >> considered in cost modeling. This way looks more exact. > Whether doloop transformation should be considered or be bypassed in > cost model isn't a problem. Actually we can bind doloop iv_cand to > cmp iv_use in order to force the transformation. My concern is the > patch specially handles doloop by setting the special flag, then > checking it. We generally avoid such special-case handling since it > hurts long time maintenance. The pass was very unstable in the pass > because of such issues. > OK, I understand your concerns now. Thanks for explanation! >> One the other hand, I assumed your suggestion is to increase the >> cost for the pair (original iv cand, cmp iv use), the increase cost >> seems to be a heuristic value? It seems it's possible to sacrifice > Decrease the cost so that the iv_cand is preferred? The comment > wasn't made on top of implementing doloop in ivopts. Anyway, you can > still bypass cost model by binding the "correct" iv_cand to cmp > iv_use. > To decrease the cost isn't workable for this case, it make the original iv cand is preferred more and over the other iv cand for memory iv use, then the desirable memory based iv cand won't be chosen. If increase the cost, one basic iv cand is chosen for cmp use, memory based iv cand is chosen for memory use, instead of original iv for both. Could you help to explain the "binding" more? Does it mean cost modeling decision making can simply bypass the cmp iv_use (we have artificially assigned one "correct" cand iv to it) and also doesn't count the "correct" iv cand cost into total iv cost? Is my understanding correct? >>> tuning; 2) the doloop decision can still be canceled by cost model if >>> it's really not beneficial. With current patch, it can't be undo once >>> the decision is made (at very early stage in IVOPTs.). >> >> I can't really follow this. If it's predicted to be transformed to doloop, >> I think it should not be undoed any more, since it's useless to consider >> this cmp iv use. Whatever IVOPTS does, the comp at loop closing should not >> be changed (although possible to use other iv), right? Do I miss something? > As mentioned, the previous comment wasn't made on top of implementing > doloop in ivopts. That would be nice but a different story. > Before we can do that, it'd better be conservative and only makes > (doloop) decision in ivopts when you are sure. As you mentioned, it's > hard to do the same checks at gimple as RTL, right? In this case, > making it a (conservative) heuristic capturing certain beneficial > cases sounds better than capturing all cases but fail in later RTL > passes. > Yes, I agree we should be conservative. But it's hard to determine which is better in practice, even for capturing all cases, we are still trying our best to be more conservative, excluding any suspicious factor which is possible to make it fail in later RTL checking, one example is that the patch won't predict it can be doloop once finding switch statement. It depends on how much "bad" cases we don't catch and how serious its impact is and whether easy to improve. Thanks Kewen.Lin