From patchwork Wed Oct 31 12:23:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 195859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5493B2C0172 for ; Wed, 31 Oct 2012 23:23:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352291012; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Date: From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=guxiHmy3bPjhX2bnzZ/dGBO06cc=; b=DHgbSEh6mNAf8Cr LHLyKDp4U189auaCawUvt4WuWv0W1nKOfNrwis9z0WBDNyMQ0aq+gCLXo+FliyVZ ApNPRkbQxsYwPNSN9AxFkh4ozQU8f1Y6kfOTREoY6WeNIPqsvEs9nLJHwgFWgm47 BLTSYRrxYuN9XRoFHEM0jlX3vPEw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Date:From:To:Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=wE0Nmqh649yyBGWJJ4WTu2gdT7H33rKh2727QTXqSA71yhMuXO8H9VSeMfsgw5 rvnRhG39jTMoCsoxBTQgbrX0GwBuYs3PpvSGdgY/r3Y4rc59nude0dWFIvAcrMSa xcT41ucQHwQ36JclKXEgZMIRAIuRMzt9JhSvDwMSBVaY0=; Received: (qmail 15006 invoked by alias); 31 Oct 2012 12:23:24 -0000 Received: (qmail 14991 invoked by uid 22791); 31 Oct 2012 12:23:22 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 31 Oct 2012 12:23:09 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 09632543BD0; Wed, 31 Oct 2012 13:23:07 +0100 (CET) Date: Wed, 31 Oct 2012 13:23:07 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Modernize loop_finite_p Message-ID: <20121031122307.GB15866@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, this patch changes finite_loop_p to use max_loop_iterations. Long time ago I made finite_loop_p as rip-off from the max_loop_iterations skipping parts that are not exactly related to the number of iteration estimates. It went out of date since then completelly missing the bounds derived from overflows and array bounds that are quite useful. So I guess these days it is better to simply implement it using max_loop_iterations, we do not save that much of effort and we can store the result. Bootstrapped/regtested x86_64, OK? Honza * tree-ssa-loop-niter.c (finite_loop_p): Reorg to use max_loop_iterations. Index: tree-ssa-loop-niter.c =================================================================== --- tree-ssa-loop-niter.c (revision 192991) +++ tree-ssa-loop-niter.c (working copy) @@ -1993,11 +1990,7 @@ find_loop_niter (struct loop *loop, edge bool finite_loop_p (struct loop *loop) { - unsigned i; - VEC (edge, heap) *exits; - edge ex; - struct tree_niter_desc desc; - bool finite = false; + double_int nit; int flags; if (flag_unsafe_loop_optimizations) @@ -2011,26 +2004,22 @@ finite_loop_p (struct loop *loop) return true; } - exits = get_loop_exit_edges (loop); - FOR_EACH_VEC_ELT (edge, exits, i, ex) + if (loop->any_upper_bound) { - if (!just_once_each_iteration_p (loop, ex->src)) - continue; + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Found loop %i to be finite: upper bound is recorded.\n", + loop->num); + return true; + } - if (number_of_iterations_exit (loop, ex, &desc, false)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - { - fprintf (dump_file, "Found loop %i to be finite: iterating ", loop->num); - print_generic_expr (dump_file, desc.niter, TDF_SLIM); - fprintf (dump_file, " times\n"); - } - finite = true; - break; - } + if (max_loop_iterations (loop, &nit)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Found loop %i to be finite: upper bound found.\n", + loop->num); + return true; } - VEC_free (edge, heap, exits); - return finite; + return false; } /*