From: Kyrylo Tkachov <[email protected]>

All three callers of noce_finish_if_conversion bump num_updated_if_blocks
right after it returns.  Do it in the helper, next to the CFG change it
counts.

While there, rename cond_exec_changed_p to ifcvt_changed_p.  It records that
some conversion happened so that if_convert makes another pass, and every
successful conversion sets it, including the ones find_if_header reaches
through its own success path.  The old name suggests only the
conditional-execution path does.  No functional change.

gcc/ChangeLog:

        * ifcvt.cc (cond_exec_changed_p): Rename to...
        (ifcvt_changed_p): ...this, and correct its comment.  Adjust all uses.
        (noce_finish_if_conversion): Bump num_updated_if_blocks.
        (noce_convert_multiple_sets, noce_process_if_block,
        cond_move_process_if_block): Drop the bump the helper now does.

Signed-off-by: Kyrylo Tkachov <[email protected]>
---
 gcc/ifcvt.cc | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/gcc/ifcvt.cc b/gcc/ifcvt.cc
index fd935ed6e19..6c754eff767 100644
--- a/gcc/ifcvt.cc
+++ b/gcc/ifcvt.cc
@@ -81,8 +81,10 @@ static int num_updated_if_blocks;
 /* # of changes made.  */
 static int num_true_changes;
 
-/* Whether conditional execution changes were made.  */
-static bool cond_exec_changed_p;
+/* Whether this pass over the function converted anything, so that another
+   pass may find further opportunities in what it left behind.  Every
+   successful conversion sets it, not only the conditional-execution one.  */
+static bool ifcvt_changed_p;
 
 /* Forward references.  */
 static int count_bb_insns (const_basic_block);
@@ -774,7 +776,7 @@ cond_exec_process_if_block (ce_if_block *ce_info, bool 
do_multiple_p)
     delete_insn_chain (first_active_insn (else_bb), else_last_head, false);
 
   merge_if_block (ce_info);
-  cond_exec_changed_p = true;
+  ifcvt_changed_p = true;
   return true;
 
  fail:
@@ -4025,7 +4027,8 @@ try_emit_cmove_seq (struct noce_if_info *if_info, rtx 
temp,
    from TEST_BB straight to JOIN_BB that bypassed THEN, and that goes as well.
    An IF-THEN-ELSE-JOIN has no such edge, and deleting ELSE_BB removes its two
    edges instead.  Redirect TEST_BB to JOIN_BB and merge the two when the tail
-   no longer needs its own block.  */
+   no longer needs its own block.  Count the converted if-block and the CFG
+   changes it took.  */
 
 static void
 noce_finish_if_conversion (noce_if_info *if_info)
@@ -4053,6 +4056,8 @@ noce_finish_if_conversion (noce_if_info *if_info)
       merge_blocks (test_bb, join_bb);
       num_true_changes++;
     }
+
+  num_updated_if_blocks++;
 }
 
 /* We have something like:
@@ -4261,7 +4266,6 @@ noce_convert_multiple_sets (struct noce_if_info *if_info)
 
   noce_finish_if_conversion (if_info);
 
-  num_updated_if_blocks++;
   if_info->transform_name = "noce_convert_multiple_sets";
   return true;
 }
@@ -5176,7 +5180,6 @@ noce_process_if_block (struct noce_if_info *if_info)
      redirected to the join block.  */
   noce_finish_if_conversion (if_info);
 
-  num_updated_if_blocks++;
   return true;
 }
 
@@ -5429,7 +5432,6 @@ cond_move_process_if_block (struct noce_if_info *if_info)
 
   noce_finish_if_conversion (if_info);
 
-  num_updated_if_blocks++;
   success_p = true;
 
 done:
@@ -5789,7 +5791,7 @@ find_if_header (basic_block test_bb, int pass)
   if (dump_file)
     fprintf (dump_file, "Conversion succeeded on pass %d.\n", pass);
   /* Set this so we continue looking.  */
-  cond_exec_changed_p = true;
+  ifcvt_changed_p = true;
   return ce_info.test_bb;
 }
 
@@ -6878,7 +6880,7 @@ if_convert (ifcvt_phase phase)
       df_analyze ();
       /* Only need to do dce on the first pass.  */
       df_clear_flags (DF_LR_RUN_DCE);
-      cond_exec_changed_p = false;
+      ifcvt_changed_p = false;
       pass++;
 
       if (dump_file && pass > 1)
@@ -6892,10 +6894,10 @@ if_convert (ifcvt_phase phase)
             bb = new_bb;
        }
 
-      if (dump_file && cond_exec_changed_p)
+      if (dump_file && ifcvt_changed_p)
        print_rtl_with_bb (dump_file, get_insns (), dump_flags);
     }
-  while (cond_exec_changed_p);
+  while (ifcvt_changed_p);
 
   if (dump_file)
     fprintf (dump_file, "\n\n========== no more changes\n");
-- 
2.50.1 (Apple Git-155)

Reply via email to