This fixes LTO profiledbootstrap.  tracer tail-duplicates loop
headers; that is not profitable and it makes loops have multiple
entries which inhibits further optimization.  The following
patch cures that.

LTO profiledbootstrapped on x86_64-unknown-linux-gnu, regular
testing in progress.

Richard.

2012-04-04  Richard Guenther  <rguent...@suse.de>

        PR tree-optimization/52808
        * tracer.c (tail_duplicate): Do not tail-duplicate loop header
        blocks.
        * Makefile.in (tracer.o): Depend on $(CFGLOOP_H).

Index: gcc/tracer.c
===================================================================
*** gcc/tracer.c        (revision 186134)
--- gcc/tracer.c        (working copy)
***************
*** 52,57 ****
--- 52,58 ----
  #include "tree-pass.h"
  #include "tree-flow.h"
  #include "tree-inline.h"
+ #include "cfgloop.h"
  
  static int count_insns (basic_block);
  static bool ignore_bb_p (const_basic_block);
*************** tail_duplicate (void)
*** 307,313 ****
            }
          traced_insns += bb2->frequency * counts [bb2->index];
          if (EDGE_COUNT (bb2->preds) > 1
!             && can_duplicate_block_p (bb2))
            {
              edge e;
              basic_block copy;
--- 308,320 ----
            }
          traced_insns += bb2->frequency * counts [bb2->index];
          if (EDGE_COUNT (bb2->preds) > 1
!             && can_duplicate_block_p (bb2)
!             /* We have the tendency to duplicate the loop header
!                of all do { } while loops.  Do not do that - it is
!                not profitable and it might create a loop with multiple
!                entries or at least rotate the loop.  */
!             && (!current_loops
!                 || bb2->loop_father->header != bb2))
            {
              edge e;
              basic_block copy;
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in     (revision 186134)
+++ gcc/Makefile.in     (working copy)
@@ -3391,7 +3391,7 @@ bb-reorder.o : bb-reorder.c $(CONFIG_H)
 tracer.o : tracer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    $(TREE_H) $(BASIC_BLOCK_H) hard-reg-set.h output.h $(CFGLAYOUT_H) \
    $(FLAGS_H) $(TIMEVAR_H) $(PARAMS_H) $(COVERAGE_H) $(FIBHEAP_H) \
-   $(TREE_PASS_H) $(TREE_FLOW_H) $(TREE_INLINE_H)
+   $(TREE_PASS_H) $(TREE_FLOW_H) $(TREE_INLINE_H) $(CFGLOOP_H)
 cfglayout.o : cfglayout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(RTL_H) $(TREE_H) insn-config.h $(BASIC_BLOCK_H) hard-reg-set.h output.h \
    $(FUNCTION_H) $(CFGLAYOUT_H) $(CFGLOOP_H) $(TARGET_H) gt-cfglayout.h \

Reply via email to