]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree.c (drop_tree_overflow): New function.
authorRichard Biener <rguenther@suse.de>
Wed, 6 Nov 2013 13:08:06 +0000 (13:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 6 Nov 2013 13:08:06 +0000 (13:08 +0000)
2013-11-06  Richard Biener  <rguenther@suse.de>

* tree.c (drop_tree_overflow): New function.
* tree.h (drop_tree_overflow): Declare.
* gimplify.c (gimplify_expr): Drop TREE_OVERFLOW.
* tree-vrp.c (range_int_cst_singleton_p): Use
is_overflow_infinity instead of testing TREE_OVERFLOW.
(extract_range_from_assert): Likewise.
(zero_nonzero_bits_from_vr): Likewise.
(extract_range_basic): Likewise.
(register_new_assert_for): Use drop_tree_overflow.
(vrp_visit_phi_node): Likewise.

From-SVN: r204454

gcc/ChangeLog
gcc/gimplify.c
gcc/tree-vrp.c
gcc/tree.c
gcc/tree.h

index 9192b7809522e762fe3f845200b0317d4fea8423..c211db0dd8ef2a7cfdc725c7016e40cce9542100 100644 (file)
@@ -1,3 +1,16 @@
+2013-11-06  Richard Biener  <rguenther@suse.de>
+
+       * tree.c (drop_tree_overflow): New function.
+       * tree.h (drop_tree_overflow): Declare.
+       * gimplify.c (gimplify_expr): Drop TREE_OVERFLOW.
+       * tree-vrp.c (range_int_cst_singleton_p): Use
+       is_overflow_infinity instead of testing TREE_OVERFLOW.
+       (extract_range_from_assert): Likewise.
+       (zero_nonzero_bits_from_vr): Likewise.
+       (extract_range_basic): Likewise.
+       (register_new_assert_for): Use drop_tree_overflow.
+       (vrp_visit_phi_node): Likewise.
+
 2013-11-06  Dodji Seketeli  <dodji@redhat.com>
 
        preprocessor/58580
index 4df9ed49e96b4815e16ff8a1fa71d66eda7c4577..721e8fb6002ce39ca66867b08a519f4b30cc3372 100644 (file)
@@ -7897,6 +7897,10 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
        case STRING_CST:
        case COMPLEX_CST:
        case VECTOR_CST:
+         /* Drop the overflow flag on constants, we do not want
+            that in the GIMPLE IL.  */
+         if (TREE_OVERFLOW_P (*expr_p))
+           *expr_p = drop_tree_overflow (*expr_p);
          ret = GS_ALL_DONE;
          break;
 
index 2a9043049417fc24325f302fd6e0dc0d321c758b..9b26f17eb548c0cc44920ca1b1de1b40decafc91 100644 (file)
@@ -892,8 +892,8 @@ static inline bool
 range_int_cst_singleton_p (value_range_t *vr)
 {
   return (range_int_cst_p (vr)
-         && !TREE_OVERFLOW (vr->min)
-         && !TREE_OVERFLOW (vr->max)
+         && !is_overflow_infinity (vr->min)
+         && !is_overflow_infinity (vr->max)
          && tree_int_cst_equal (vr->min, vr->max));
 }
 
@@ -1741,7 +1741,7 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
         all should be optimized away above us.  */
       if ((cond_code == LT_EXPR
           && compare_values (max, min) == 0)
-         || (CONSTANT_CLASS_P (max) && TREE_OVERFLOW (max)))
+         || is_overflow_infinity (max))
        set_value_range_to_varying (vr_p);
       else
        {
@@ -1781,7 +1781,7 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
         all should be optimized away above us.  */
       if ((cond_code == GT_EXPR
           && compare_values (min, max) == 0)
-         || (CONSTANT_CLASS_P (min) && TREE_OVERFLOW (min)))
+         || is_overflow_infinity (min))
        set_value_range_to_varying (vr_p);
       else
        {
@@ -1998,8 +1998,8 @@ zero_nonzero_bits_from_vr (value_range_t *vr,
   *may_be_nonzero = double_int_minus_one;
   *must_be_nonzero = double_int_zero;
   if (!range_int_cst_p (vr)
-      || TREE_OVERFLOW (vr->min)
-      || TREE_OVERFLOW (vr->max))
+      || is_overflow_infinity (vr->min)
+      || is_overflow_infinity (vr->max))
     return false;
 
   if (range_int_cst_singleton_p (vr))
@@ -3623,13 +3623,13 @@ extract_range_basic (value_range_t *vr, gimple stmt)
                    && integer_nonzerop (vr0->min))
                   || (vr0->type == VR_ANTI_RANGE
                       && integer_zerop (vr0->min)))
