public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc(refs/users/marxin/heads/if-to-switch-v4)] Fix various issues.
Date: Tue, 13 Oct 2020 13:41:27 +0000 (GMT)	[thread overview]
Message-ID: <20201013134127.630EB3857838@sourceware.org> (raw)

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

commit ff35e1afaed3227a8d82c3f4077d98c328db0957
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Oct 13 15:41:18 2020 +0200

    Fix various issues.

Diff:
---
 gcc/gimple-if-to-switch.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-if-to-switch.cc b/gcc/gimple-if-to-switch.cc
index ba78a2c7233..8f61ba80c10 100644
--- a/gcc/gimple-if-to-switch.cc
+++ b/gcc/gimple-if-to-switch.cc
@@ -89,7 +89,7 @@ condition_info::record_phi_mapping (edge e, mapping_vec *vec)
       gphi *phi = gsi.phi ();
       if (!virtual_operand_p (gimple_phi_result (phi)))
 	{
-	  tree arg = PHI_ARG_DEF_FROM_EDGE (phi, m_true_edge);
+	  tree arg = PHI_ARG_DEF_FROM_EDGE (phi, e);
 	  vec->safe_push (std::make_pair (phi, arg));
 	}
     }
@@ -408,8 +408,15 @@ find_conditions (basic_block bb,
       info.m_true_edge = in_p ? true_edge : false_edge;
       info.m_false_edge = in_p ? false_edge : true_edge;
 
+      for (unsigned i = 0; i < info.m_ranges.length (); ++i)
+	if (info.m_ranges[i].exp == NULL_TREE
+	    || info.m_ranges[i].low == NULL_TREE
+	    || info.m_ranges[i].high == NULL_TREE)
+	  return;
+
       for (unsigned i = 1; i < info.m_ranges.length (); ++i)
-	if (info.m_ranges[i].exp != expr || info.m_ranges[i].in_p != in_p)
+	if (info.m_ranges[i].exp != expr
+	    || info.m_ranges[i].in_p != in_p)
 	  return;
 
       info.record_phi_mapping (info.m_true_edge, &info.m_true_edge_phi_mapping);
@@ -495,6 +502,7 @@ pass_if_to_switch::execute (function *fun)
 
 	  chain->m_entries.reverse ();
 	  if (chain->m_entries.length () >= 3
+	      && chain->check_non_overlapping_cases ()
 	      && chain->is_beneficial ())
 	    {
 	      expanded_location loc


             reply	other threads:[~2020-10-13 13:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 13:41 Martin Liska [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-10-12 13:05 Martin Liska
2020-10-09 12:41 Martin Liska
2020-10-06 13:49 Martin Liska

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=20201013134127.630EB3857838@sourceware.org \
    --to=marxin@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).