ifcombine: factor out inner block viability test
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 3 Nov 2015 00:31:18 +0000 (00:31 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 3 Nov 2015 00:31:18 +0000 (00:31 +0000)
Bail out early if the inner block has side effects or is otherwise not
eligible for ifcombine.

for  gcc/ChangeLog

* tree-ssa-ifcombine.c (tree_ssa_ifcombine_bb_1): Factor out
bb_no_side_effects_p tests...
(tree_ssa_ifcombine_bb): ... here.

From-SVN: r229691

gcc/ChangeLog
gcc/tree-ssa-ifcombine.c

index 84cad3f59b75177436693bffb1b1df5758abdf81..63297775ec24898b8263302fd5676645aad9a496 100644 (file)
@@ -1,5 +1,9 @@
 2015-11-02  Alexandre Oliva <aoliva@redhat.com>
 
+       * tree-ssa-ifcombine.c (tree_ssa_ifcombine_bb_1): Factor out
+       bb_no_side_effects_p tests...
+       (tree_ssa_ifcombine_bb): ... here.
+
        PR tree-optimization/68083
        * tree-ssa-ifcombine.c: Include tree-ssa.h.
        (bb_no_side_effects_p): Test for undefined uses too.
index c18de7e607e087a97e9aef77fc73bee3e038f843..2a2e38788d76dd94e63b8180557e0d3cc5389756 100644 (file)
@@ -576,8 +576,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb,
      the inner cond_bb having no side-effects.  */
   if (phi_pred_bb != else_bb
       && recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &else_bb)
-      && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb)
-      && bb_no_side_effects_p (inner_cond_bb))
+      && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb))
     {
       /* We have
           <outer_cond_bb>
@@ -595,8 +594,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb,
   /* And a version where the outer condition is negated.  */
   if (phi_pred_bb != else_bb
       && recognize_if_then_else (outer_cond_bb, &else_bb, &inner_cond_bb)
-      && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb)
-      && bb_no_side_effects_p (inner_cond_bb))
+      && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb))
     {
       /* We have
           <outer_cond_bb>
@@ -617,8 +615,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb,
      having no side-effects.  */
   if (phi_pred_bb != then_bb
       && recognize_if_then_else (outer_cond_bb, &then_bb, &inner_cond_bb)
-      && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb)
-      && bb_no_side_effects_p (inner_cond_bb))
+      && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb))
     {
       /* We have
           <outer_cond_bb>
@@ -635,8 +632,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb,
   /* And a version where the outer condition is negated.  */
   if (phi_pred_bb != then_bb
       && recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &then_bb)
-      && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb)
-      && bb_no_side_effects_p (inner_cond_bb))
+      && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb))
     {
       /* We have
           <outer_cond_bb>
@@ -673,7 +669,8 @@ tree_ssa_ifcombine_bb (basic_block inner_cond_bb)
        if (a && b)
         ;
      This requires a single predecessor of the inner cond_bb.  */
-  if (single_pred_p (inner_cond_bb))
+  if (single_pred_p (inner_cond_bb)
+      && bb_no_side_effects_p (inner_cond_bb))
     {
       basic_block outer_cond_bb = single_pred (inner_cond_bb);