diff mbox

Possible fix for perofmrance issue discussed in PR64043

Message ID 20150124065244.GA9844@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Jan. 24, 2015, 6:52 a.m. UTC
Igor noticed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64043#c13
a regression caused by the option streaming patch on LTO SPEC scores.
While looking for posisble causes I noticed that x86_tune_cost is not properly
restored at cfun change. Fixed by the following patch.
Igor, does it fix the regression by any chance?

Bootstrapped/regtested x86_64-linux, comitted.

	* i386.opt (prefetch_sse): New targetsave.
	* i386.c (ix86_function_specific_save): Save prefetch_sse.
	(ix86_function_specific_restore): Restore prefetch_sse and initialize
	ix86_cost/ix86_tune_cost.

----- End forwarded message -----
diff mbox

Patch

Index: config/i386/i386.opt
===================================================================
--- config/i386/i386.opt	(revision 219969)
+++ config/i386/i386.opt	(working copy)
@@ -60,6 +60,10 @@  const char *x_ix86_tune_string
 TargetSave
 unsigned char schedule
 
+;; True if processor has SSE prefetch instruction.
+TargetSave
+unsigned char prefetch_sse
+
 ;; branch cost
 TargetSave
 unsigned char branch_cost
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c	(revision 219969)
+++ config/i386/i386.c	(working copy)
@@ -4466,6 +4466,7 @@  ix86_function_specific_save (struct cl_t
 {
   ptr->arch = ix86_arch;
   ptr->schedule = ix86_schedule;
+  ptr->prefetch_sse = x86_prefetch_sse;
   ptr->tune = ix86_tune;
   ptr->branch_cost = ix86_branch_cost;
   ptr->tune_defaulted = ix86_tune_defaulted;
@@ -4523,6 +4524,7 @@  ix86_function_specific_restore (struct g
   ix86_arch = (enum processor_type) ptr->arch;
   ix86_schedule = (enum attr_cpu) ptr->schedule;
   ix86_tune = (enum processor_type) ptr->tune;
+  x86_prefetch_sse = ptr->prefetch_sse;
   opts->x_ix86_branch_cost = ptr->branch_cost;
   ix86_tune_defaulted = ptr->tune_defaulted;
   ix86_arch_specified = ptr->arch_specified;
@@ -4553,6 +4555,13 @@  ix86_function_specific_restore (struct g
   opts->x_ix86_tune_memset_strategy = ptr->x_ix86_tune_memset_strategy;
   opts->x_ix86_tune_no_default = ptr->x_ix86_tune_no_default;
   opts->x_ix86_veclibabi_type = ptr->x_ix86_veclibabi_type;
+  ix86_tune_cost = processor_target_table[ix86_tune].cost;
+  /* TODO: ix86_cost should be chosen at instruction or function granuality
+     so for cold code we use size_cost even in !optimize_size compilation.  */
+  if (opts->x_optimize_size)
+    ix86_cost = &ix86_size_cost;
+  else
+    ix86_cost = ix86_tune_cost;
 
   /* Recreate the arch feature tests if the arch changed */
   if (old_arch != ix86_arch)