[PATCH] Fix edge probabilities of loop guards

Richard Guenther rguenther@suse.de
Thu Jul 5 11:17:00 GMT 2012


This fixes edge probabilities of loop guards the vectorizer inserts
for prologue/epilogue peeling.  Formerly we'd end up with

  prolog_loop_niters.72_165 = D.2000_146 & 1;
  if (prolog_loop_niters.72_165 == 0)
    goto <bb 7>;
  else
    goto <bb 4>;
  # SUCC: 4 [100.0%]  (false) 7 (true)

which is bogus and yields a distorted basic-block ordering.  The
following changes it to

  prolog_loop_niters.72_165 = D.2000_146 & 1;
  if (prolog_loop_niters.72_165 == 0)
    goto <bb 7>;
  else
    goto <bb 4>;
  # SUCC: 4 [50.0%]  (false) 7 [50.0%]  (true)

which in this case is perfectly reasonable (in the case of, say,
D.2000_146 & 3 we could compute a more precise distribution, but
at this point this information is not available).

I'll give this a round of testing.

Honza, does this look reasonable?

Thanks,
Richard.

2012-07-05  Richard Guenther  <rguenther@suse.de>

	* tree-vect-loop-manip.c (slpeel_add_loop_guard): Update
	edge probabilities.

Index: gcc/tree-vect-loop-manip.c
===================================================================
*** gcc/tree-vect-loop-manip.c	(revision 189284)
--- gcc/tree-vect-loop-manip.c	(working copy)
*************** slpeel_add_loop_guard (basic_block guard
*** 954,959 ****
--- 954,962 ----
    /* Add new edge to connect guard block to the merge/loop-exit block.  */
    new_e = make_edge (guard_bb, exit_bb, EDGE_TRUE_VALUE);
    set_immediate_dominator (CDI_DOMINATORS, exit_bb, dom_bb);
+   /* Mark the outcome of the guard as equally likely.  */
+   enter_e->probability = REG_BR_PROB_BASE / 2;
+   new_e->probability = REG_BR_PROB_BASE / 2;
    return new_e;
  }
  



More information about the Gcc-patches mailing list