From a51fa0f4caad62b4dcc3590a9ec611236b8ef1f9 Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Fri, 25 Jul 2008 23:44:24 +0000 Subject: [PATCH] Fix IA-64 breakage... Fix IA-64 breakage; Make hot/cold optimization conversation port specific; Move disabling of scheduling from OVERRIDE_OPTIONS to OPTIMIZATION_OPTIONS Files modified: gcc/doc/extend.texi gcc/doc/tm.texi gcc/target.h gcc/ChangeLog gcc/testsuite/gcc.target/i386/cmov8.c gcc/testsuite/gcc.target/i386/funcspec-10.c gcc/testsuite/gcc.target/i386/funcspec-11.c gcc/testsuite/ChangeLog gcc/target-def.h gcc/c-common.c gcc/config/i386/i386.c gcc/config/ia64/ia64.c From-SVN: r138154 --- gcc/ChangeLog | 43 +++++++++++++++++++++ gcc/c-common.c | 9 +++-- gcc/config/i386/i386.c | 19 +++++---- gcc/config/ia64/ia64.c | 16 ++++++-- gcc/doc/extend.texi | 10 +++-- gcc/doc/tm.texi | 7 ++-- gcc/target-def.h | 10 +++++ gcc/target.h | 6 +++ gcc/testsuite/ChangeLog | 7 ++++ gcc/testsuite/gcc.target/i386/cmov8.c | 13 +++++++ gcc/testsuite/gcc.target/i386/funcspec-10.c | 15 +++++++ gcc/testsuite/gcc.target/i386/funcspec-11.c | 15 +++++++ 12 files changed, 149 insertions(+), 21 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/cmov8.c create mode 100644 gcc/testsuite/gcc.target/i386/funcspec-10.c create mode 100644 gcc/testsuite/gcc.target/i386/funcspec-11.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 63f0ed2ef72..ed4a31c36be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,46 @@ +2008-07-25 Michael Meissner + + * doc/extend.texi (hot attribute): Document that the hot attribute + turns on -O3 for some ports. + (cold attribute): Document that the cold attribute turns on -Os + for some ports + + * doc/tm.texi (OPTIMIZATION_OPTIONS): Update documentation to + reflect function specific option support. + + * target.h (struct target_option_hooks): Add fields to say whether + the cold attribute implies -Os and the hot attribute implies -O3. + + * target-def.h (TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION): + By default, do not turn on -Os for cold functions. + (TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION): By default, do + not turn on -O3 for hot functions. + + * c-common.c (handle_hot_attribute): Use target hook to determine + if hot functions should enable -O3. + (handle_cold_attribute): Use target hook to determine if cold + functions should enable -Os. + + * config/i386/i386.c (ix86_target_string): Add -m3dnowa support. + (override_options): Move disable scheduling to + optimization_options. + (optimization_options): Disable scheduling here, not + override_options. + (TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION): Define. + (TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION): Define. + + * config/ia64/ia64.c (ia64_override_options): Move setting + scheduling flags to ia64_optimization_options. + (ia64_optimization_options): Disable scheduling options here, and + not in ia64_override_options. + (TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION): Define. + (TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION): Define. + +2008-07-25 H.J. Lu + + PR target/36936 + * config/i386/i386.c (override_options): Don't clear TARGET_CMOVE. + 2008-07-25 Martin Jambor PR tree-optimization/36926 diff --git a/gcc/c-common.c b/gcc/c-common.c index fbb5f88fac8..c9ffd9c9aa3 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5046,7 +5046,6 @@ handle_hot_attribute (tree *node, tree name, tree ARG_UNUSED (args), name, "cold"); *no_add_attrs = true; } - else { tree old_opts = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node); @@ -5054,6 +5053,7 @@ handle_hot_attribute (tree *node, tree name, tree ARG_UNUSED (args), /* If we are not at -O3, but are optimizing, turn on -O3 optimizations just for this one function. */ if (((optimize > 0 && optimize < 3) || optimize_size) + && targetm.target_option.hot_attribute_sets_optimization && (!old_opts || old_opts == optimization_default_node)) { /* Create the hot optimization node if needed. */ @@ -5071,9 +5071,9 @@ handle_hot_attribute (tree *node, tree name, tree ARG_UNUSED (args), DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_hot_node; } + /* Most of the rest of the hot processing is done later with + lookup_attribute. */ } - /* Most of the rest of the hot processing is done later with - lookup_attribute. */ } else { @@ -5105,6 +5105,7 @@ handle_cold_attribute (tree *node, tree name, tree ARG_UNUSED (args), /* If we are optimizing, but not optimizing for space, turn on -Os optimizations just for this one function. */ if (optimize && !optimize_size + && targetm.target_option.cold_attribute_sets_optimization && (!old_opts || old_opts == optimization_default_node)) { /* Create the cold optimization node if needed. */ @@ -5122,6 +5123,8 @@ handle_cold_attribute (tree *node, tree name, tree ARG_UNUSED (args), DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node) = optimization_cold_node; } + /* Most of the rest of the cold processing is done later with + lookup_attribute. */ } } else diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index fb4963fb721..7b4c243035a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2215,6 +2215,7 @@ ix86_target_string (int isa, int flags, const char *arch, const char *tune, { "-msse2", OPTION_MASK_ISA_SSE2 }, { "-msse", OPTION_MASK_ISA_SSE }, { "-m3dnow", OPTION_MASK_ISA_3DNOW }, + { "-m3dnowa", OPTION_MASK_ISA_3DNOW_A }, { "-mmmx", OPTION_MASK_ISA_MMX }, { "-mabm", OPTION_MASK_ISA_ABM }, { "-mpopcnt", OPTION_MASK_ISA_POPCNT }, @@ -3123,8 +3124,6 @@ override_options (bool main_args_p) target_flags |= MASK_ACCUMULATE_OUTGOING_ARGS; } - TARGET_CMOVE = 0; - /* For sane SSE instruction set generation we need fcomi instruction. It is safe to enable all CMOVE instructions. */ if (TARGET_SSE) @@ -3139,11 +3138,6 @@ override_options (bool main_args_p) *p = '\0'; } - /* When scheduling description is not available, disable scheduler pass - so it won't slow down the compilation and make x87 code slower. */ - if (!TARGET_SCHEDULE) - flag_schedule_insns_after_reload = flag_schedule_insns = 0; - if (!PARAM_SET_P (PARAM_SIMULTANEOUS_PREFETCHES)) set_param_value ("simultaneous-prefetches", ix86_cost->simultaneous_prefetches); @@ -3911,6 +3905,11 @@ optimization_options (int level, int size ATTRIBUTE_UNUSED) flag_schedule_insns = 0; #endif + /* When scheduling description is not available, disable scheduler pass + so it won't slow down the compilation and make x87 code slower. */ + if (!TARGET_SCHEDULE) + flag_schedule_insns_after_reload = flag_schedule_insns = 0; + if (TARGET_MACHO) /* The Darwin libraries never set errno, so we might as well avoid calling them when that's the only reason we would. */ @@ -27345,6 +27344,12 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree) #undef TARGET_OPTION_CAN_INLINE_P #define TARGET_OPTION_CAN_INLINE_P ix86_can_inline_p +#undef TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION +#define TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION true + +#undef TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION +#define TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION true + struct gcc_target targetm = TARGET_INITIALIZER; #include "gt-i386.h" diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index e93ae31b0bd..29a9a8dacf2 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -493,6 +493,12 @@ static const struct attribute_spec ia64_attribute_table[] = #undef TARGET_C_MODE_FOR_SUFFIX #define TARGET_C_MODE_FOR_SUFFIX ia64_c_mode_for_suffix +#undef TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION +#define TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION true + +#undef TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION +#define TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION true + struct gcc_target targetm = TARGET_INITIALIZER; typedef enum @@ -5232,9 +5238,6 @@ ia64_override_options (void) TARGET_INLINE_SQRT = INL_MAX_THR; } - ia64_flag_schedule_insns2 = flag_schedule_insns_after_reload; - flag_schedule_insns_after_reload = 0; - ia64_section_threshold = g_switch_set ? g_switch_value : IA64_DEFAULT_GVALUE; init_machine_status = ia64_init_machine_status; @@ -9927,6 +9930,13 @@ void ia64_optimization_options (int level ATTRIBUTE_UNUSED, int size ATTRIBUTE_UNUSED) { + /* Disable the second machine independent scheduling pass and use one for the + IA-64. This needs to be here instead of in OVERRIDE_OPTIONS because this + is done whenever the optimization is changed via #pragma GCC optimize or + attribute((optimize(...))). */ + ia64_flag_schedule_insns2 = flag_schedule_insns_after_reload; + flag_schedule_insns_after_reload = 0; + /* Let the scheduler form additional regions. */ set_param_value ("max-sched-extend-regions-iters", 2); diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index a8040920d65..4b1d302a48d 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -2853,7 +2853,7 @@ that affect more than one function. This can be used for instance to have frequently executed functions compiled with more aggressive optimization options that produce faster and larger code, while other functions can be called with less -aggressive options. The @code{hot} attribute implies +aggressive options. On some targets, the @code{hot} attribute implies @code{optimize("O3")}, and @code{cold} attribute implies @code{optimize("Os")}. @@ -2903,8 +2903,9 @@ are automatically detected and this attribute is ignored. The @code{hot} attribute is not implemented in GCC versions earlier than 4.3. -Starting with GCC 4.4, the @code{hot} attribute sets -@code{optimize("O3")} to turn on more aggressive optimization. +Starting with GCC 4.4, the @code{cold} attribute sets +@code{optimize("O3")} to turn on more aggressive optimization on the +the i386, x86_64, and IA-64 targets. @item cold @cindex @code{cold} function attribute @@ -2924,7 +2925,8 @@ are automatically detected and this attribute is ignored. The @code{cold} attribute is not implemented in GCC versions earlier than 4.3. Starting with GCC 4.4, the @code{cold} attribute sets -@code{optimize("Os")} to save space. +@code{optimize("Os")} to save space on the the i386, x86_64, and IA-64 +targets. @item regparm (@var{number}) @cindex @code{regparm} attribute diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 274e69b9802..5183736ccae 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -833,10 +833,9 @@ specified, 1 if @option{-O} is specified, and 0 if neither is specified. @var{size} is nonzero if @option{-Os} is specified and zero otherwise. -You should not use this macro to change options that are not -machine-specific. These should uniformly selected by the same -optimization level on all supported machines. Use this macro to enable -machine-specific optimizations. +This macro is run once at program startup and when the optimization +options are changed via @code{#pragma GCC optimize} or by using the +@code{optimize} attribute. @strong{Do not examine @code{write_symbols} in this macro!} The debugging options are not supposed to alter the diff --git a/gcc/target-def.h b/gcc/target-def.h index 1d138e5fb68..bf8c7e79eac 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -783,6 +783,14 @@ #define TARGET_OPTION_CAN_INLINE_P default_target_option_can_inline_p #endif +#ifndef TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION +#define TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION false +#endif + +#ifndef TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION +#define TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION false +#endif + #define TARGET_OPTION_HOOKS \ { \ TARGET_OPTION_VALID_ATTRIBUTE_P, \ @@ -791,6 +799,8 @@ TARGET_OPTION_PRINT, \ TARGET_OPTION_PRAGMA_PARSE, \ TARGET_OPTION_CAN_INLINE_P, \ + TARGET_OPTION_COLD_ATTRIBUTE_SETS_OPTIMIZATION, \ + TARGET_OPTION_HOT_ATTRIBUTE_SETS_OPTIMIZATION, \ } /* The whole shebang. */ diff --git a/gcc/target.h b/gcc/target.h index 468e5d7f083..a44ab0b51c7 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -989,6 +989,12 @@ struct gcc_target /* Function to determine if one function can inline another function. */ bool (*can_inline_p) (tree, tree); + + /* Whether the cold attribute changes the optimization level. */ + bool cold_attribute_sets_optimization; + + /* Whether the hot attribute changes the optimization level. */ + bool hot_attribute_sets_optimization; } target_option; /* For targets that need to mark extra registers as live on entry to diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 85ac795ca91..db8df624927 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2008-07-25 H.J. Lu + + PR target/36936 + * gcc.target/i386/cmov8.c: New. + * gcc.target/i386/funcspec-10.c: Likewise. + * gcc.target/i386/funcspec-11.c: Likewise. + 2008-07-25 Joseph Myers * lib/target-supports.exp (check_effective_target_arm_thumb1_ok): diff --git a/gcc/testsuite/gcc.target/i386/cmov8.c b/gcc/testsuite/gcc.target/i386/cmov8.c new file mode 100644 index 00000000000..639fb62b0c0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/cmov8.c @@ -0,0 +1,13 @@ +/* PR target/36936 */ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O2 -march=i686" } */ +/* { dg-final { scan-assembler "cmov\[^8\]" } } */ + +int +foo (int x) +{ + if (x < 0) + x = 1; + return x; +} diff --git a/gcc/testsuite/gcc.target/i386/funcspec-10.c b/gcc/testsuite/gcc.target/i386/funcspec-10.c new file mode 100644 index 00000000000..9446cdf8f35 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/funcspec-10.c @@ -0,0 +1,15 @@ +/* PR target/36936 */ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O2 -march=i686" } */ +/* { dg-final { scan-assembler-not "cmov" } } */ + +extern int foo (int) __attribute__((__option__("arch=i386"))); + +int +foo (int x) +{ + if (x < 0) + x = 1; + return x; +} diff --git a/gcc/testsuite/gcc.target/i386/funcspec-11.c b/gcc/testsuite/gcc.target/i386/funcspec-11.c new file mode 100644 index 00000000000..ec32e0c669e --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/funcspec-11.c @@ -0,0 +1,15 @@ +/* PR target/36936 */ +/* { dg-do compile } */ +/* { dg-require-effective-target ilp32 } */ +/* { dg-options "-O2 -march=i386" } */ +/* { dg-final { scan-assembler "cmov" } } */ + +extern int foo (int) __attribute__((__option__("arch=i686"))); + +int +foo (int x) +{ + if (x < 0) + x = 1; + return x; +} -- 2.30.2