tree.h (POINTER_TYPE_OVERFLOW_UNDEFINED): Delete.
authorBin Cheng <bin.cheng@arm.com>
Tue, 1 Aug 2017 09:28:18 +0000 (09:28 +0000)
committerBin Cheng <amker@gcc.gnu.org>
Tue, 1 Aug 2017 09:28:18 +0000 (09:28 +0000)
* tree.h (POINTER_TYPE_OVERFLOW_UNDEFINED): Delete.
* fold-const.c (fold_comparison, fold_binary_loc): Delete use of
above macro.
* match.pd: Ditto in address comparison pattern.

gcc/testsuite
* gcc.dg/no-strict-overflow-7.c: Revise comment and test string.
* gcc.dg/tree-ssa/pr81388-1.c: Ditto.

From-SVN: r250765

gcc/ChangeLog
gcc/fold-const.c
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/no-strict-overflow-7.c
gcc/testsuite/gcc.dg/tree-ssa/pr81388-1.c
gcc/tree.h

index 9e09d56d2b22636e041fef6fd36f8d807a132c8b..10c10c7089cac5ae6f085c7b147cc74a2f72408e 100644 (file)
@@ -1,3 +1,10 @@
+2017-08-01  Bin Cheng  <bin.cheng@arm.com>
+
+       * tree.h (POINTER_TYPE_OVERFLOW_UNDEFINED): Delete.
+       * fold-const.c (fold_comparison, fold_binary_loc): Delete use of
+       above macro.
+       * match.pd: Ditto in address comparison pattern.
+
 2017-08-01  Bin Cheng  <bin.cheng@arm.com>
 
        PR tree-optimization/81627
