Hi.

Now we should not meet a degenerated gswitch statements.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2018-08-27  Martin Liska  <mli...@suse.cz>

        * tree-cfg.c (find_taken_edge_switch_expr): Replace not possible
        condition with assert.
        * tree-switch-conversion.c (switch_conversion::expand):
        Likewise.
---
 gcc/tree-cfg.c               | 17 +++++++----------
 gcc/tree-switch-conversion.c |  9 +--------
 2 files changed, 8 insertions(+), 18 deletions(-)


diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index cf12cb1f391..338967f39f7 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -2443,17 +2443,14 @@ find_taken_edge_switch_expr (const gswitch *switch_stmt, tree val)
   edge e;
   tree taken_case;
 
-  if (gimple_switch_num_labels (switch_stmt) == 1)
-    taken_case = gimple_switch_default_label (switch_stmt);
+  gcc_assert (gimple_switch_num_labels (switch_stmt) >= 2);
+  if (val == NULL_TREE)
+    val = gimple_switch_index (switch_stmt);
+  if (TREE_CODE (val) != INTEGER_CST)
+    return NULL;
   else
-    {
-      if (val == NULL_TREE)
-	val = gimple_switch_index (switch_stmt);
-      if (TREE_CODE (val) != INTEGER_CST)
-	return NULL;
-      else
-	taken_case = find_case_label_for_value (switch_stmt, val);
-    }
+    taken_case = find_case_label_for_value (switch_stmt, val);
+
   dest_bb = label_to_block (cfun, CASE_LABEL (taken_case));
 
   e = find_edge (gimple_bb (switch_stmt), dest_bb);
diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index a31ff94b895..7e4f34c71f8 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -913,14 +913,7 @@ switch_conversion::expand (gswitch *swtch)
   /* Group case labels so that we get the right results from the heuristics
      that decide on the code generation approach for this switch.  */
   m_cfg_altered |= group_case_labels_stmt (swtch);
-
-  /* If this switch is now a degenerate case with only a default label,
-     there is nothing left for us to do.  */
-  if (gimple_switch_num_labels (swtch) < 2)
-    {
-      m_reason = "switch is a degenerate case";
-      return;
-    }
+  gcc_assert (gimple_switch_num_labels (swtch) >= 2);
 
   collect (swtch);
 

Reply via email to