From patchwork Thu Jul 1 12:52:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 57546 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 111BD100811 for ; Thu, 1 Jul 2010 22:51:57 +1000 (EST) Received: (qmail 5896 invoked by alias); 1 Jul 2010 12:51:55 -0000 Received: (qmail 5885 invoked by uid 22791); 1 Jul 2010 12:51:53 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD 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; Thu, 01 Jul 2010 12:51:48 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o61Cpk1m030710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 1 Jul 2010 08:51:47 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o61CpjpE032248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 1 Jul 2010 08:51:46 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o61CqfAO007815 for ; Thu, 1 Jul 2010 14:52:41 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o61CqfSS007814 for gcc-patches@gcc.gnu.org; Thu, 1 Jul 2010 14:52:41 +0200 Date: Thu, 1 Jul 2010 14:52:41 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Backport of PR40421 to 4.4 branch Message-ID: <20100701125241.GV25077@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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! The pr40421.f90 testcase below ICEs on the 4.4 branch, fixed by backporting richi's fix. Incidentally, that testcase stopped ICEing when predcom has been moved in passes.c, while gamess the other testcase richi committed started failing at that point. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to 4.4 branch. Will commit the new testcase to 4.6/4.5 too. 2010-07-01 Jakub Jelinek Backport from mainline 2009-06-13 Richard Guenther PR tree-optimization/40421 * tree-predcom.c (should_unroll_loop_p): Remove. (tree_predictive_commoning_loop): Use can_unroll_loop_p. * gfortran.fortran-torture/compile/pr40421.f: New testcase. * gfortran.fortran-torture/compile/pr40421.f90: New test. Jakub --- gcc/tree-predcom.c (revision 148457) +++ gcc/tree-predcom.c (revision 148458) @@ -1870,43 +1870,6 @@ execute_pred_commoning_cbck (struct loop execute_pred_commoning (loop, dta->chains, dta->tmp_vars); } -/* Returns true if we can and should unroll LOOP FACTOR times. Number - of iterations of the loop is returned in NITER. */ - -static bool -should_unroll_loop_p (struct loop *loop, unsigned factor, - struct tree_niter_desc *niter) -{ - edge exit; - - if (factor == 1) - return false; - - /* Check whether unrolling is possible. We only want to unroll loops - for that we are able to determine number of iterations. We also - want to split the extra iterations of the loop from its end, - therefore we require that the loop has precisely one - exit. */ - - exit = single_dom_exit (loop); - if (!exit) - return false; - - if (!number_of_iterations_exit (loop, exit, niter, false)) - return false; - - /* And of course, we must be able to duplicate the loop. */ - if (!can_duplicate_loop_p (loop)) - return false; - - /* The final loop should be small enough. */ - if (tree_num_loop_insns (loop, &eni_size_weights) * factor - > (unsigned) PARAM_VALUE (PARAM_MAX_UNROLLED_INSNS)) - return false; - - return true; -} - /* Base NAME and all the names in the chain of phi nodes that use it on variable VAR. The phi nodes are recognized by being in the copies of the header of the LOOP. */ @@ -2544,7 +2507,8 @@ tree_predictive_commoning_loop (struct l that its number of iterations is divisible by the factor. */ unroll_factor = determine_unroll_factor (chains); scev_reset (); - unroll = should_unroll_loop_p (loop, unroll_factor, &desc); + unroll = (unroll_factor > 1 + && can_unroll_loop_p (loop, unroll_factor, &desc)); exit = single_dom_exit (loop); /* Execute the predictive commoning transformations, and possibly unroll the --- gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f (revision 0) +++ gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f (revision 148458) @@ -0,0 +1,18 @@ + SUBROUTINE VROT2(N,DIS) + IMPLICIT DOUBLE PRECISION (A-H,O-Z) + PARAMETER(ZERO=0.0D+00) + COMMON /SYMSPD/ PTR(3,144) + DIMENSION DIS(3,2),TMP(3,2) + DO I = 1,3 + TMP1 = ZERO + DO J = 1,3 + TMP1 = TMP1 + PTR(I,N+J) + END DO + TMP(I,1) = TMP1 + END DO + DO I = 1,3 + DIS(I,1) = TMP(I,1) + END DO + RETURN + END + --- gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f90.jj 2010-07-01 12:22:03.000000000 +0200 +++ gcc/testsuite/gfortran.fortran-torture/compile/pr40421.f90 2010-07-01 12:21:29.000000000 +0200 @@ -0,0 +1,15 @@ +subroutine pr40421 (j, q, r) + double precision :: q(1,1), r(1,1,3) + save + integer :: i, j, m, n + double precision :: s, t, u + do i=1,2 + do m=1,j + do n=1,1 + s=q(n,m)*r(n,m,1) + t=q(n,m)*r(n,m,2) + u=q(n,m)*r(n,m,3) + end do + end do + end do +end