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: Small DOM record_equivalences_from_incoming_edge speedup


On Wed, 2004-05-26 at 17:17, Steven Bosscher wrote:
> Hi Jeff, all,
> 
> In record_equivalences_from_incoming_edge, we try to record the
> condition of a switch by looking at the value of case labels that
> transfer control to the basic block under consideration.
> 
> We identify such case labels by looking if one or more cases jump
> from the idom block to the head of the current basic block, so
> there seems to be an implicit assumption that the idom block is
> the only predecessor of the current block.  But we do not test for
> that fact.  With the attached patch, we do.
>
The assumption is not implicit.  The code uses case_count for that. 
Your approach of checking for a single predecessor seems faster to me. 
But in that case, you won't need to keep case_count.

Unless I'm missing something, this should work.  Jeff?


Thanks.  Diego.


diff -d -u -p -r2.5 tree-ssa-dom.c
--- tree-ssa-dom.c      18 May 2004 02:53:55 -0000      2.5
+++ tree-ssa-dom.c      28 May 2004 15:50:15 -0000
@@ -1450,9 +1450,12 @@ record_equivalences_from_incoming_edge (
                                       &bd->avail_exprs,
                                       bb,
                                       &bd->vrp_variables);
-  /* Similarly when the parent block ended in a SWITCH_EXPR.  */
+  /* Similarly when the parent block ended in a SWITCH_EXPR.
+     We can only know the value of the switch condition if the
+     dominator parent is also the only predecessor of this block.  */
   else if (parent_block_last_stmt
           && bb->pred->pred_next == NULL
+          && bb->pred->src == parent
           && TREE_CODE (parent_block_last_stmt) == SWITCH_EXPR)
     {
       tree switch_cond = SWITCH_COND (parent_block_last_stmt);
@@ -1463,7 +1466,6 @@ record_equivalences_from_incoming_edge (
        {
          tree switch_vec = SWITCH_LABELS (parent_block_last_stmt);
          size_t i, n = TREE_VEC_LENGTH (switch_vec);
-         int case_count = 0;
          tree match_case = NULL_TREE;

          /* Search the case labels for those whose destination is
@@ -1472,18 +1474,14 @@ record_equivalences_from_incoming_edge (
            {
              tree elt = TREE_VEC_ELT (switch_vec, i);
              if (label_to_block (CASE_LABEL (elt)) == bb)
-               {
-                 if (++case_count > 1)
-                   break;
-                 match_case = elt;
-               }
+               break;
            }

          /* If we encountered precisely one CASE_LABEL_EXPR and it
             was not the default case, or a case range, then we know
             the exact value of SWITCH_COND which caused us to get to
             this block.  Record that equivalence in EQ_EXPR_VALUE.  */
-         if (case_count == 1
+         if (match_case
              && CASE_LOW (match_case)
              && !CASE_HIGH (match_case))
            {



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