-                 && !TREE_OVERFLOW (vr0->min))
+                 && !is_overflow_infinity (vr0->min))
                mini = 1;
              /* If some high bits are known to be zero,
                 we can decrease the maximum.  */
              if (vr0->type == VR_RANGE
                  && TREE_CODE (vr0->max) == INTEGER_CST
-                 && !TREE_OVERFLOW (vr0->max))
+                 && !is_overflow_infinity (vr0->max))
                maxi = tree_floor_log2 (vr0->max) + 1;
            }
          goto bitop_builtin;
@@ -3664,7 +3664,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
                 result maximum.  */
              if (vr0->type == VR_RANGE
                  && TREE_CODE (vr0->min) == INTEGER_CST
-                 && !TREE_OVERFLOW (vr0->min))
+                 && !is_overflow_infinity (vr0->min))
                {
                  maxi = prec - 1 - tree_floor_log2 (vr0->min);
                  if (maxi != prec)
@@ -3672,7 +3672,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
                }
              else if (vr0->type == VR_ANTI_RANGE
                       && integer_zerop (vr0->min)
-                      && !TREE_OVERFLOW (vr0->min))
+                      && !is_overflow_infinity (vr0->min))
                {
                  maxi = prec - 1;
                  mini = 0;
@@ -3683,7 +3683,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
                 result minimum.  */
              if (vr0->type == VR_RANGE
                  && TREE_CODE (vr0->max) == INTEGER_CST
-                 && !TREE_OVERFLOW (vr0->max))
+                 && !is_overflow_infinity (vr0->max))
                {
                  mini = prec - 1 - tree_floor_log2 (vr0->max);
                  if (mini == prec)
@@ -3726,7 +3726,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
                    && integer_nonzerop (vr0->min))
                   || (vr0->type == VR_ANTI_RANGE
                       && integer_zerop (vr0->min)))
-                 && !TREE_OVERFLOW (vr0->min))
+                 && !is_overflow_infinity (vr0->min))
                {
                  mini = 0;
                  maxi = prec - 1;
@@ -3735,7 +3735,7 @@ extract_range_basic (value_range_t *vr, gimple stmt)
                 we can decrease the result maximum.  */
              if (vr0->type == VR_RANGE
                  && TREE_CODE (vr0->max) == INTEGER_CST
-                 && !TREE_OVERFLOW (vr0->max))
+                 && !is_overflow_infinity (vr0->max))
                {
                  maxi = tree_floor_log2 (vr0->max);
                  /* For vr0 [0, 0] give up.  */
@@ -4619,10 +4619,8 @@ register_new_assert_for (tree name, tree expr,
   /* Never build an assert comparing against an integer constant with
      TREE_OVERFLOW set.  This confuses our undefined overflow warning
      machinery.  */
-  if (TREE_CODE (val) == INTEGER_CST
-      && TREE_OVERFLOW (val))
-    val = build_int_cst_wide (TREE_TYPE (val),
-                             TREE_INT_CST_LOW (val), TREE_INT_CST_HIGH (val));
+  if (TREE_OVERFLOW_P (val))
+    val = drop_tree_overflow (val);
 
   /* The new assertion A will be inserted at BB or E.  We need to
      determine if the new location is dominated by a previously
@@ -8320,10 +8318,7 @@ vrp_visit_phi_node (gimple phi)
          else
            {
              if (is_overflow_infinity (arg))
-               {
-                 arg = copy_node (arg);
-                 TREE_OVERFLOW (arg) = 0;
-               }
+               arg = drop_tree_overflow (arg);
 
              vr_arg.type = VR_RANGE;
              vr_arg.min = arg;
index e0e9d8d4f36cdd15071acef074b84272c9b273cc..98896f82e810e6b48e709c144022ffc1bdb72e95 100644 (file)
@@ -12542,4 +12542,23 @@ get_tree_code_name (enum tree_code code)
   return tree_code_name[code];
 }
 
+/* Drops the TREE_OVERFLOW flag from T.  */
+
+tree
+drop_tree_overflow (tree t)
+{
+  gcc_checking_assert (TREE_OVERFLOW (t));
+
+  /* For tree codes with a sharing machinery re-build the result.  */
+  if (TREE_CODE (t) == INTEGER_CST)
+    return build_int_cst_wide (TREE_TYPE (t),
+                              TREE_INT_CST_LOW (t), TREE_INT_CST_HIGH (t));
+
+  /* Otherwise, as all tcc_constants are possibly shared, copy the node
+     and drop the flag.  */
+  t = copy_node (t);
+  TREE_OVERFLOW (t) = 0;
+  return t;
+}
+
 #include "gt-tree.h"
index 920ad07aadde4345b1ec88bcc4ac6b1795239a2d..5f9d0ea14cc9973d0eee3e835b344bebfc62f2de 100644 (file)
@@ -4800,6 +4800,7 @@ extern tree get_base_address (tree t);
 extern void mark_addressable (tree);
 
 /* In tree.c.  */
+extern tree drop_tree_overflow (tree);
 extern int tree_map_base_eq (const void *, const void *);
 extern unsigned int tree_map_base_hash (const void *);
 extern int tree_map_base_marked_p (const void *);