public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jiu Fu Guo <guojiufu@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/guojiufu/heads/guojiufu-branch)] invert in/out edge for eq cond
Date: Wed,  9 Jun 2021 05:27:33 +0000 (GMT)	[thread overview]
Message-ID: <20210609052733.6E3C63848427@sourceware.org> (raw)

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));


                 reply	other threads:[~2021-06-09  5:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210609052733.6E3C63848427@sourceware.org \
    --to=guojiufu@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).