From 172e74fa37372711b121792b3405b32c862cf171 Mon Sep 17 00:00:00 2001
From: Martin Jambor <mjambor@suse.cz>
Date: Fri, 31 Aug 2012 15:13:03 +0200
Subject: [PATCH] re PR middle-end/54394 (fatigue2 -flto run time regression)

2012-08-31  Martin Jambor  <mjambor@suse.cz>

	PR middle-end/54394
	* ipa-inline-analysis.c (estimate_function_body_sizes): Compute
	dominance info and loops whenever optimizing.

From-SVN: r190831
---
 gcc/ChangeLog             |  6 ++++++
 gcc/ipa-inline-analysis.c | 15 ++++++++++-----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 40a2444c1d8f..e1413eb19d74 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-08-31  Martin Jambor  <mjambor@suse.cz>
+
+	PR middle-end/54394
+	* ipa-inline-analysis.c (estimate_function_body_sizes): Compute
+	dominance info and loops whenever optimizing.
+
 2012-08-29  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 	    Richard Earnshaw  <richard.earnshaw@arm.com>
 
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index ca80a8b88ba4..a3f0a8eccf97 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2102,6 +2102,11 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
   info->conds = 0;
   info->entry = 0;
 
+  if (optimize && !early)
+    {
+      calculate_dominance_info (CDI_DOMINATORS);
+      loop_optimizer_init (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS);
+    }
 
   if (dump_file)
     fprintf (dump_file, "\nAnalyzing function body size: %s\n",
@@ -2270,9 +2275,6 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
       loop_iterator li;
       predicate loop_iterations = true_predicate ();
 
-      calculate_dominance_info (CDI_DOMINATORS);
-      loop_optimizer_init (LOOPS_NORMAL
-			   | LOOPS_HAVE_RECORDED_EXITS);
       if (dump_file && (dump_flags & TDF_DETAILS))
 	flow_loops_dump (dump_file, NULL, 0);
       scev_initialize ();
@@ -2305,12 +2307,15 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
           *inline_summary (node)->loop_iterations = loop_iterations;
 	}
       scev_finalize ();
-      loop_optimizer_finalize ();
-      free_dominance_info (CDI_DOMINATORS);
     }
   inline_summary (node)->self_time = time;
   inline_summary (node)->self_size = size;
   VEC_free (predicate_t, heap, nonconstant_names);
+  if (optimize && !early)
+    {
+      loop_optimizer_finalize ();
+      free_dominance_info (CDI_DOMINATORS);
+    }
   if (dump_file)
     {
       fprintf (dump_file, "\n");