From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17703 invoked by alias); 13 Aug 2015 22:08:47 -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 17692 invoked by uid 89); 13 Aug 2015 22:08:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 13 Aug 2015 22:08:45 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 3F5A6FA9D6; Thu, 13 Aug 2015 22:08:44 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-104.phx2.redhat.com [10.3.113.104]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t7DM8hwA017561; Thu, 13 Aug 2015 18:08:43 -0400 Subject: Re: [PATCH GCC]Improve bound information in loop niter analysis To: Bin Cheng , gcc-patches@gcc.gnu.org References: <000401d0c918$d7a2e780$86e8b680$@arm.com> From: Jeff Law Message-ID: <55CD156B.3030506@redhat.com> Date: Thu, 13 Aug 2015 22:10:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <000401d0c918$d7a2e780$86e8b680$@arm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00744.txt.bz2 On 07/28/2015 03:36 AM, Bin Cheng wrote: > Hi, > Loop niter computes inaccurate bound information for different loops. This > patch is to improve it by using loop initial condition in > determine_value_range. Generally, loop niter is computed by subtracting > start var from end var in loop exit condition. Moreover, loop bound is > computed using value range information of both start and end variables. > Basic idea of this patch is to check if loop initial condition implies more > range information for both start/end variables. If yes, we refine range > information and use that to compute loop bound. > With this improvement, more accurate loop bound information is computed for > test cases added by this patch. > > Is it OK? > > Thanks, > bin > > 2015-07-28 Bin Cheng > > * tree-ssa-loop-niter.c (refine_value_range_using_guard): New. > (determine_value_range): Call refine_value_range_using_guard for > each loop initial condition to improve value range. > > gcc/testsuite/ChangeLog > 2015-07-28 Bin Cheng > > * gcc.dg/tree-ssa/loop-bound-1.c: New test. > * gcc.dg/tree-ssa/loop-bound-3.c: New test. > * gcc.dg/tree-ssa/loop-bound-5.c: New test. > > > improve-loop-bound-analysis-20150728.txt > > > Index: gcc/testsuite/gcc.dg/tree-ssa/loop-bound-3.c > =================================================================== > --- gcc/testsuite/gcc.dg/tree-ssa/loop-bound-3.c (revision 0) > +++ gcc/testsuite/gcc.dg/tree-ssa/loop-bound-3.c (revision 0) > @@ -0,0 +1,22 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fdump-tree-ivopts-details" } */ > + > +int *a; > + > +int > +foo (unsigned char s, unsigned char l) > +{ > + unsigned char i; > + int sum = 0; > + > + for (i = s; i > l; i -= 1) So is this really bounded by 254 iterations? ISTM it's bounded by 255 iterations when called with s = 255, l = 0. What am I missing here? Am I mis-interpreting the dump output in some way? Similarly for the other tests. Jeff