From patchwork Fri Dec 21 21:22:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 207876 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 8B0D02C0084 for ; Sat, 22 Dec 2012 08:22:33 +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=1356729753; 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=G3przO6 Iu8TTdxjPw9IaKEVtc/Y=; b=tfL6s6zC1lAPJCRtMQBrnHONudQ8CY0ZrWpDR1L 8tzPfk95qx/GchygYWUllzCCGe+Dwhm/XdpdgMGCcfpph0jj5YFFz/jPebbEnjhZ P7gr/KVmHf+7GYNIyQhFUC0up98EsgEhZGI8P0qukba7ysk/V20sDPW847iuicf/ v2NQ= 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=IwcREYSKkVkkCipx/wieILBLZTgw67P0B/DH40Q/d/CYWoD22+8Sw7rkusJR8y lPMIqkwWQcQysOAQzc5P+PaqlWfT1Rfd40Ukf9NuxHrFaEcBWwW9IAJR+GiFiz6z ktk8bdkDQ5T3wR3p8WTzXx+UWdTW1zh+fbszcVUMkwUos=; Received: (qmail 2278 invoked by alias); 21 Dec 2012 21:22:29 -0000 Received: (qmail 2269 invoked by uid 22791); 21 Dec 2012 21:22:29 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, 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; Fri, 21 Dec 2012 21:22:17 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBLLMHQi026613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 21 Dec 2012 16:22:17 -0500 Received: from Mair.local (vpn-52-122.rdu2.redhat.com [10.10.52.122]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBLLMGsE005709 for ; Fri, 21 Dec 2012 16:22:16 -0500 Message-ID: <50D4D307.109@redhat.com> Date: Fri, 21 Dec 2012 16:22:15 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR55775 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=55775 The bug is related to PR55330. The patch was successfully bootstrapped and tested on x86/x86-64. Committed as rev. 194680. 2012-12-21 Vladimir Makarov PR middle-end/55775 * lra-assigns.c (improve_inheritance): Do nothing after LRA_MAX_INHERITANCE_PASSES pass. * lra-constraints.c (MAX_CONSTRAINT_ITERATION_NUMBER): Rename to LRA_MAX_CONSTRAINT_ITERATION_NUMBER. Move to lra-int.h. (MAX_INHERITANCE_PASSES): Rename to LRA_MAX_INHERITANCE_PASSES. Move to lra-int.h. * lra-int.h (LRA_MAX_CONSTRAINT_ITERATION_NUMBER): Move from lra-constraints.c. (LRA_MAX_INHERITANCE_PASSES): Ditto. 2012-12-21 Vladimir Makarov PR middle-end/55775 * gcc.target/i386/pr55775.c: New test. Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 194677) +++ lra-assigns.c (working copy) @@ -1084,6 +1084,8 @@ improve_inheritance (bitmap changed_pseu lra_copy_t cp, next_cp; bitmap_iterator bi; + if (lra_inheritance_iter > LRA_MAX_INHERITANCE_PASSES) + return; n = 0; EXECUTE_IF_SET_IN_BITMAP (&lra_inheritance_pseudos, 0, k, bi) if (reg_renumber[k] >= 0 && lra_reg_info[k].nrefs != 0) Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 194677) +++ lra-constraints.c (working copy) @@ -3201,10 +3201,6 @@ loc_equivalence_callback (rtx loc, const return NULL_RTX; } -/* Maximum allowed number of constraint pass iterations after the last - spill pass. It is for preventing LRA cycling in a bug case. */ -#define MAX_CONSTRAINT_ITERATION_NUMBER 30 - /* Maximum number of generated reload insns per an insn. It is for preventing this pass cycling in a bug case. */ #define MAX_RELOAD_INSNS_NUMBER LRA_MAX_INSN_RELOADS @@ -3328,10 +3324,10 @@ lra_constraints (bool first_p) fprintf (lra_dump_file, "\n********** Local #%d: **********\n\n", lra_constraint_iter); lra_constraint_iter_after_spill++; - if (lra_constraint_iter_after_spill > MAX_CONSTRAINT_ITERATION_NUMBER) + if (lra_constraint_iter_after_spill > LRA_MAX_CONSTRAINT_ITERATION_NUMBER) internal_error ("Maximum number of LRA constraint passes is achieved (%d)\n", - MAX_CONSTRAINT_ITERATION_NUMBER); + LRA_MAX_CONSTRAINT_ITERATION_NUMBER); changed_p = false; lra_risky_transformations_p = false; new_insn_uid_start = get_max_uid (); @@ -4698,21 +4694,6 @@ 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. */ @@ -4730,7 +4711,7 @@ lra_inheritance (void) edge e; lra_inheritance_iter++; - if (lra_inheritance_iter > MAX_INHERITANCE_PASSES) + if (lra_inheritance_iter > LRA_MAX_INHERITANCE_PASSES) return; timevar_push (TV_LRA_INHERITANCE); if (lra_dump_file != NULL) @@ -5000,7 +4981,7 @@ lra_undo_inheritance (void) bool change_p; lra_undo_inheritance_iter++; - if (lra_undo_inheritance_iter > MAX_INHERITANCE_PASSES) + if (lra_undo_inheritance_iter > LRA_MAX_INHERITANCE_PASSES) return false; if (lra_dump_file != NULL) fprintf (lra_dump_file, Index: lra-int.h =================================================================== --- lra-int.h (revision 194677) +++ lra-int.h (working copy) @@ -249,6 +249,25 @@ typedef struct lra_insn_recog_data *lra_ #define LRA_LOSER_COST_FACTOR 6 #define LRA_MAX_REJECT 600 +/* Maximum allowed number of constraint pass iterations after the last + spill pass. It is for preventing LRA cycling in a bug case. */ +#define LRA_MAX_CONSTRAINT_ITERATION_NUMBER 30 + +/* 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 LRA_MAX_INHERITANCE_PASSES 2 + +#if LRA_MAX_INHERITANCE_PASSES <= 0 \ + || LRA_MAX_INHERITANCE_PASSES >= LRA_MAX_CONSTRAINT_ITERATION_NUMBER - 8 +#error wrong LRA_MAX_INHERITANCE_PASSES value +#endif + /* lra.c: */ extern FILE *lra_dump_file; Index: testsuite/gcc.target/i386/pr55775.c =================================================================== --- testsuite/gcc.target/i386/pr55775.c (revision 0) +++ testsuite/gcc.target/i386/pr55775.c (working copy) @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +int *ptr; +int *fn1 (int *); +int fn2 (int, int); +int fn3 (void); +int fn4 (int); + +static int +foo (int x, int y, int z) +{ + int b; + asm ("" : "=a" (b), "=&d" (x) : "0" (y), "1" (x), "mr" (z)); + return x; +} + +static int +bar (int x, int y) +{ + int a; + if (!y) + { + for (a = 0; a <= (x >> 1); ) + ; + a = foo (y, fn2 (2, x), x); + if (x) + a = x; + return a; + } +} + +static int +baz (int x, int y) +{ + int *a = ptr; + int t, xk1 = fn3 (), xk = x * xk1; + for (t = 0; t < xk; t += xk1) + { + if (fn4 (a[2])) + return -y; + a = fn1 (a); + } + return 0; +} + +void +test (int x, long y, int z) +{ + int a = fn3 (); + int b; + int c = bar (x, z); + for (b = 0; b <= y; b++) + c = baz (x, c); + fn2 (c, a); +}