From patchwork Tue Dec 20 21:32:41 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 132522 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 0EC12B7049 for ; Wed, 21 Dec 2011 08:33:03 +1100 (EST) Received: (qmail 31752 invoked by alias); 20 Dec 2011 21:33:01 -0000 Received: (qmail 31740 invoked by uid 22791); 20 Dec 2011 21:33:01 -0000 X-SWARE-Spam-Status: No, hits=-5.2 required=5.0 tests=AWL, BAYES_00, 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; Tue, 20 Dec 2011 21:32:42 +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 pBKLWgtl028763 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 20 Dec 2011 16:32:42 -0500 Received: from toll.yyz.redhat.com (unused [10.15.16.165] (may be forged)) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id pBKLWfeS012147 for ; Tue, 20 Dec 2011 16:32:42 -0500 Message-ID: <4EF0FEF9.4050007@redhat.com> Date: Tue, 20 Dec 2011 16:32:41 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.23) Gecko/20110928 Fedora/3.1.15-1.fc14 Thunderbird/3.1.15 MIME-Version: 1.0 To: gcc-patches Subject: patch for PR49865 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 solves PR49865. The problem is described on http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49865 The patch changes code a bit only for gcc, crafty, and mesa on x86. There is no visible change in the performance. Only code for crafty is changed on x86-64 and improvement in the performance is about 0.3%. The patch was successfully bootstrapped on x86/x86-64. The patch has been committed as rev. 182553. 2011-12-20 Vladimir Makarov PR target/49865 * ira-costs.c (find_costs_and_classes): Prefer registers even if the memory cost is the same. Index: ira-costs.c =================================================================== --- ira-costs.c (revision 182552) +++ ira-costs.c (working copy) @@ -1693,7 +1693,14 @@ find_costs_and_classes (FILE *dump_file) else if (i_costs[k] == best_cost) best = ira_reg_class_subunion[best][rclass]; if (pass == flag_expensive_optimizations - && i_costs[k] < i_mem_cost + /* We still prefer registers to memory even at this + stage if their costs are the same. We will make + a final decision during assigning hard registers + when we have all info including more accurate + costs which might be affected by assigning hard + registers to other pseudos because the pseudos + involved in moves can be coalesced. */ + && i_costs[k] <= i_mem_cost && (reg_class_size[reg_class_subunion[alt_class][rclass]] > reg_class_size[alt_class])) alt_class = reg_class_subunion[alt_class][rclass];