RFC: ix86 / x86_64 register pressure aware scheduling

Message ID CABu31nPFeo=Yu2yCUePoHCV-jkTNX4=Xn0FrY-PBLAEctU-8Gg@mail.gmail.com
State New
Headers show

Commit Message

Steven Bosscher April 15, 2013, 7:33 p.m.

The attached patch enables register pressure aware scheduling for the
ix86 and x86_64 targets. It uses the optimistic algorithm to avoid
being overly conservative.

This is the same as what other CISCy targets, like s390, also do.

The motivation for this patch is the excessive spilling I've observed
in a few test cases with relatively large basic blocks, e.g.
encryption algorithms and codecs. The patch passes bootstrap+testing
on x86_64-unknown-linux-gnu and i686-unknown-linux-gnu, with a few new
failures due to PR56950.

Off-list, Uros, Honza and others have already looked at the patch and
benchmarked it. For x86_64 there is an overall improvement for SPEC2k
except that lucas regresses, but such a preliminary result is IMHO
very promising.

Comments/suggestions welcome :-)

* common/config/i386/i386-common.c (ix86_option_optimization_table):
	Do not disable insns scheduling.  Enable register pressure aware
	* config/i386/i386.c (ix86_option_override): Use the alternative,
	optimistic scheduling-pressure algorithm by default.


Index: common/config/i386/i386-common.c
--- common/config/i386/i386-common.c	(revision 197941)
+++ common/config/i386/i386-common.c	(working copy)
@@ -707,9 +707,15 @@  static const struct default_options ix86
     /* Enable redundant extension instructions removal at -O2 and higher.  */
     { OPT_LEVELS_2_PLUS, OPT_free, NULL, 1 },
-    /* Turn off -fschedule-insns by default.  It tends to make the
-       problem with not enough registers even worse.  */
-    { OPT_LEVELS_ALL, OPT_fschedule_insns, NULL, 0 },
+    /* Enable -fsched-pressure by default for all optimization levels.
+       Before SCHED_PRESSURE_MODEL register-pressure aware schedule was
+       available, -fschedule-insns was turned off completely by default for
+       this port, because scheduling before register allocation tends to
+       make the problem with not enough registers even worse.  However,
+       for very long basic blocks the scheduler can help bring register
+       pressure down significantly, and SCHED_PRESSURE_MODEL is still
+       conservative enough to avoid creating excessive register pressure.  */
+    { OPT_LEVELS_ALL, OPT_fsched_pressure, NULL, 1 },
Index: config/i386/i386.c
--- config/i386/i386.c	(revision 197941)
+++ config/i386/i386.c	(working copy)
@@ -3936,6 +3936,10 @@  ix86_option_override (void)
   ix86_option_override_internal (true);
+  /* Use the alternative scheduling-pressure algorithm by default.  */
+  maybe_set_param_value (PARAM_SCHED_PRESSURE_ALGORITHM, 2,
+			 global_options.x_param_values,
+			 global_options_set.x_param_values);
   /* This needs to be done at start up.  It's convenient to do it here.  */
   register_pass (&insert_vzeroupper_info);