From patchwork Tue Oct 16 15:36:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 191824 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 78BBD2C0098 for ; Wed, 17 Oct 2012 02:36:59 +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=1351006620; 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=ea0SnoPMZG2iUfNLCfzpYLhWFpc=; b=GJVcFf+mY5jU2Cz O6dhgPLIWof24UJRD0YxSC/E+k9f5SKZ4W3WqgPTlKv7kUnKSL63ZM/3To3mUW1O OYalj/BhQBS6qtNKiRWyAM28QIQOFY7BifSSfi229MF/7Er5dIGpIkJRLxi/tAru d53Kh8ErZ2SEfIzqe6Enx2wrW87g= 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=ymiixBzHCcEBKB7P9FTu9PAeC4QL3QTMDX8omWSjJok3De3G+i8JbTiFLugTVV 9ePwK7H4u4PlYkhfG+FfBuSPo2GFIRQR7qaHH9gUAguz1V9yhkmRv7m9P35CN+78 r5uYHwCoQVmgrKe5mf2rX0BgNL/y4lsjpBbbGR+RTCg0w=; Received: (qmail 15993 invoked by alias); 16 Oct 2012 15:36:26 -0000 Received: (qmail 15954 invoked by uid 22791); 16 Oct 2012 15:36:25 -0000 X-SWARE-Spam-Status: No, hits=-4.0 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; Tue, 16 Oct 2012 15:36:14 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 91B8A5437D5; Tue, 16 Oct 2012 17:36:12 +0200 (CEST) Date: Tue, 16 Oct 2012 17:36:12 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Do not drop the loop bounds when copying it Message-ID: <20121016153612.GA25204@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, while looking into cases where loop-iv.c still deduce useful bounds that are not recorded by tree level I noticed that we do not duplicate the bounds when copying the loop. Fixed thus. Bootstrapped/regtested x86_64-linux, OK? Honza * cfgloopmanip.c (copy_loop_info): New function. (duplicate_loop): Use it. (loop_version): Use it. * loop-unswitch.c (unswitch_loop): Use it. * cfgloop.h (copy_loop_info): Declare. Index: cfgloopmanip.c =================================================================== --- cfgloopmanip.c (revision 192483) +++ cfgloopmanip.c (working copy) @@ -971,6 +970,20 @@ fix_loop_placements (struct loop *loop, } } +/* Duplicate loop bounds and other information we store about + the loop into its duplicate. */ + +void +copy_loop_info (struct loop *loop, struct loop *target) +{ + gcc_checking_assert (!target->any_upper_bound && !target->any_estimate); + target->any_upper_bound = loop->any_upper_bound; + target->nb_iterations_upper_bound = loop->nb_iterations_upper_bound; + target->any_estimate = loop->any_estimate; + target->nb_iterations_estimate = loop->nb_iterations_estimate; + target->estimate_state = loop->estimate_state; +} + /* Copies copy of LOOP as subloop of TARGET loop, placing newly created loop into loops structure. */ struct loop * @@ -979,6 +992,8 @@ duplicate_loop (struct loop *loop, struc struct loop *cloop; cloop = alloc_loop (); place_new_loop (cloop); + + copy_loop_info (loop, cloop); /* Mark the new loop as copy of LOOP. */ set_loop_copy (loop, cloop); @@ -1687,6 +1702,8 @@ loop_version (struct loop *loop, false /* Do not redirect all edges. */, then_scale, else_scale); + copy_loop_info (loop, nloop); + /* loopify redirected latch_edge. Update its PENDING_STMTS. */ lv_flush_pending_stmts (latch_edge); Index: loop-unswitch.c =================================================================== --- loop-unswitch.c (revision 192483) +++ loop-unswitch.c (working copy) @@ -454,6 +454,7 @@ unswitch_loop (struct loop *loop, basic_ BRANCH_EDGE (switch_bb), FALLTHRU_EDGE (switch_bb), true, prob, REG_BR_PROB_BASE - prob); + copy_loop_info (loop, nloop); /* Remove branches that are now unreachable in new loops. */ remove_path (true_edge); remove_path (false_edge); Index: cfgloop.h =================================================================== --- cfgloop.h (revision 192483) +++ cfgloop.h (working copy) @@ -310,6 +310,7 @@ extern edge create_empty_if_region_on_ed extern struct loop *create_empty_loop_on_edge (edge, tree, tree, tree, tree, tree *, tree *, struct loop *); extern struct loop * duplicate_loop (struct loop *, struct loop *); +extern void copy_loop_info (struct loop *loop, struct loop *target); extern void duplicate_subloops (struct loop *, struct loop *); extern bool duplicate_loop_to_header_edge (struct loop *, edge, unsigned, sbitmap, edge,