[gcc(refs/users/guojiufu/heads/guojiufu-branch)] invert in/out edge for eq cond

Jiu Fu Guo guojiufu@gcc.gnu.org
Wed Jun 9 05:27:33 GMT 2021


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

commit c3931cdad3686c7283577dcd8681075e85c39bd4
Author: Jiufu Guo <guojiufu@linux.ibm.com>
Date:   Fri Jun 4 14:05:11 2021 +0800

    invert in/out edge for eq cond

Diff:
---
 gcc/tree-ssa-loop-split.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c
index 44bb8056b5b..9fa339ebb7d 100644
--- a/gcc/tree-ssa-loop-split.c
+++ b/gcc/tree-ssa-loop-split.c
@@ -1719,6 +1719,24 @@ split_ne_loop (struct loop *loop, edge cond_e)
 
   gcond *gc = as_a<gcond *> (last_stmt (cond_e->src));
   gcond *dup_gc = as_a<gcond *> (last_stmt (loop2_cond_exit_bb));
+  /* Invert edges for gcond.  */
+  if (gimple_cond_code (gc) == EQ_EXPR)
+    {
+      auto invert_edge = [](basic_block bb) {
+	edge out = EDGE_SUCC (bb, 0);
+	edge in = EDGE_SUCC (bb, 1);
+	if (in->flags & EDGE_TRUE_VALUE)
+	  std::swap (in, out);
+	in->flags |= EDGE_TRUE_VALUE;
+	in->flags &= ~EDGE_FALSE_VALUE;
+	out->flags |= EDGE_FALSE_VALUE;
+	out->flags &= ~EDGE_TRUE_VALUE;
+      };
+
+      invert_edge (gimple_bb (gc));
+      invert_edge (gimple_bb (dup_gc));      
+    }
+  
 
   /* Change if (i != n) to LOOP1:if (i > n) and LOOP2:if (i < n) */
   bool inv = expr_invariant_in_loop_p (loop, gimple_cond_lhs (gc));


More information about the Gcc-cvs mailing list