stmt.c (expand_case): Put an assertion that index_expr is never INTEGER_CST.
authorKazu Hirata <kazu@cs.umass.edu>
Tue, 26 Oct 2004 17:19:39 +0000 (17:19 +0000)
committerKazu Hirata <kazu@gcc.gnu.org>
Tue, 26 Oct 2004 17:19:39 +0000 (17:19 +0000)
* stmt.c (expand_case): Put an assertion that index_expr is
never INTEGER_CST.  Don't special case for constant
index_expr.

From-SVN: r89590

gcc/ChangeLog
gcc/stmt.c

index ce3a7a610bbc48f0e8bd200a16e0d16970d6c68d..7ac8e6ada3be03952952f179c0a41aaf7c3b932d 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-26  Kazu Hirata  <kazu@cs.umass.edu>
+
+       * stmt.c (expand_case): Put an assertion that index_expr is
+       never INTEGER_CST.  Don't special case for constant
+       index_expr.
+
 2004-10-26  Andrew Pinski  <pinskia@physics.uc.edu>
 
        PR 18162
index bb17fa2e4e6551f50d3ed8471f7e176fd3587525..3e866cde918582fc718d41795ff3d418f131b4c5 100644 (file)
@@ -2355,6 +2355,10 @@ expand_case (tree exp)
     {
       tree elt;
 
+      /* cleanup_tree_cfg removes all SWITCH_EXPR with their index
+        expressions being INTEGER_CST.  */
+      gcc_assert (TREE_CODE (index_expr) != INTEGER_CST);
+
       /* The default case is at the end of TREE_VEC.  */
       elt = TREE_VEC_ELT (vec, TREE_VEC_LENGTH (vec) - 1);
       gcc_assert (!CASE_HIGH (elt));
@@ -2494,58 +2498,27 @@ expand_case (tree exp)
 
          if (MEM_P (index))
            index = copy_to_reg (index);
-         if (GET_CODE (index) == CONST_INT
-             || TREE_CODE (index_expr) == INTEGER_CST)
-           {
-             /* Make a tree node with the proper constant value
-                if we don't already have one.  */
-             if (TREE_CODE (index_expr) != INTEGER_CST)
-               {
-                 index_expr
-                   = build_int_cst_wide (NULL_TREE, INTVAL (index),
-                                         unsignedp || INTVAL (index) >= 0
-                                         ? 0 : -1);
-                 index_expr = convert (index_type, index_expr);
-               }
 
-             /* For constant index expressions we need only
-                issue an unconditional branch to the appropriate
-                target code.  The job of removing any unreachable
-                code is left to the optimization phase if the
-                "-O" option is specified.  */
-             for (n = case_list; n; n = n->right)
-               if (! tree_int_cst_lt (index_expr, n->low)
-                   && ! tree_int_cst_lt (n->high, index_expr))
-                 break;
-
-             if (n)
-               emit_jump (label_rtx (n->code_label));
-             else
-               emit_jump (default_label);
-           }
-         else
-           {
-             /* If the index expression is not constant we generate
-                a binary decision tree to select the appropriate
-                target code.  This is done as follows:
+         /* If the index expression is not constant we generate
+            a binary decision tree to select the appropriate
+            target code.  This is done as follows:
 
-                The list of cases is rearranged into a binary tree,
-                nearly optimal assuming equal probability for each case.
+            The list of cases is rearranged into a binary tree,
+            nearly optimal assuming equal probability for each case.
 
-                The tree is transformed into RTL, eliminating
-                redundant test conditions at the same time.
+            The tree is transformed into RTL, eliminating
+            redundant test conditions at the same time.
 
-                If program flow could reach the end of the
-                decision tree an unconditional jump to the
-                default code is emitted.  */
+            If program flow could reach the end of the
+            decision tree an unconditional jump to the
+            default code is emitted.  */
 
-             use_cost_table
-               = (TREE_CODE (orig_type) != ENUMERAL_TYPE
-                  && estimate_case_costs (case_list));
-             balance_case_nodes (&case_list, NULL);
-             emit_case_nodes (index, case_list, default_label, index_type);
-             emit_jump (default_label);
-           }
+         use_cost_table
+           = (TREE_CODE (orig_type) != ENUMERAL_TYPE
+              && estimate_case_costs (case_list));
+         balance_case_nodes (&case_list, NULL);
+         emit_case_nodes (index, case_list, default_label, index_type);
+         emit_jump (default_label);
        }
       else
        {