diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1536017e43f..f7f2169b9d3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,4 +1,12 @@
-2012-02-15  Bernd Schmidt  <bernds@codesourcery.com>
+2012-02-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR lto/52178
+	* gimple.c (iterative_hash_gimple_type): Use RECORD_OR_UNION_TYPE_P.
+	(iterative_hash_canonical_type): Likewise.
+	* tree-ssa-pre.c (fini_pre): Clean up the CFG only after purging all
+	the dead edges.
+
+2012-02-14  Bernd Schmidt  <bernds@codesourcery.com>
 
 	* haifa-sched.c (prune_ready_list): Ensure that if there is a
 	sched-group insn, it either remains alone or the entire list is
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 9a6ed671f84..805ad2d77b2 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -4140,9 +4140,7 @@ iterative_hash_gimple_type (tree type, hashval_t val,
       v = iterative_hash_hashval_t (na, v);
     }
 
-  if (TREE_CODE (type) == RECORD_TYPE
-      || TREE_CODE (type) == UNION_TYPE
-      || TREE_CODE (type) == QUAL_UNION_TYPE)
+  if (RECORD_OR_UNION_TYPE_P (type))
     {
       unsigned nf;
       tree f;
@@ -4373,9 +4371,7 @@ iterative_hash_canonical_type (tree type, hashval_t val)
       v = iterative_hash_hashval_t (na, v);
     }
 
-  if (TREE_CODE (type) == RECORD_TYPE
-      || TREE_CODE (type) == UNION_TYPE
-      || TREE_CODE (type) == QUAL_UNION_TYPE)
+  if (RECORD_OR_UNION_TYPE_P (type))
     {
       unsigned nf;
       tree f;
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 71f945fc491..e5ec931b96f 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -4836,6 +4836,9 @@ init_pre (bool do_fre)
 static void
 fini_pre (bool do_fre)
 {
+  bool do_eh_cleanup = !bitmap_empty_p (need_eh_cleanup);
+  bool do_ab_cleanup = !bitmap_empty_p (need_ab_cleanup);
+
   free (postorder);
   VEC_free (bitmap_set_t, heap, value_expressions);
   BITMAP_FREE (inserted_exprs);
@@ -4851,22 +4854,18 @@ fini_pre (bool do_fre)
 
   free_dominance_info (CDI_POST_DOMINATORS);
 
-  if (!bitmap_empty_p (need_eh_cleanup))
-    {
-      gimple_purge_all_dead_eh_edges (need_eh_cleanup);
-      cleanup_tree_cfg ();
-    }
+  if (do_eh_cleanup)
+    gimple_purge_all_dead_eh_edges (need_eh_cleanup);
+
+  if (do_ab_cleanup)
+    gimple_purge_all_dead_abnormal_call_edges (need_ab_cleanup);
 
   BITMAP_FREE (need_eh_cleanup);
-
-  if (!bitmap_empty_p (need_ab_cleanup))
-    {
-      gimple_purge_all_dead_abnormal_call_edges (need_ab_cleanup);
-      cleanup_tree_cfg ();
-    }
-
   BITMAP_FREE (need_ab_cleanup);
 
+  if (do_eh_cleanup || do_ab_cleanup)
+    cleanup_tree_cfg ();
+
   if (!do_fre)
     loop_optimizer_finalize ();
 }