index 524208ae564e7a85f36b0dc57a6de884c2af4930..eeeff1ed166734328a612142fdf6235274f9e858 100644 (file)
@@ -8458,14 +8458,9 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
        {
          /* We can fold this expression to a constant if the non-constant
             offset parts are equal.  */
-         if ((offset0 == offset1
-              || (offset0 && offset1
-                  && operand_equal_p (offset0, offset1, 0)))
-             && (equality_code
-                 || (indirect_base0
-                     && (DECL_P (base0) || CONSTANT_CLASS_P (base0)))
-                 || POINTER_TYPE_OVERFLOW_UNDEFINED))
-
+         if (offset0 == offset1
+             || (offset0 && offset1
+                 && operand_equal_p (offset0, offset1, 0)))
            {
              if (!equality_code
                  && bitpos0 != bitpos1
@@ -8500,11 +8495,7 @@ fold_comparison (location_t loc, enum tree_code code, tree type,
             because pointer arithmetic is restricted to retain within an
             object and overflow on pointer differences is undefined as of
             6.5.6/8 and /9 with respect to the signed ptrdiff_t.  */
-         else if (bitpos0 == bitpos1
-                  && (equality_code
-                      || (indirect_base0
-                          && (DECL_P (base0) || CONSTANT_CLASS_P (base0)))
-                      || POINTER_TYPE_OVERFLOW_UNDEFINED))
+         else if (bitpos0 == bitpos1)
            {
              /* By converting to signed sizetype we cover middle-end pointer
                 arithmetic which operates on unsigned pointer types of size
@@ -9590,7 +9581,7 @@ fold_binary_loc (location_t loc,
 
          /* With undefined overflow prefer doing association in a type
             which wraps on overflow, if that is one of the operand types.  */
-         if ((POINTER_TYPE_P (type) && POINTER_TYPE_OVERFLOW_UNDEFINED)
+         if (POINTER_TYPE_P (type)
              || (INTEGRAL_TYPE_P (type) && !TYPE_OVERFLOW_WRAPS (type)))
            {
              if (INTEGRAL_TYPE_P (TREE_TYPE (arg0))
@@ -9604,7 +9595,7 @@ fold_binary_loc (location_t loc,
 
          /* With undefined overflow we can only associate constants with one
             variable, and constants whose association doesn't overflow.  */
-         if ((POINTER_TYPE_P (atype) && POINTER_TYPE_OVERFLOW_UNDEFINED)
+         if (POINTER_TYPE_P (atype)
              || (INTEGRAL_TYPE_P (atype) && !TYPE_OVERFLOW_WRAPS (atype)))
            {
              if (var0 && var1)
index 1cabcfc618a4b810ab18c62041d6e54b3720f52a..e98db52af84946cf579c6434e06d450713a47162 100644 (file)
@@ -3223,14 +3223,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
                    || TREE_CODE (base1) == STRING_CST))
          equal = (base0 == base1);
      }
-     (if (equal == 1
-         && (cmp == EQ_EXPR || cmp == NE_EXPR
-             /* If the offsets are equal we can ignore overflow.  */
-             || off0 == off1
-             || POINTER_TYPE_OVERFLOW_UNDEFINED
-             /* Or if we compare using pointers to decls or strings.  */
-             || (POINTER_TYPE_P (TREE_TYPE (@2))
-                 && (DECL_P (base0) || TREE_CODE (base0) == STRING_CST))))
+     (if (equal == 1)
       (switch
        (if (cmp == EQ_EXPR)
        { constant_boolean_node (off0 == off1, type); })
index a86b281157e9e991f9e6cc275dad18735341a32f..02df696860c1d50bcabca245a1fe03d0048a7f37 100644 (file)
@@ -1,3 +1,8 @@
+2017-08-01  Bin Cheng  <bin.cheng@arm.com>
+
+       * gcc.dg/no-strict-overflow-7.c: Revise comment and test string.
+       * gcc.dg/tree-ssa/pr81388-1.c: Ditto.
+
 2017-08-01  Bin Cheng  <bin.cheng@arm.com>
 
        PR tree-optimization/81627
index 19e1b55bb12f8f530efbb3dcb5d1400c543ba1aa..0e73d486f22f1d6b5d8993c47b1f80861884840e 100644 (file)
@@ -3,8 +3,8 @@
 
 /* Source: Ian Lance Taylor.  Dual of strict-overflow-6.c.  */
 
-/* We can only simplify the conditional when using strict overflow
-   semantics.  */
+/* We can simplify the conditional because pointer overflow always has
+   undefined semantics.  */
 
 int
 foo (char* p)
@@ -12,4 +12,4 @@ foo (char* p)
   return p + 1000 < p;
 }
 
-/* { dg-final { scan-tree-dump "\[+\]\[ \]*1000" "optimized" } } */
+/* { dg-final { scan-tree-dump "return 0" "optimized" } } */
index ecfe12929ccbcf8f5b56ef04dcb5533fd62f0070..0beb5109d403ba53a5cf556e80f49208add106e1 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fno-strict-overflow -fdump-tree-ivcanon-details" } */
+/* { dg-options "-O2 -fno-strict-overflow -fdump-tree-tailc-details" } */
 
 void bar();
 void foo(char *dst)
@@ -11,4 +11,6 @@ void foo(char *dst)
   } while (dst < end);
 }
 
-/* { dg-final { scan-tree-dump-times " zero if " 1 "ivcanon" } } */
+/* The loop only iterates once because pointer overflow always has undefined
+   semantics.  As a result, call to bar becomes tail call.  */
+/* { dg-final { scan-tree-dump-times "Found tail call " 1 "tailc" } } */
index e9e7931b1ae6ea83051e33012ff6750c9d693495..d955b58d82a9c1491f85d987fff0e60c31bf8fd7 100644 (file)
@@ -859,9 +859,6 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int,
    && !TYPE_OVERFLOW_WRAPS (TYPE)                      \
    && (flag_sanitize & SANITIZE_SI_OVERFLOW))
 
-/* True if pointer types have undefined overflow.  */
-#define POINTER_TYPE_OVERFLOW_UNDEFINED (!flag_wrapv)
-
 /* Nonzero in a VAR_DECL or STRING_CST means assembler code has been written.
    Nonzero in a FUNCTION_DECL means that the function has been compiled.
    This is interesting in an inline function, since it might not need