diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d697ad1b104f59172a69bb5542164b0e87b9f13d..f56b07015f0cacd03292d7e7ab5523db29948fc9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2010-12-03  Jan Hubicka  <jh@suse.cz>
+
+	* Makefile.in (LTO_STREAMER_H): Add GCOV_IO_H.
+	* lto-cgraph.c (merge_profile_summaries): Fix thinko.
+
 2010-12-03  Jan Hubicka  <jh@suse.cz>
 
 	PR tree-optimization/46760
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 231500b23941b9213af9dcd1916f6a72f07ae2f1..949262b58c3c79ddb8d9b2e766de66f531a6dc59 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -975,7 +975,8 @@ IRA_INT_H = ira.h ira-int.h $(CFGLOOP_H) alloc-pool.h
 DBGCNT_H = dbgcnt.h dbgcnt.def
 EBITMAP_H = ebitmap.h sbitmap.h
 LTO_STREAMER_H = lto-streamer.h $(LINKER_PLUGIN_API_H) $(TARGET_H) \
-		$(CGRAPH_H) $(VEC_H) vecprim.h $(TREE_H) $(GIMPLE_H)
+		$(CGRAPH_H) $(VEC_H) vecprim.h $(TREE_H) $(GIMPLE_H) \
+		$(GCOV_IO_H)
 TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H)
 IPA_PROP_H = ipa-prop.h $(TREE_H) $(VEC_H) $(CGRAPH_H) $(GIMPLE_H)
 GSTAB_H = gstab.h stab.def
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index 140a926909ae6a1144a8e3079d222044a0ec0a35..76597a000ee868837ec4677ec4ab55aee3aaad7c 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -1504,16 +1504,14 @@ merge_profile_summaries (struct lto_file_decl_data **file_data_vec)
      During LTRANS we already have values of count_materialization_scale
      computed, so just update them.  */
   for (node = cgraph_nodes; node; node = node->next)
-    if (node->local.lto_file_data->profile_info.run_max)
+    if (node->local.lto_file_data->profile_info.runs)
       {
 	int scale;
-	if (node->local.lto_file_data->profile_info.runs)
-	  scale =
-	     ((node->count_materialization_scale * max_runs
-	       + node->local.lto_file_data->profile_info.run_max / 2)
-	      / node->local.lto_file_data->profile_info.run_max);
-	else
-	  scale = node->count_materialization_scale;
+
+	scale =
+	   ((node->count_materialization_scale * max_runs
+	     + node->local.lto_file_data->profile_info.runs / 2)
+	    / node->local.lto_file_data->profile_info.runs);
 	node->count_materialization_scale = scale;
 	if (scale < 0)
 	  fatal_error ("Profile information in %s corrupted",