- for (e = bb->pred; e; e = e->pred_next)
- {
- if (!dominated_by_p (dom, e->src, bb))
- dom_bb = nearest_common_dominator (dom, dom_bb, e->src);
- }
+ if (dir == CDI_DOMINATORS)
+ {
+ for (e = bb->pred; e; e = e->pred_next)
+ {
+ /* Ignore the predecessors that either are not reachable from
+ the entry block, or whose dominator was not determined yet. */
+ if (!dominated_by_p (dir, e->src, ENTRY_BLOCK_PTR))
+ continue;
+
+ if (!dominated_by_p (dir, e->src, bb))
+ dom_bb = nearest_common_dominator (dir, dom_bb, e->src);
+ }
+ }
+ else
+ {
+ for (e = bb->succ; e; e = e->succ_next)
+ {
+ if (!dominated_by_p (dir, e->dest, bb))
+ dom_bb = nearest_common_dominator (dir, dom_bb, e->dest);
+ }
+ }