https://gcc.gnu.org/g:88b60656bc326fc024633217ddf343283fc52f38

commit 88b60656bc326fc024633217ddf343283fc52f38
Author: Alexandre Oliva <ol...@gnu.org>
Date:   Thu Oct 24 15:35:40 2024 -0300

    preserve TRUTH_ANDIF handling in ifcombine_replace_cond

Diff:
---
 gcc/tree-ssa-ifcombine.cc | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 817c95b20252..a21cc22cf589 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -518,6 +518,19 @@ ifcombine_replace_cond (gcond *inner_cond, bool inner_inv,
                        gcond *outer_cond, bool outer_inv,
                        tree cond, bool must_canon, tree cond2)
 {
+  /* Split cond into cond2 if they're contiguous.  ??? We might be able to
+     handle ORIF as well, inverting both conditions, but it's not clear that
+     this would be enough, and it never comes up.  */
+  if (!cond2
+      && TREE_CODE (cond) == TRUTH_ANDIF_EXPR
+      && single_pred (gimple_bb (inner_cond)) == gimple_bb (outer_cond))
+    {
+      /* ??? Does this ever hit?  */
+      gcc_unreachable ();
+      cond2 = TREE_OPERAND (cond, 1);
+      cond = TREE_OPERAND (cond, 0);
+    }
+
   bool outer_p = cond2 || (single_pred (gimple_bb (inner_cond))
                           != gimple_bb (outer_cond));
   bool result_inv = outer_p ? outer_inv : inner_inv;

Reply via email to