https://gcc.gnu.org/g:eae53de5dc6e9e11010912130fdb861e224cb4df

commit eae53de5dc6e9e11010912130fdb861e224cb4df
Author: Alexandre Oliva <ol...@gnu.org>
Date:   Thu Dec 19 00:19:34 2024 -0300

    add options to control ifcombine

Diff:
---
 gcc/common.opt            | 12 ++++++++++++
 gcc/tree-ssa-ifcombine.cc | 29 +++++++++++++++++------------
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/gcc/common.opt b/gcc/common.opt
index 1b72826d44b1..51e7daa0703e 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1241,6 +1241,18 @@ fcode-hoisting
 Common Var(flag_code_hoisting) Optimization
 Enable code hoisting.
 
+fcombine-conditionals
+Common Var(flag_tree_ifcombine) Init(-1) Optimization
+Combine conditionals, with the ifcombine optimization pass.
+
+fcombine-noncontiguous-conditionals
+Common Var(flag_tree_ifcombine_noncontig) Init(-1) Optimization
+Combine conditionals from noncontiguous blocks
+
+fcombine-field-conditionals
+Common Var(flag_tree_ifcombine_fieldmerge) Init(-1) Optimization
+Combine conditionals involving separate fields
+
 fcombine-stack-adjustments
 Common Var(flag_combine_stack_adjustments) Optimization
 Looks for opportunities to reduce stack adjustments and stack references.
diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index c9399a106945..eac80ca730d1 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -972,18 +972,19 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool 
inner_inv,
                                            gimple_cond_lhs (outer_cond),
                                            gimple_cond_rhs (outer_cond),
                                            gimple_bb (outer_cond)))
-         && !(t = (fold_truth_andor_for_ifcombine
-                   (TRUTH_ANDIF_EXPR, boolean_type_node,
-                    gimple_location (outer_cond),
-                    outer_cond_code,
-                    gimple_cond_lhs (outer_cond),
-                    gimple_cond_rhs (outer_cond),
-                    gimple_location (inner_cond),
-                    inner_cond_code,
-                    gimple_cond_lhs (inner_cond),
-                    gimple_cond_rhs (inner_cond),
-                    single_pred (inner_cond_bb) != outer_cond_bb
-                    ? &ts : 0))))
+         && !(flag_tree_ifcombine_fieldmerge
+              && (t = (fold_truth_andor_for_ifcombine
+                       (TRUTH_ANDIF_EXPR, boolean_type_node,
+                        gimple_location (outer_cond),
+                        outer_cond_code,
+                        gimple_cond_lhs (outer_cond),
+                        gimple_cond_rhs (outer_cond),
+                        gimple_location (inner_cond),
+                        inner_cond_code,
+                        gimple_cond_lhs (inner_cond),
+                        gimple_cond_rhs (inner_cond),
+                        single_pred (inner_cond_bb) != outer_cond_bb
+                        ? &ts : 0)))))
        {
          /* Only combine conditions in this fallback case if the blocks are
             neighbors.  */
@@ -1255,6 +1256,9 @@ tree_ssa_ifcombine_bb (basic_block inner_cond_bb)
       /* Record the exit path taken by the outer condition.  */
       if (!exit_bb)
        {
+         if (!flag_tree_ifcombine_noncontig)
+           break;
+
          /* If we have removed the outer condition entirely, we need not
             commit to an exit block yet, it's as if we'd merged the blocks and
             were starting afresh.  This is sound as long as we never replace
@@ -1369,6 +1373,7 @@ public:
   {}
 
   /* opt_pass methods: */
+  bool gate (function *) final override { return flag_tree_ifcombine; }
   unsigned int execute (function *) final override;
 
 }; // class pass_tree_ifcombine

Reply via email to