From patchwork Mon Apr 29 19:51:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 240496 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 05F962C00D3 for ; Tue, 30 Apr 2013 05:52:03 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=kcbVRVSJkcU1q34tdKefEG25ucvTA3/Q0v8RJ3txDeOtk+ Okc0a8VgmPuynkIhgdGVWtIJaBQ6ewjUMUFz0FaAER5AzXtb9mHqgZfws7aAlwnh fIGAy6CN2gI5bCM//k6f9x6N5N99pyH+JZ9dzA25g7VG1c7Op/qjUirsb7vX4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=Q2+NXBLpViDM0hQ2InMYVMGishs=; b=sPpbXv9DJVqsX2QQwBRD hkt14x04MOHh+v8atBBooGdJR4J3MBaeKMlXXdfQLu+ZmKL5bisOHLRb01ggpsCj FABOTmwT+YlsI917wEe6e6RIuwDkpjhjOehqxd0tQwyFv4/Ma/2FfqZGSYIRYef4 wN7znHLLxD3to8I7C5IBGyY= Received: (qmail 18214 invoked by alias); 29 Apr 2013 19:51:56 -0000 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 Received: (qmail 18204 invoked by uid 89); 29 Apr 2013 19:51:56 -0000 X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 29 Apr 2013 19:51:55 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3TJps7B004262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 29 Apr 2013 15:51:54 -0400 Received: from Mair.local (vpn-56-134.rdu2.redhat.com [10.10.56.134]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3TJprIq015502 for ; Mon, 29 Apr 2013 15:51:53 -0400 Message-ID: <517ECF58.6010904@redhat.com> Date: Mon, 29 Apr 2013 15:51:52 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: GCC Patches Subject: patch to fix PR57097 X-Virus-Found: No The following patch fixes: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57097 The patch was successfully bootstrapped and tested on x86/x86-64. Committed as rev. 198432. 2013-04-29 Vladimir Makarov PR target/57097 * lra-constraints.c (process_alt_operands): Discourage a bit more using memory for pseudos. Print cost dump for alternatives. Modify cost values for conflicts with early clobbers. (curr_insn_transform): Spill pseudos reassigned to NO_REGS. 2013-04-29 Vladimir Makarov PR target/57097 * gcc.target/i386/pr57097.c: New test. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 198422) +++ lra-constraints.c (working copy) @@ -2013,7 +2013,7 @@ process_alt_operands (int only_alternati although it might takes the same number of reloads. */ if (no_regs_p && REG_P (op)) - reject++; + reject += 2; #ifdef SECONDARY_MEMORY_NEEDED /* If reload requires moving value through secondary @@ -2044,7 +2044,13 @@ process_alt_operands (int only_alternati or non-important thing to be worth to do it. */ overall = losers * LRA_LOSER_COST_FACTOR + reject; if ((best_losers == 0 || losers != 0) && best_overall < overall) - goto fail; + { + if (lra_dump_file != NULL) + fprintf (lra_dump_file, + " alt=%d,overall=%d,losers=%d -- reject\n", + nalt, overall, losers); + goto fail; + } curr_alt[nop] = this_alternative; COPY_HARD_REG_SET (curr_alt_set[nop], this_alternative_set); @@ -2139,7 +2145,10 @@ process_alt_operands (int only_alternati curr_alt_dont_inherit_ops[curr_alt_dont_inherit_ops_num++] = last_conflict_j; losers++; - overall += LRA_LOSER_COST_FACTOR; + /* Early clobber was already reflected in REJECT. */ + lra_assert (reject > 0); + reject--; + overall += LRA_LOSER_COST_FACTOR - 1; } else { @@ -2163,7 +2172,10 @@ process_alt_operands (int only_alternati } curr_alt_win[i] = curr_alt_match_win[i] = false; losers++; - overall += LRA_LOSER_COST_FACTOR; + /* Early clobber was already reflected in REJECT. */ + lra_assert (reject > 0); + reject--; + overall += LRA_LOSER_COST_FACTOR - 1; } } small_class_operands_num = 0; @@ -2171,6 +2183,11 @@ process_alt_operands (int only_alternati small_class_operands_num += SMALL_REGISTER_CLASS_P (curr_alt[nop]) ? 1 : 0; + if (lra_dump_file != NULL) + fprintf (lra_dump_file, " alt=%d,overall=%d,losers=%d," + "small_class_ops=%d,rld_nregs=%d\n", + nalt, overall, losers, small_class_operands_num, reload_nregs); + /* If this alternative can be made to work by reloading, and it needs less reloading than the others checked so far, record it as the chosen goal for reloading. */ @@ -3136,7 +3153,15 @@ curr_insn_transform (void) spilled. Spilled scratch pseudos are transformed back to scratches at the LRA end. */ && lra_former_scratch_operand_p (curr_insn, i)) - change_class (REGNO (op), NO_REGS, " Change", true); + { + int regno = REGNO (op); + change_class (regno, NO_REGS, " Change", true); + if (lra_get_regno_hard_regno (regno) >= 0) + /* We don't have to mark all insn affected by the + spilled pseudo as there is only one such insn, the + current one. */ + reg_renumber[regno] = -1; + } continue; } Index: testsuite/gcc.target/i386/pr57097.c =================================================================== --- testsuite/gcc.target/i386/pr57097.c (revision 0) +++ testsuite/gcc.target/i386/pr57097.c (working copy) @@ -0,0 +1,29 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fPIC" } */ +extern double ad[], bd[], cd[], dd[]; +extern long long all[], bll[], cll[], dll[]; + +int +main (int i, char **a) +{ + bd[i] = i + 64; + if (i % 3 == 0) + { + cd[i] = i; + } + dd[i] = i / 2; + ad[i] = i * 2; + if (i % 3 == 1) + { + dll[i] = 127; + } + dll[i] = i; + cll[i] = i * 2; + switch (i % 3) + { + case 0: + bll[i] = i + 64; + } + all[i] = i / 2; + return 0; +}