From patchwork Tue Aug 16 20:07:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 110218 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 61925B6F7E for ; Wed, 17 Aug 2011 06:08:26 +1000 (EST) Received: (qmail 14292 invoked by alias); 16 Aug 2011 20:08:22 -0000 Received: (qmail 14250 invoked by uid 22791); 16 Aug 2011 20:08:15 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, 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, 16 Aug 2011 20:07:56 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7GK7uA1028494 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Aug 2011 16:07:56 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7GK7urP029509; Tue, 16 Aug 2011 16:07:56 -0400 Received: from localhost.localdomain (ovpn-113-25.phx2.redhat.com [10.3.113.25]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p7GK7sLm026025; Tue, 16 Aug 2011 16:07:55 -0400 Message-ID: <4E4ACE1F.8090004@redhat.com> Date: Tue, 16 Aug 2011 16:07:59 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110621 Fedora/3.1.11-1.fc14 Thunderbird/3.1.11 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Jeff Law Subject: RFA: patch to solve PR48455 and improve code size for -Os 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 After a lot of thinking and some experiments, I did not find a better solution to considerably (like on 0.2% - 0.3% on ARM SPEC2000) improve code size than use of non-regional RA for -Os. So the patch makes one region allocation is default for -Os. I don't use function optimize_function_for_size_p because I'd like to keep possibility still set up regions independedly of used -O option. This final patch removes ARM code size regression reported on http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48455. The patch was successfully bootstrapped on x86-64 and ppc64 (actually the generated code is not changed for -O2). Is it ok to commit? 2011-08-16 Vladimir Makarov PR rtl-optimization/48455 * doc/invoke.texi (-fira-region): Document default values. * flags-types.h (enum ira_region): Add new value IRA_REGION_AUTODETECT. * common.opt (fira-region): Set up initial value to IRA_REGION_AUTODETECT. * toplev.c (process_options): Set up flag_ira_region depending on -O options. * ira.c (ira.c): Remove optimize guard for ira_build. Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 177573) +++ doc/invoke.texi (working copy) @@ -6661,13 +6661,16 @@ rule generates a better code. Use specified regions for the integrated register allocator. The @var{region} argument should be one of @code{all}, @code{mixed}, or @code{one}. The first value means using all loops as register -allocation regions, the second value which is the default means using -all loops except for loops with small register pressure as the -regions, and third one means using all function as a single region. -The first value can give best result for machines with small size and -irregular register set, the third one results in faster and generates -decent code and the smallest size code, and the default value usually -give the best results in most cases and for most architectures. +allocation regions, the second value which is enabled by default when +compiling with optimization for speed (@option{-O}, @option{-O2}, +@dots{}) means using all loops except for loops with small register +pressure as the regions, and third one which is enabled by default for +@option{-Os} or @option{-O0} means using all function as a single +region. The first value can give best result for machines with small +size and irregular register set, the third one results in faster and +generates decent code and the smallest size code, and the second value +usually give the best results in most cases and for most +architectures. @item -fira-loop-pressure @opindex fira-loop-pressure Index: toplev.c =================================================================== --- toplev.c (revision 177573) +++ toplev.c (working copy) @@ -1289,6 +1289,11 @@ process_options (void) "and -ftree-loop-linear)"); #endif + /* One region RA really helps to decrease the code size. */ + if (flag_ira_region == IRA_REGION_AUTODETECT) + flag_ira_region + = optimize_size || !optimize ? IRA_REGION_ONE : IRA_REGION_MIXED; + /* Unrolling all loops implies that standard loop unrolling must also be done. */ if (flag_unroll_all_loops) Index: flag-types.h =================================================================== --- flag-types.h (revision 177573) +++ flag-types.h (working copy) @@ -118,7 +118,11 @@ enum ira_region { IRA_REGION_ONE, IRA_REGION_ALL, - IRA_REGION_MIXED + IRA_REGION_MIXED, + /* This value means that there were no options -fira-region on the + command line and that we should choose a value depending on the + used -O option. */ + IRA_REGION_AUTODETECT }; /* The options for excess precision. */ Index: common.opt =================================================================== --- common.opt (revision 177573) +++ common.opt (working copy) @@ -1313,7 +1313,7 @@ EnumValue Enum(ira_algorithm) String(priority) Value(IRA_ALGORITHM_PRIORITY) fira-region= -Common Joined RejectNegative Enum(ira_region) Var(flag_ira_region) Init(IRA_REGION_MIXED) +Common Joined RejectNegative Enum(ira_region) Var(flag_ira_region) Init(IRA_REGION_AUTODETECT) -fira-region=[one|all|mixed] Set regions for IRA Enum Index: ira.c =================================================================== --- ira.c (revision 177573) +++ ira.c (working copy) @@ -3617,9 +3617,8 @@ ira (FILE *f) if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL) fprintf (ira_dump_file, "Building IRA IR\n"); - loops_p = ira_build (optimize - && (flag_ira_region == IRA_REGION_ALL - || flag_ira_region == IRA_REGION_MIXED)); + loops_p = ira_build (flag_ira_region == IRA_REGION_ALL + || flag_ira_region == IRA_REGION_MIXED); ira_assert (ira_conflicts_p || !loops_p);