]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
stmt.c (expand_case): Use build_int_cst.
authorRichard Guenther <rguenth@gcc.gnu.org>
Wed, 1 Jun 2005 18:51:12 +0000 (18:51 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 1 Jun 2005 18:51:12 +0000 (18:51 +0000)
2005-06-01  Richard Guenther  <rguenth@gcc.gnu.org>

* stmt.c (expand_case): Use build_int_cst.
(node_has_low_bound): Likewise, and correct type mismatch.
(node_has_high_bound): Likewise.
* fold-const.c (fold_binary): Ensure we build trees
with the correct types - undo what STRIP_NOPS possibly did.

From-SVN: r100459

gcc/ChangeLog
gcc/fold-const.c
gcc/stmt.c

index 29603148a2c447097b55473d6dd1a9822a0d8e25..28e537e2823ac70d88c6a1088beb32cc5c1414ba 100644 (file)
@@ -1,3 +1,11 @@
+2005-06-01  Richard Guenther  <rguenth@gcc.gnu.org>
+
+       * stmt.c (expand_case): Use build_int_cst.
+       (node_has_low_bound): Likewise, and correct type mismatch.
+       (node_has_high_bound): Likewise.
+       * fold-const.c (fold_binary): Ensure we build trees
+       with the correct types - undo what STRIP_NOPS possibly did.
+
 2005-06-01  Richard Guenther  <rguenth@gcc.gnu.org>
 
        * tree.h (fold_indirect_ref_1): Export from fold-const.c.
index ad5039bba6eb541619b24f1219c4da1ab0b3c414..05e016add7365bced7de6c24baaae7c0dffd1dd8 100644 (file)
@@ -7948,7 +7948,9 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
               && (TREE_CODE (arg1) != REAL_CST
                   ||  REAL_VALUE_NEGATIVE (TREE_REAL_CST (arg1))))
              || (INTEGRAL_TYPE_P (type) && flag_wrapv && !flag_trapv)))
-       return fold_build2 (PLUS_EXPR, type, arg0, negate_expr (arg1));
+       return fold_build2 (PLUS_EXPR, type,
+                           fold_convert (type, arg0),
+                           fold_convert (type, negate_expr (arg1)));
 
       /* Try folding difference of addresses.  */
       {
@@ -8467,7 +8469,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
              if (exact_real_inverse (TYPE_MODE(TREE_TYPE(arg0)), &r))
                {
                  tem = build_real (type, r);
-                 return fold_build2 (MULT_EXPR, type, arg0, tem);
+                 return fold_build2 (MULT_EXPR, type,
+                                     fold_convert (type, arg0), tem);
                }
            }
        }
index 6bdaf51b9db654d6864fd2b7591dc5556e4c9666..6df6eaa3e2e233c31d0fb3c0e38566e592ce1fb0 100644 (file)
@@ -2437,7 +2437,7 @@ expand_case (tree exp)
          if (compare_tree_int (minval, 0) > 0
              && compare_tree_int (maxval, GET_MODE_BITSIZE (word_mode)) < 0)
            {
-             minval = fold_convert (index_type, integer_zero_node);
+             minval = build_int_cst (index_type, 0);
              range = maxval;
            }
          emit_case_bit_tests (index_type, index_expr, minval, range,
@@ -2523,7 +2523,7 @@ expand_case (tree exp)
                  && compare_tree_int (minval, 0) > 0
                  && compare_tree_int (minval, 3) < 0)
                {
-                 minval = fold_convert (index_type, integer_zero_node);
+                 minval = build_int_cst (index_type, 0);
                  range = maxval;
                }
 
@@ -2830,7 +2830,8 @@ node_has_low_bound (case_node_ptr node, tree index_type)
     return 0;
 
   low_minus_one = fold_build2 (MINUS_EXPR, TREE_TYPE (node->low),
-                              node->low, integer_one_node);
+                              node->low,
+                              build_int_cst (TREE_TYPE (node->low), 1));
 
   /* If the subtraction above overflowed, we can't verify anything.
      Otherwise, look for a parent that tests our value - 1.  */
@@ -2880,7 +2881,8 @@ node_has_high_bound (case_node_ptr node, tree index_type)
     return 0;
 
   high_plus_one = fold_build2 (PLUS_EXPR, TREE_TYPE (node->high),
-                              node->high, integer_one_node);
+                              node->high,
+                              build_int_cst (TREE_TYPE (node->high), 1));
 
   /* If the addition above overflowed, we can't verify anything.
      Otherwise, look for a parent that tests our value + 1.  */