From patchwork Fri Nov 16 16:36:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 199684 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 629E52C0085 for ; Sat, 17 Nov 2012 03:36:46 +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=1353688607; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=RPfAbSi ZGnOZEo7n8298Wa385UA=; b=PgdnqJt1uwQoqwDVz+GZBjYp2JJMBLYxOOK+QuU hquwYbmW/rCP2lghkpDeJK0Oy/KdVmAbCSsl5Qmho24wMz1enCTL+Jz+5Y02vpPZ uJu1oG0Ar17PnoBY3zENDzc8xgzKnGtPxf+sKUYhBXBXmkl2a65G+R1I7OvTjlzl oY6A= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=n2SlNS+IQLGbQbXpDu+35CLkl9ya13Rw3jUmffm9H2aww89omIzmKPEodRhssF RUhnJuX5CcEIV03C7mTKfJYKzdNbG8RvYymbyoY0YIsycKH9vnAyJ29zZcSiDPYa moTZB6/zgpEgA+5p6Ey7VS/K8eOs7RiOYufX6K7TPustE=; Received: (qmail 22601 invoked by alias); 16 Nov 2012 16:36:42 -0000 Received: (qmail 22449 invoked by uid 22791); 16 Nov 2012 16:36:41 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, 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; Fri, 16 Nov 2012 16:36:36 +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 qAGGaZdK022499 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 16 Nov 2012 11:36:36 -0500 Received: from Mair.local (vpn-8-146.rdu.redhat.com [10.11.8.146]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qAGGaYsA008098 for ; Fri, 16 Nov 2012 11:36:35 -0500 Message-ID: <50A66B92.2050008@redhat.com> Date: Fri, 16 Nov 2012 11:36:34 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR55330 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 The following patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55330 The problem was in a complex interaction of inheritance and constraint passes. The test would be compiled successfully if we increased the number constraint passes. But for such pass interaction, it hard to know how many passes we need (it can be depended on register pressure). So my solution for the problem is to put a limit on number of inheritance passes. I did some experiments. The most important is the first inheritance pass. The 3rd inheritance pass has practically no affect on code generation on most tests, e.g. SPEC2000 code on x86-64 is not changed when we add the 3rd pass. The limit might be defined as a compiler parameter but after some thoughts I've decided not to do this as it is not easy to describe constraints on the value and changing the value I use has no practical sense. The patch was successfully bootstrapped on x86/x86-64. Committed as rev. 193567. 2012-11-16 Vladimir Makarov PR rtl-optimization/55330 * lra-constraints.c (MAX_INHERITANCE_PASSES): New macro. (lra_inheritance, lra_undo_inheritance): Use it to limit number of the passes. 2012-11-16 Vladimir Makarov PR rtl-optimization/55330 * gfortran.dg/pr55330.f90: New test. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 193557) +++ lra-constraints.c (working copy) @@ -4633,6 +4633,21 @@ inherit_in_ebb (rtx head, rtx tail) return change_p; } +/* The maximal number of inheritance/split passes in LRA. It should + be more 1 in order to perform caller saves transformations and much + less MAX_CONSTRAINT_ITERATION_NUMBER to prevent LRA to do as many + as permitted constraint passes in some complicated cases. The + first inheritance/split pass has a biggest impact on generated code + quality. Each subsequent affects generated code in less degree. + For example, the 3rd pass does not change generated SPEC2000 code + at all on x86-64. */ +#define MAX_INHERITANCE_PASSES 2 + +#if MAX_INHERITANCE_PASSES <= 0 \ + || MAX_INHERITANCE_PASSES >= MAX_CONSTRAINT_ITERATION_NUMBER - 8 +#error wrong MAX_INHERITANCE_PASSES value +#endif + /* This value affects EBB forming. If probability of edge from EBB to a BB is not greater than the following value, we don't add the BB to EBB. */ @@ -4649,8 +4664,10 @@ lra_inheritance (void) basic_block bb, start_bb; edge e; - timevar_push (TV_LRA_INHERITANCE); lra_inheritance_iter++; + if (lra_inheritance_iter > MAX_INHERITANCE_PASSES) + return; + timevar_push (TV_LRA_INHERITANCE); if (lra_dump_file != NULL) fprintf (lra_dump_file, "\n********** Inheritance #%d: **********\n\n", lra_inheritance_iter); @@ -4920,6 +4937,8 @@ lra_undo_inheritance (void) bool change_p; lra_undo_inheritance_iter++; + if (lra_undo_inheritance_iter > MAX_INHERITANCE_PASSES) + return false; if (lra_dump_file != NULL) fprintf (lra_dump_file, "\n********** Undoing inheritance #%d: **********\n\n", Index: testsuite/gfortran.dg/pr55330.f90 =================================================================== --- testsuite/gfortran.dg/pr55330.f90 (revision 0) +++ testsuite/gfortran.dg/pr55330.f90 (working copy) @@ -0,0 +1,73 @@ +! PR rtl-optimization/55330 +! { dg-do compile } +! { dg-options "-O -fPIC -fno-dse -fno-guess-branch-probability" } + +module global + public p, line + interface p + module procedure p + end interface + character(128) :: line = 'abcdefghijklmnopqrstuvwxyz' +contains + subroutine p() + character(128) :: word + word = line + call redirect_((/word/)) + end subroutine + subroutine redirect_ (ch) + character(*) :: ch(:) + if (ch(1) /= line) call abort () + end subroutine redirect_ +end module global + +module my_module + implicit none + type point + real :: x + end type point + type(point), pointer, public :: stdin => NULL() +contains + subroutine my_p(w) + character(128) :: w + call r(stdin,(/w/)) + end subroutine my_p + subroutine r(ptr, io) + use global + type(point), pointer :: ptr + character(128) :: io(:) + if (associated (ptr)) call abort () + if (io(1) .ne. line) call abort () + end subroutine r +end module my_module + +program main + use global + use my_module + + integer :: i(6) = (/1,6,3,4,5,2/) + character (6) :: a = 'hello ', t + character(len=1) :: s(6) = (/'g','g','d','d','a','o'/) + equivalence (s, t) + + call option_stopwatch_s (a) + call p () + call my_p (line) + + s = s(i) + call option_stopwatch_a ((/a,'hola! ', t/)) + +contains + + subroutine option_stopwatch_s(a) + character (*), intent(in) :: a + character (len=len(a)) :: b + + b = 'hola! ' + call option_stopwatch_a((/a, b, 'goddag'/)) + end subroutine option_stopwatch_s + subroutine option_stopwatch_a (a) + character (*) :: a(:) + if (any (a .ne. (/'hello ','hola! ','goddag'/))) call abort () + end subroutine option_stopwatch_a + +end program main