Hi,
this patch makes tree-ssa-threadupdate to not leave basic blocks with
undefined counts in the program.  

create_block_for_threading sets counts as follows:

  /* Zero out the profile, since the block is unreachable for now.  */
  rd->dup_blocks[count]->count = profile_count::uninitialized ();

which is usually set to correct count in update_profile. However
template_blocks are not seen by it and thus this patch calculates the
profile while redirecting edgs to it.

Bootstrapped/regtested x86_64-linux and also checked that the profile is
correct. Does it make sense?  There is no testcase since I plan to
commit sanity check that triggers several times during the testsuite and
bootstrap w/o this patch.

Honza

        * tree-ssa-threadupdate.c
Index: tree-ssa-threadupdate.c
===================================================================
--- tree-ssa-threadupdate.c     (revision 278959)
+++ tree-ssa-threadupdate.c     (working copy)
@@ -1286,6 +1286,10 @@ ssa_redirect_edges (struct redirection_d
          /* Redirect the incoming edge (possibly to the joiner block) to the
             appropriate duplicate block.  */
          e2 = redirect_edge_and_branch (e, rd->dup_blocks[0]);
+         if (single_pred_p (rd->dup_blocks[0]))
+           rd->dup_blocks[0]->count = e2->count ();
+         else
+           rd->dup_blocks[0]->count = rd->dup_blocks[0]->count + e2->count ();
          gcc_assert (e == e2);
          flush_pending_stmts (e2);
        }

Reply via email to