From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30273 invoked by alias); 4 Feb 2015 13:21:38 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 30254 invoked by uid 89); 4 Feb 2015 13:21:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mx08-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx08-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 04 Feb 2015 13:21:36 +0000 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id t14DI8mB019967; Wed, 4 Feb 2015 14:21:33 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 1sasnfy531-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 04 Feb 2015 14:21:33 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id CB7EB31; Wed, 4 Feb 2015 13:20:40 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas6.st.com [10.75.90.73]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id A084321C0; Wed, 4 Feb 2015 13:21:30 +0000 (GMT) Received: from [164.129.122.197] (164.129.122.197) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.342.0; Wed, 4 Feb 2015 14:21:30 +0100 Message-ID: <54D21CD9.7040201@st.com> Date: Wed, 04 Feb 2015 13:21:00 -0000 From: Christian Bruel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: , , Uros Bizjak , "gcc-patches@gcc.gnu.org" Subject: [PATCH, x86] Add TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook Content-Type: multipart/mixed; boundary="------------070605090402000700070806" X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.13.68,1.0.33,0.0.0000 definitions=2015-02-04_03:2015-02-04,2015-02-04,1970-01-01 signatures=0 X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00243.txt.bz2 --------------070605090402000700070806 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1815 While trying to reduce the PR64835 case for ARM and x86, I noticed that the alignment flags are cleared for x86 when attribute optimized is used. With the attached testcases, the visible effects are twofold : 1) Functions compiled in with attribute optimize (-O2) are not aligned as if they were with the -O2 flag. 2) can_inline_edge_p fails because opts_for_fn (caller->decl) != opts_for_fn (callee->decl)) even-though they are compiled with the same optimization level. indeed we have: PR target/64835 * config/i386/i386.c (ix86_default_align): New function. (ix86_override_options_after_change): Call ix86_default_align. (TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE): New hook. (ix86_override_options_after_change): New function. 2015-02-06 Christian Bruel PR target/64835 * gcc.dg/ipa/iinline-attr.c: New test. * gcc.target/i386/iinline-attr-2.c: New test. Index: gcc/config/i386/i386.c =================================================================== --- gcc/config/i386/i386.c (revision 220394) +++ gcc/config/i386/i386.c (working copy) @@ -3105,6 +3105,35 @@ } +/* Default align_* from the processor table. */ + +static void +ix86_default_align (struct gcc_options *opts) +{ + if (opts->x_align_loops == 0) + { + opts->x_align_loops = processor_target_table[ix86_tune].align_loop; + align_loops_max_skip = processor_target_table[ix86_tune].align_loop_max_skip; + } + if (opts->x_align_jumps == 0) + { + opts->x_align_jumps = processor_target_table[ix86_tune].align_jump; + align_jumps_max_skip = processor_target_table[ix86_tune].align_jump_max_skip; + } + if (opts->x_align_functions == 0) + { + opts->x_align_functions = processor_target_table[ix86_tune].align_func; + } +} + +/* Implement TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE hook. */ + +static void +ix86_override_options_after_change (void) +{ + ix86_default_align (&global_options); +} + /* Override various settings based on options. If MAIN_ARGS_P, the options are from the command line, otherwise they are from attributes. */ @@ -3902,20 +3931,7 @@ opts->x_ix86_regparm = REGPARM_MAX; /* Default align_* from the processor table. */ - if (opts->x_align_loops == 0) - { - opts->x_align_loops = processor_target_table[ix86_tune].align_loop; - align_loops_max_skip = processor_target_table[ix86_tune].align_loop_max_skip; - } - if (opts->x_align_jumps == 0) - { - opts->x_align_jumps = processor_target_table[ix86_tune].align_jump; - align_jumps_max_skip = processor_target_table[ix86_tune].align_jump_max_skip; - } - if (opts->x_align_functions == 0) - { - opts->x_align_functions = processor_target_table[ix86_tune].align_func; - } + ix86_default_align (opts); /* Provide default for -mbranch-cost= value. */ if (!opts_set->x_ix86_branch_cost) @@ -51928,6 +51944,9 @@ #undef TARGET_PROMOTE_FUNCTION_MODE #define TARGET_PROMOTE_FUNCTION_MODE ix86_promote_function_mode +#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE +#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE ix86_override_options_after_change + #undef TARGET_MEMBER_TYPE_FORCES_BLK #define TARGET_MEMBER_TYPE_FORCES_BLK ix86_member_type_forces_blk Index: gcc/testsuite/gcc.dg/ipa/iinline-attr.c =================================================================== --- gcc/testsuite/gcc.dg/ipa/iinline-attr.c (revision 0) +++ gcc/testsuite/gcc.dg/ipa/iinline-attr.c (working copy) @@ -0,0 +1,27 @@ +/* Verify that simple indirect calls are inlined even when + attribute __optimize is used. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-inline" } */ + +extern void non_existent(int); + +static void hooray () +{ + non_existent (1); +} + +__attribute__ ((__optimize__ ("O2"))) +static void hiphip (void (*f)()) +{ + non_existent (2); + f (); +} + +int test (void) +{ + hiphip (hooray); + return 0; +} + +/* { dg-final { scan-ipa-dump "hooray\[^\\n\]*inline copy in test" "inline" } } */ +/* { dg-final { cleanup-ipa-dump "inline" } } */ Index: gcc/testsuite/gcc.target/i386/iinline-attr-2.c =================================================================== --- gcc/testsuite/gcc.target/i386/iinline-attr-2.c (revision 0) +++ gcc/testsuite/gcc.target/i386/iinline-attr-2.c (working copy) @@ -0,0 +1,29 @@ +/* Verify that alignment flags are set when attribute __optimize is used. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +extern void non_existent(int); + +__attribute__ ((__optimize__ ("O2"))) +static void hooray () +{ + non_existent (1); +} + +__attribute__ ((__optimize__ ("O2"))) +static void hiphip (void (*f)()) +{ + non_existent (2); + f (); +} + +__attribute__ ((__optimize__ ("O2"))) +int test (void) +{ + hiphip (hooray); + return 0; +} + +/* { dg-final { scan-assembler "p2align" } } */ + + --------------070605090402000700070806--