From patchwork Mon Feb 25 19:53:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 223026 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 C7F842C0087 for ; Tue, 26 Feb 2013 06:54:26 +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=1362426867; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Date:From:To:Cc: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=LMBX90VduZoUkN4A1kFsF88Hung=; b=mdJltMglb1/gOed dafIhjJ4jx0S4QQybQ0a1rB7LA8ZfiiNfawXSrEnrT+1+UA08Hv6a0LQHBaav/Xz 6pBhTlHNfVQ8RGbRSFdo/zXzyIc31M2PLcSsZIpVkBNmc+/nB80+GgFAmeEAsweS Qsz+RpBMBYbSa4DIeD2NAMVzDBf4= 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:Received:Date:From:To:Cc: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=s0ovwLZowg5i8xDZnR5mG3FjQ8YvhnANtmbxG2qZ3C7aNlTlz+Jm0cOkPiuksA UIHtq5DFulUWpojm4K7YqVuy6G+jN5ei4xdoj7qpvFS8hwen6Gc4rV84KA78VXKC 1THnm8IbER7kuqozKAJksYhrEvB15gCNfhil0TQ9oNxlY=; Received: (qmail 21146 invoked by alias); 25 Feb 2013 19:53:27 -0000 Received: (qmail 21123 invoked by uid 22791); 25 Feb 2013 19:53:25 -0000 X-SWARE-Spam-Status: No, hits=-6.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 25 Feb 2013 19:53:15 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1PJrEVC008140 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 25 Feb 2013 14:53:15 -0500 Received: from redhat.com (ovpn-116-20.ams2.redhat.com [10.36.116.20]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r1PJrBAq006442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 25 Feb 2013 14:53:14 -0500 Date: Mon, 25 Feb 2013 20:53:11 +0100 From: Marek Polacek To: GCC Patches Cc: Richard Biener Subject: [PATCH] Fix PR56426 Message-ID: <20130225195311.GB25197@redhat.com> 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 This fixes PR56426. We were ICEing during the loop pipeline, because copyprop changed an irreducible region into a reducible - thus the number_of_loops grew. Firstly, in tree_ssa_loop_init, number_of_loops was == 1, which means we didn't initialize SCEV. But then later on, in tree_ssa_loop_bounds, the number_of_loops was 2, thus we called estimate_numbers_of_iterations. Oops. So fixed by always initializing SCEV in the loop initialization on the tree level. Another approach would be to skip the whole loop pipeline - but then we'd miss e.g. the BB vectorization. Richi: no, I didn't forget to change the TODO_update_ssa to 0, but that ICEd pretty soon when building gcc :(. Regtested/bootstrapped on x86_64-linux, ok for trunk? 2013-02-25 Marek Polacek PR tree-optimization/56426 * tree-ssa-loop.c (tree_ssa_loop_init): Always call scev_initialize. * gcc.dg/pr56436.c: New test. Marek --- gcc/tree-ssa-loop.c.mp 2013-02-25 13:06:47.212132327 +0100 +++ gcc/tree-ssa-loop.c 2013-02-25 20:09:30.668978936 +0100 @@ -70,10 +70,13 @@ tree_ssa_loop_init (void) | LOOPS_HAVE_RECORDED_EXITS); rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa); + /* We might discover new loops, e.g. when turning irreducible + regions into reducible. */ + scev_initialize (); + if (number_of_loops () <= 1) return 0; - scev_initialize (); return 0; } --- gcc/testsuite/gcc.dg/pr56436.c.mp 2013-02-25 20:19:10.213561026 +0100 +++ gcc/testsuite/gcc.dg/pr56436.c 2013-02-25 20:19:02.944541180 +0100 @@ -0,0 +1,22 @@ +/* PR tree-optimization/56426 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int a, *c; + +void +f (void) +{ + int b = 0; + + for (a = 0;; a++) + if (--b) + { + if (a) + lbl: + a++; + + c = &b; + goto lbl; + } +}