From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57866 invoked by alias); 30 Mar 2016 14:41:35 -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 57797 invoked by uid 89); 30 Mar 2016 14:41:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=person X-HELO: mail-vk0-f45.google.com Received: from mail-vk0-f45.google.com (HELO mail-vk0-f45.google.com) (209.85.213.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 30 Mar 2016 14:41:13 +0000 Received: by mail-vk0-f45.google.com with SMTP id k1so63748559vkb.0 for ; Wed, 30 Mar 2016 07:41:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=KWCz9bhzOtjRfyWzRrYEGM5qZgZoq+hvsbPvvCAIlyc=; b=dbNH3Bxi/bV2cAwXn8GMNQq+Pd6VSyQNFCNSKPpyboSCZYTQkuzaf/Lkdfu62lwqiz JNFD1VK8cC+MSIQkFddSZY27rJrKaFX3+Ufh5IINqmMNdtbz3OFT/9+qKaNbghUDRbCM OuOvfITEkDJwvtqSnV+kRPsZVX1ivh1yH0wi3onuPhFGJyE9rKkzPa7cLxMK7tROG38F R+asph5PQRIn6CoKaI+ZsljaVL3CZd7h8Of+lZjvOwm8BJfulP5ubftQBXbYg8yePCRI BkpyU9m5Zysh/OETNoM0+JmDyKH4mC4/BzwoPjT/cUcsujc0kyDXxxC2C9zM4wtmDy5A SgLA== X-Gm-Message-State: AD7BkJIsMAgTTHSiqRTdxDKSWfW/yvKyfnN2b1N/FfAU7mE41Yg5ZuL7D0p3BPgeisHJfFxGtVHvBBY/G/D7dA== MIME-Version: 1.0 X-Received: by 10.176.5.135 with SMTP id e7mr5284799uae.91.1459348871325; Wed, 30 Mar 2016 07:41:11 -0700 (PDT) Received: by 10.103.95.129 with HTTP; Wed, 30 Mar 2016 07:41:11 -0700 (PDT) In-Reply-To: <20160330142215.GA34986@kam.mff.cuni.cz> References: <20160330100018.GA54780@kam.mff.cuni.cz> <20160330142215.GA34986@kam.mff.cuni.cz> Date: Wed, 30 Mar 2016 15:30:00 -0000 Message-ID: Subject: Re: Do not give realistic estimates for loop with array accesses From: "Bin.Cheng" To: Jan Hubicka Cc: gcc-patches List , Richard Biener Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg01606.txt.bz2 On Wed, Mar 30, 2016 at 3:22 PM, Jan Hubicka wrote: >> > - /* If access is not executed on every iteration, we must ensure that overlow may >> > - not make the access valid later. */ >> > + /* If access is not executed on every iteration, we must ensure that overlow >> > + may not make the access valid later. */ >> > if (!dominated_by_p (CDI_DOMINATORS, loop->latch, gimple_bb (data->stmt)) >> > && scev_probably_wraps_p (initial_condition_in_loop_num (ev, loop->num), >> > step, data->stmt, loop, true)) >> > - reliable = false; >> > + upper = false; >> > >> > - record_nonwrapping_iv (loop, init, step, data->stmt, low, high, reliable, upper); >> > + record_nonwrapping_iv (loop, init, step, data->stmt, low, high, false, upper); >> > return true; >> > } >> Hi, >> I have a concern that GCC records bound information from basic blocks >> even that don't dominate loop latch. Given below example: >> >> extern int b[]; >> void bar (int *); >> int foo (int x, int n) >> { >> int i; >> int arr[128] = {0}; >> >> for (i = 0; i < n; i++) >> { >> if (x > i) >> { >> a[i] = i; >> b[i] = i; >> } >> } >> bar (arr); >> return 0; >> } > > This testcase is not affected, becase scev_probably_wraps_p returns false in this case. > In the wrapping case, we can't derive upper bound - this is indeed a correctness issue. In the wrapping case, we still can derive upper bound if the index's wrapping range is larger than array bound. But I agree it looks like very corner case and not likely be useful in practice. Thanks, bin > > I am experiemtning with enabling loop peeling by default. For that I extended the code > to record likely upper bounds, which can be used to test if the loop most probably has > low trip count. This is also useful to trottle other transformations. > > In this case we can probably assume that no sane person would count > on wrapping and record this as likely bound. > > Honza