]> gcc.gnu.org Git - gcc.git/commitdiff
Remove irange::varying_p checks from symbolic_p and constant_p.
authorAldy Hernandez <aldyh@redhat.com>
Sat, 17 Apr 2021 12:26:33 +0000 (14:26 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 26 Apr 2021 13:42:50 +0000 (15:42 +0200)
As of a few releases ago, varying_p() ranges are also constant_p.
Consequently, there is no need to check varying_p from either
symbolic_p or constant_p.

I have adjusted a few users of constant_p that were depending on
constant_p returning false for varying_p.  In these cases, I have
placed the varying_p check before the constant_p check to avoid
the more expensive constant_p check when possible.

gcc/ChangeLog:

* gimple-ssa-evrp-analyze.c (evrp_range_analyzer::set_ssa_range_info):
Adjust for constant_p including varying_p.
* tree-vrp.c (vrp_prop::finalize): Same.
(determine_value_range): Same.
* vr-values.c (vr_values::range_of_expr): Same.
* value-range.cc (irange::symbolic_p): Do not check varying_p.
(irange::constant_p): Same.

gcc/gimple-ssa-evrp-analyze.c
gcc/tree-vrp.c
gcc/value-range.cc
gcc/vr-values.c

index 4c474cdfb4d4911fe9717239a88a2a1356e3dbfe..d78b6f8423cc01db234f68296c046f41e1e2184a 100644 (file)
@@ -109,7 +109,7 @@ evrp_range_analyzer::set_ssa_range_info (tree lhs, value_range_equiv *vr)
   /* Set the SSA with the value range.  */
   if (INTEGRAL_TYPE_P (TREE_TYPE (lhs)))
     {
-      if (vr->constant_p ())
+      if (!vr->varying_p () && vr->constant_p ())
        set_range_info (lhs, vr->kind (),
                        wi::to_wide (vr->min ()),
                        wi::to_wide (vr->max ()));
index 62b90079a03f3ca1de8c5f51d7105901995b00da..d968ef288ff23e1074f1bd305610b6f7f2276f66 100644 (file)
@@ -4059,7 +4059,7 @@ vrp_prop::finalize ()
        continue;
 
       const value_range_equiv *vr = m_vr_values->get_value_range (name);
-      if (!name || !vr->constant_p ())
+      if (!name || vr->varying_p () || !vr->constant_p ())
        continue;
 
       if (POINTER_TYPE_P (TREE_TYPE (name))
@@ -4679,7 +4679,7 @@ determine_value_range (tree expr, wide_int *min, wide_int *max)
 {
   value_range vr;
   determine_value_range_1 (&vr, expr);
-  if (vr.constant_p ())
+  if (!vr.varying_p () && vr.constant_p ())
     {
       *min = wi::to_wide (vr.min ());
       *max = wi::to_wide (vr.max ());
index d46662397e7e1ed5b7b2a9a483f18565e7471637..f5ef4808530a3c727a5d5b70378444ccb1e0b8af 100644 (file)
@@ -534,22 +534,17 @@ irange::equal_p (const irange &other) const
 bool
 irange::symbolic_p () const
 {
-  return (!varying_p ()
-         && !undefined_p ()
+  return (m_num_ranges > 0
          && (!is_gimple_min_invariant (min ())
              || !is_gimple_min_invariant (max ())));
 }
 
-/* NOTE: This is not the inverse of symbolic_p because the range
-   could also be varying or undefined.  Ideally they should be inverse
-   of each other, with varying only applying to symbolics.  Varying of
-   constants would be represented as [-MIN, +MAX].  */
+/* Return TRUE if this is a constant range.  */
 
 bool
 irange::constant_p () const
 {
-  return (!varying_p ()
-         && !undefined_p ()
+  return (m_num_ranges > 0
          && TREE_CODE (min ()) == INTEGER_CST
          && TREE_CODE (max ()) == INTEGER_CST);
 }
index e117f66d1bdb052ee72f5b39962621d9b306c8ac..08b237b263203090f6db38f3229ff575646fc4ae 100644 (file)
@@ -182,7 +182,7 @@ vr_values::range_of_expr (irange &r, tree expr, gimple *stmt)
 
   if (const value_range *vr = get_value_range (expr, stmt))
     {
-      if (vr->undefined_p () || vr->varying_p () || vr->constant_p ())
+      if (vr->undefined_p () || vr->constant_p ())
        r = *vr;
       else
        {
This page took 0.79927 seconds and 5 git commands to generate.