]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Normalize unsigned ~[0,0] into [1,MAX].
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 14 Oct 2019 06:43:03 +0000 (06:43 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 14 Oct 2019 06:43:03 +0000 (06:43 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@276949 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/evrp4.c
gcc/tree-vrp.c
gcc/tree-vrp.h

index 053ef6c84cbea58eef649764bba1469365d0dd33..cf359bf58351bb9ad52c44686e4b18e2527edb58 100644 (file)
@@ -1,3 +1,10 @@
+2019-10-14  Aldy Hernandez  <aldyh@redhat.com>
+
+       * tree-vrp.c (value_range_base::set): Normalize unsigned ~[0,0]
+       into [1,MAX].
+       * tree-vrp.h (value_range_base::nonzero_p): Adjust for unsigned
+       non-zero being represented as [1,MAX].
+
 2019-10-14  Xiong Hu Luo  <luoxhu@linux.ibm.com>
 
        * tree-sra.c (dump_access): Add missing braces.
index c14075b80c3d43f6915f04c1de791fb52986c5e1..fbc3d27f7a3014ac8ca761c3119cd8b92e6fb5ef 100644 (file)
@@ -1,3 +1,8 @@
+2019-10-14  Aldy Hernandez  <aldyh@redhat.com>
+
+       * gcc.dg/tree-ssa/evrp4.c: Adjust for unsigned non-zero being
+       [1,MAX].
+
 2019-10-13  Iain Sandoe  <iain@sandoe.co.uk>
 
        * gcc.target/i386/indirect-thunk-1.c: Allow 'l' or 'L' in
index ebb87ed38b089e1fa1f115685ec91e0887372c5f..ba2f6b9b430ada4c442d48375f8c955df0d15c47 100644 (file)
@@ -17,4 +17,4 @@ int bar (struct st *s)
   foo (&s->a);
 }
 
-/* { dg-final { scan-tree-dump "\~\\\[0B, 0B\\\]" "evrp" } } */
+/* { dg-final { scan-tree-dump "\\\[1B, -1B\\\]" "evrp" } } */
index d69cfb107cbe79058a8f1d96385491a571053d11..cffa05083400bb2539fed72eed7c695b5c8e6949 100644 (file)
@@ -800,13 +800,13 @@ value_range_base::set (enum value_range_kind kind, tree min, tree max)
          kind = VR_RANGE;
        }
       else if (is_min
-              /* As a special exception preserve non-null ranges.  */
-              && !(TYPE_UNSIGNED (TREE_TYPE (min))
-                   && integer_zerop (max)))
+              /* Allow non-zero pointers to be normalized to [1,MAX].  */
+              || (POINTER_TYPE_P (TREE_TYPE (min))
+                  && integer_zerop (min)))
         {
          tree one = build_int_cst (TREE_TYPE (max), 1);
          min = int_const_binop (PLUS_EXPR, max, one);
-         max = vrp_val_max (TREE_TYPE (max));
+         max = vrp_val_max (TREE_TYPE (max), true);
          kind = VR_RANGE;
         }
       else if (is_max)
index a3f9e90699d3d49fe080be1713c5b52fdf71904b..4bfdfeb8f7905e2273a01afa0e121a510f216180 100644 (file)
@@ -245,16 +245,6 @@ value_range_base::zero_p () const
          && integer_zerop (m_max));
 }
 
-/* Return TRUE if range is nonzero.  */
-
-inline bool
-value_range_base::nonzero_p () const
-{
-  return (m_kind == VR_ANTI_RANGE
-         && integer_zerop (m_min)
-         && integer_zerop (m_max));
-}
-
 extern void dump_value_range (FILE *, const value_range *);
 extern void dump_value_range (FILE *, const value_range_base *);
 
@@ -322,6 +312,23 @@ extern tree get_single_symbol (tree, bool *, tree *);
 extern void maybe_set_nonzero_bits (edge, tree);
 extern value_range_kind determine_value_range (tree, wide_int *, wide_int *);
 
+/* Return TRUE if range is nonzero.  */
+
+inline bool
+value_range_base::nonzero_p () const
+{
+  if (m_kind == VR_ANTI_RANGE
+      && !TYPE_UNSIGNED (type ())
+      && integer_zerop (m_min)
+      && integer_zerop (m_max))
+    return true;
+
+  return (m_kind == VR_RANGE
+         && TYPE_UNSIGNED (type ())
+         && integer_onep (m_min)
+         && vrp_val_is_max (m_max, true));
+}
+
 /* Return TRUE if *VR includes the value zero.  */
 
 inline bool