This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, i386] Turn on -fschedule-insns and -fsched-pressure by default for x86-64


Hi,

Attached is the patch that proposes to turn on -fschedule-insns and -fsched-pressure by default at 
-O2 or higher (for speed-runs only) for x86-64 systems.  Enablement of these two flags could improve
the performance of floating point programs (For CFP2006, 2.29% under -O2, and  1.34% under -O3).
There is no apparent performance  impact on integer programs (as expected).

We have investigated this optimization since 4.5, and it is the time to turn on these two flags to enjoy
the performance gains.

The patch passed bootstrappings under -O2 and -O3 on  x86_64-unknown-linux-gnu, and passed
the gcc regression tests.

Is it OK to commit the patch?

Thanks,

Changpeng
From 60859804422c1e0093769eaa47b4cc2d95657f86 Mon Sep 17 00:00:00 2001
From: Changpeng Fang <chfang@houghton.(none)>
Date: Mon, 6 Dec 2010 11:03:07 -0800
Subject: [PATCH] Turn on -fschedule-insns and -fsched-pressure by default at -O2 or higher for x86-64.

	* common.opt (fschedule-insns): Add Init(0).

	* opts.c (default_options_table): Set default of -fschedule-insns to
	2 to differentiate it with the user setting of 1 (if any).

	* config/i386/i386.c (ix86_option_optimization_table): Turn on
	-fsched-pressure by default at -O2 or higher (for speed run only).
	(ix86_option_override_internal): Turn off -fschedule-insns by default
 	for 32-bit compilation.  Also, turn off -fsched-pressure by default if
	-fschedule-insns was not turned on.
---
 gcc/common.opt         |    2 +-
 gcc/config/i386/i386.c |   20 +++++++++++++++++---
 gcc/opts.c             |    2 +-
 3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 57f5b0a..72be118 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1570,7 +1570,7 @@ Common Ignore
 Does nothing.  Preserved for backward compatibility.
 
 fschedule-insns
-Common Report Var(flag_schedule_insns) Optimization
+Common Report Var(flag_schedule_insns) Init(0) Optimization
 Reschedule instructions before register allocation
 
 fschedule-insns2
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a66a0c4..226e4fc 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4079,6 +4079,19 @@ ix86_option_override_internal (bool main_args_p)
   if (!TARGET_SCHEDULE)
     flag_schedule_insns_after_reload = flag_schedule_insns = 0;
 
+#ifdef INSN_SCHEDULING
+  /* For 32-bit compilation, turn off -fschedule-insns by default to hide
+     the problem with not enough registers.  */
+  if (!TARGET_64BIT)
+    flag_schedule_insns = (flag_schedule_insns == 1);
+
+  /* If -fschedule-insns was not turned on, the default of -fsched-pressure
+     should be off.  On the other hand, if user turned on -fschedule-insns
+     for 32-bit compilation, the default of -fsched-presssure is kept on.  */
+  if (!flag_schedule_insns)
+    flag_sched_pressure = (flag_sched_pressure == 1);
+#endif
+
   maybe_set_param_value (PARAM_SIMULTANEOUS_PREFETCHES,
 			 ix86_cost->simultaneous_prefetches,
 			 global_options.x_param_values,
@@ -5031,10 +5044,11 @@ x86_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
 
 static const struct default_options ix86_option_optimization_table[] =
   {
-    /* Turn off -fschedule-insns by default.  It tends to make the
-       problem with not enough registers even worse.  */
+    /* Turn on -fsched-pressure by default at -O2 or higher.  This could
+       alleviate the problem with not enough registers caused by turning
+       on -fschedule-pressure (in opts.c).  */
 #ifdef INSN_SCHEDULING
-    { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 },
+    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fsched_pressure, NULL, 2 },
 #endif
 
 #ifdef SUBTARGET_OPTIMIZATION_OPTIONS
diff --git a/gcc/opts.c b/gcc/opts.c
index cd41c2a..7700f0a 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -483,7 +483,7 @@ static const struct default_options default_options_table[] =
     { OPT_LEVELS_2_PLUS, OPT_fpeephole2, NULL, 1 },
 #ifdef INSN_SCHEDULING
   /* Only run the pre-regalloc scheduling pass if optimizing for speed.  */
-    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 1 },
+    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_fschedule_insns, NULL, 2 },
     { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
 #endif
     { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
-- 
1.6.3.3

Attachment: schedule-improvement.txt
Description: schedule-improvement.txt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]