This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA][PATCH] Refactor duplicated code used by various dom walkers


On 11/03/2017 04:05 AM, Richard Biener wrote:
On Fri, Nov 3, 2017 at 4:49 AM, Jeff Law <law@redhat.com> wrote:



Several passes which perform dominator walks want to identify when block has
a single incoming edge, ignoring loop backedges.

I'm aware of 4 implementations of this code.  3 of the 4 are identical in
function.  The 4th (tree-ssa-dom.c) has an additional twist that it also
ignores edges that are not marked as executable.

So I've taken the more general implementation from tree-ssa-dom.c and
conditionalized the handling of unexecutable edges on a flag and moved the
implementation into cfganal.c where it more naturally belongs.

Bootstrapped and regression tested on x86_64.  OK for the trunk?

Minor nits (sorry...)
No need to apologize. I'm always appreciative of feedback as it consistently improves what ultimately lands in the tree.



Jeff

         * cfganal.c (single_incoming_edge_ignoring_loop_edges): New function
         extracted from tree-ssa-dom.c.
         * cfganal.h (single_incoming_edge_ignoring_loop_edges): Prototype.
         * tree-ssa-dom.c (single_incoming_edge_ignoring_loop_edges): Remove.
         (record_equivalences_from_incoming_edge): Add additional argument
         to single_incoming_edge_ignoring_loop_edges call.
         * tree-ssa-uncprop.c (single_incoming_edge_ignoring_loop_edges):
Remove.
         (uncprop_dom_walker::before_dom_children): Add additional argument
         to single_incoming_edge_ignoring_loop_edges call.
         * tree-ssa-sccvn.c (sccvn_dom_walker::before_dom_children): Use
         single_incoming_edge_ignoring_loop_edges rather than open coding.
         * tree-vrp.c (evrp_dom_walker::before_dom_children): Similarly.





diff --git a/gcc/cfganal.c b/gcc/cfganal.c
index c506067..14d94b2 100644
--- a/gcc/cfganal.c
+++ b/gcc/cfganal.c
@@ -1554,3 +1554,38 @@ single_pred_before_succ_order (void)
  #undef MARK_VISITED
  #undef VISITED_P
  }
+
+/* Ignoring loop backedges, if BB has precisely one incoming edge then
+   return that edge.  Otherwise return NULL.  */
+edge
+single_incoming_edge_ignoring_loop_edges (basic_block bb,
+                                         bool ignore_unreachable)

single_pred_edge_ignoring_loop_edges and ignore_not_executable

to better match existing CFG functions and actual edge flag use.

Ok with that change.
Sure.  Easy to change.

Jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]