]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Remove ASSERT_EXPR.
authorAldy Hernandez <aldyh@redhat.com>
Tue, 22 Nov 2022 09:24:06 +0000 (10:24 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Thu, 24 Nov 2022 06:38:27 +0000 (07:38 +0100)
This removes all uses of ASSERT_EXPR except the internal one in ipa-*.

gcc/ChangeLog:

* doc/gimple.texi: Remove ASSERT_EXPR references.
* fold-const.cc (tree_expr_nonzero_warnv_p): Same.
(fold_binary_loc): Same.
(tree_expr_nonnegative_warnv_p): Same.
* gimple-array-bounds.cc (get_base_decl): Same.
* gimple-pretty-print.cc (dump_unary_rhs): Same.
* gimple.cc (get_gimple_rhs_num_ops): Same.
* pointer-query.cc (handle_ssa_name): Same.
* tree-cfg.cc (verify_gimple_assign_single): Same.
* tree-pretty-print.cc (dump_generic_node): Same.
* tree-scalar-evolution.cc (scev_dfs::follow_ssa_edge_expr):Same.
(interpret_rhs_expr): Same.
* tree-ssa-operands.cc (operands_scanner::get_expr_operands): Same.
* tree-ssa-propagate.cc
(substitute_and_fold_dom_walker::before_dom_children): Same.
* tree-ssa-threadedge.cc: Same.
* tree-vrp.cc (overflow_comparison_p): Same.
* tree.def (ASSERT_EXPR): Add note.
* tree.h (ASSERT_EXPR_VAR): Remove.
(ASSERT_EXPR_COND): Remove.
* vr-values.cc (simplify_using_ranges::vrp_visit_cond_stmt):
Remove comment.

16 files changed:
gcc/doc/gimple.texi
gcc/fold-const.cc
gcc/gimple-array-bounds.cc
gcc/gimple-pretty-print.cc
gcc/gimple.cc
gcc/pointer-query.cc
gcc/tree-cfg.cc
gcc/tree-pretty-print.cc
gcc/tree-scalar-evolution.cc
gcc/tree-ssa-operands.cc
gcc/tree-ssa-propagate.cc
gcc/tree-ssa-threadedge.cc
gcc/tree-vrp.cc
gcc/tree.def
gcc/tree.h
gcc/vr-values.cc

index 7832fa6ff90d737f3c6a2a3108007530cc7a3483..a4263922887bcf730bd9438a54c88eef82e0df66 100644 (file)
@@ -682,8 +682,7 @@ more than two slots on the RHS.  For instance, a @code{COND_EXPR}
 expression of the form @code{(a op b) ? x : y} could be flattened
 out on the operand vector using 4 slots, but it would also
 require additional processing to distinguish @code{c = a op b}
-from @code{c = a op b ? x : y}.  Something similar occurs with
-@code{ASSERT_EXPR}.   In time, these special case tree
+from @code{c = a op b ? x : y}.  In time, these special case tree
 expressions should be flattened into the operand vector.
 @end itemize
 
index b89cac91cae2f3e47f4407df96fb5b4f86c78d2b..114258fa182b1bede268a61e073130746545da1a 100644 (file)
@@ -10751,7 +10751,6 @@ tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p)
     case COND_EXPR:
     case CONSTRUCTOR:
     case OBJ_TYPE_REF:
-    case ASSERT_EXPR:
     case ADDR_EXPR:
     case WITH_SIZE_EXPR:
     case SSA_NAME:
@@ -12618,10 +12617,6 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type,
                                 : fold_convert_loc (loc, type, arg1);
       return tem;
 
-    case ASSERT_EXPR:
-      /* An ASSERT_EXPR should never be passed to fold_binary.  */
-      gcc_unreachable ();
-
     default:
       return NULL_TREE;
     } /* switch (code) */
@@ -15117,7 +15112,6 @@ tree_expr_nonnegative_warnv_p (tree t, bool *strict_overflow_p, int depth)
     case COND_EXPR:
     case CONSTRUCTOR:
     case OBJ_TYPE_REF:
-    case ASSERT_EXPR:
     case ADDR_EXPR:
     case WITH_SIZE_EXPR:
     case SSA_NAME:
index 1eafd3fd3e165d1bfbc89a5b5d2925076794db61..eae49ab3910ad57288d772e63af10fd610527a84 100644 (file)
@@ -75,14 +75,7 @@ get_base_decl (tree ref)
       if (gimple_assign_single_p (def))
        {
          base = gimple_assign_rhs1 (def);
-         if (TREE_CODE (base) != ASSERT_EXPR)
-           return base;
-
-         base = TREE_OPERAND (base, 0);
-         if (TREE_CODE (base) != SSA_NAME)
-           return base;
-
-         continue;
+         return base;
        }
 
       if (!gimple_nop_p (def))
index 7ec079f15c638cf64c1a4a93b27edd83b7a3fbf1..af70425763384b359ed78e1aa1afcd1a7786c9bd 100644 (file)
@@ -339,7 +339,6 @@ dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
   switch (rhs_code)
     {
     case VIEW_CONVERT_EXPR:
-    case ASSERT_EXPR:
       dump_generic_node (buffer, rhs, spc, flags, false);
       break;
 
index 6c23dd77609396624c225a83b6717b3d2c06ae91..dd054e1645374684472aae6831020c76c24e6368 100644 (file)
@@ -2408,7 +2408,6 @@ get_gimple_rhs_num_ops (enum tree_code code)
       || (SYM) == BIT_INSERT_EXPR) ? GIMPLE_TERNARY_RHS                            \
    : ((SYM) == CONSTRUCTOR                                                 \
       || (SYM) == OBJ_TYPE_REF                                             \
-      || (SYM) == ASSERT_EXPR                                              \
       || (SYM) == ADDR_EXPR                                                \
       || (SYM) == WITH_SIZE_EXPR                                           \
       || (SYM) == SSA_NAME) ? GIMPLE_SINGLE_RHS                                    \
index 0f0100233c1ef58a089d3dfa7170230f7dc7df7f..95565fd6005b99bedcbdacf8e076cf48928a301b 100644 (file)
@@ -2144,12 +2144,6 @@ handle_ssa_name (tree ptr, bool addr, int ostype,
 
   tree rhs = gimple_assign_rhs1 (stmt);
 
-  if (code == ASSERT_EXPR)
-    {
-      rhs = TREE_OPERAND (rhs, 0);
-      return compute_objsize_r (rhs, stmt, addr, ostype, pref, snlim, qry);
-    }
-
   if (code == POINTER_PLUS_EXPR
       && TREE_CODE (TREE_TYPE (rhs)) == POINTER_TYPE)
     {
index d982988048f24eb318c01ec84298282a1b8b1ba8..28175312afce59109b0255e8f756bf69e81d4ac7 100644 (file)
@@ -4795,17 +4795,6 @@ verify_gimple_assign_single (gassign *stmt)
        }
       return res;
 
-    case ASSERT_EXPR:
-      /* FIXME.  */
-      rhs1 = fold (ASSERT_EXPR_COND (rhs1));
-      if (rhs1 == boolean_false_node)
-       {
-         error ("%qs with an always-false condition", code_name);
-         debug_generic_stmt (rhs1);
-         return true;
-       }
-      break;
-
     case WITH_SIZE_EXPR:
       error ("%qs RHS in assignment statement",
             get_tree_code_name (rhs_code));
index e7a8c9481a6463b7016441b66ea68e6e604052f0..cb2a88cbdc58501fd3c5042d8c73870e0376675b 100644 (file)
@@ -3416,14 +3416,6 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags,
       pp_greater (pp);
       break;
 
-    case ASSERT_EXPR:
-      pp_string (pp, "ASSERT_EXPR <");
-      dump_generic_node (pp, ASSERT_EXPR_VAR (node), spc, flags, false);
-      pp_string (pp, ", ");
-      dump_generic_node (pp, ASSERT_EXPR_COND (node), spc, flags, false);
-      pp_greater (pp);
-      break;
-
     case SCEV_KNOWN:
       pp_string (pp, "scev_known");
       break;
index 7e2a3e986619de87e4ae9daf16198be1f13b917c..60060337804aebd4538ec90057c219fab9acf63a 100644 (file)
@@ -1122,13 +1122,11 @@ scev_dfs::follow_ssa_edge_expr (gimple *at_stmt, tree expr,
      - a PLUS_EXPR,
      - a POINTER_PLUS_EXPR,
      - a MINUS_EXPR,
-     - an ASSERT_EXPR,
      - other cases are not yet handled.  */
 
   /* For SSA_NAME look at the definition statement, handling
      PHI nodes and otherwise expand appropriately for the expression
      handling below.  */
-tail_recurse:
   if (TREE_CODE (expr) == SSA_NAME)
     {
       gimple *def = SSA_NAME_DEF_STMT (expr);
@@ -1272,12 +1270,6 @@ tail_recurse:
       return follow_ssa_edge_binary (at_stmt, type, rhs0, code, rhs1,
                                     evolution_of_loop, limit);
 
-    case ASSERT_EXPR:
-      /* This assignment is of the form: "a_1 = ASSERT_EXPR <a_2, ...>"
-        It must be handled as a copy assignment of the form a_1 = a_2.  */
-      expr = ASSERT_EXPR_VAR (rhs0);
-      goto tail_recurse;
-
     default:
       return t_false;
     }
@@ -1640,13 +1632,6 @@ interpret_rhs_expr (class loop *loop, gimple *at_stmt,
       if (code == SSA_NAME)
        return chrec_convert (type, analyze_scalar_evolution (loop, rhs1),
                              at_stmt);
-
-      if (code == ASSERT_EXPR)
-       {
-         rhs1 = ASSERT_EXPR_VAR (rhs1);
-         return chrec_convert (type, analyze_scalar_evolution (loop, rhs1),
-                               at_stmt);
-       }
     }
 
   switch (code)
index 9e85998b75e978f8bde894ddb2beaa7bca03a70b..4c90197860ce44a7ec88e41a6031bf5ff2b548c4 100644 (file)
@@ -897,7 +897,6 @@ operands_scanner::get_expr_operands (tree *expr_p, int flags)
     case BIT_INSERT_EXPR:
     case COMPOUND_EXPR:
     case OBJ_TYPE_REF:
-    case ASSERT_EXPR:
     do_binary:
       {
        get_expr_operands (&TREE_OPERAND (expr, 0), flags);
index d8b0aed4564298822f40819d0930fa16465f2e69..976b035eeece5d8f0e44015c403c392ef16100a5 100644 (file)
@@ -821,10 +821,7 @@ substitute_and_fold_dom_walker::before_dom_children (basic_block bb)
              && sprime != lhs
              && may_propagate_copy (lhs, sprime)
              && !stmt_could_throw_p (cfun, stmt)
-             && !gimple_has_side_effects (stmt)
-             /* We have to leave ASSERT_EXPRs around for jump-threading.  */
-             && (!is_gimple_assign (stmt)
-                 || gimple_assign_rhs_code (stmt) != ASSERT_EXPR))
+             && !gimple_has_side_effects (stmt))
            {
              if (dump_file && (dump_flags & TDF_DETAILS))
                {
index 905a98c8c68d98105be025b45f120dd69d64c653..cc7020ddbb3f0d5ba7d4b7643750b15d7710ec4a 100644 (file)
@@ -497,9 +497,9 @@ jump_threader::simplify_control_stmt_condition_1
     }
 
   /* If the condition has the form (A & B) CMP 0 or (A | B) CMP 0 then
-     recurse into the LHS to see if there is a dominating ASSERT_EXPR
-     of A or of B that makes this condition always true or always false
-     along the edge E.  */
+     recurse into the LHS to see if there is a simplification that
+     makes this condition always true or always false along the edge
+     E.  */
   if ((cond_code == EQ_EXPR || cond_code == NE_EXPR)
       && TREE_CODE (op0) == SSA_NAME
       && integer_zerop (op1))
index df2f1eae203245dd4c80acd8d4fd1b101ea99364..d29941d0f2d296b20de7e3e57206405c64154f1b 100644 (file)
@@ -782,10 +782,9 @@ overflow_comparison_p (tree_code code, tree name, tree val,
    <bb 6>:
    __builtin_unreachable ();
    <bb 7>:
-   x_5 = ASSERT_EXPR <x_3, ...>;
-   If x_3 has no other immediate uses (checked by caller),
-   var is the x_3 var from ASSERT_EXPR, we can clear low 5 bits
-   from the non-zero bitmask.  */
+
+   If x_3 has no other immediate uses (checked by caller), var is the
+   x_3 var, we can clear low 5 bits from the non-zero bitmask.  */
 
 void
 maybe_set_nonzero_bits (edge e, tree var)
index 62650b6934b337c5d56e5393dc114173d72c9aa9..69783bd44fcccde4d8cf862d269f9c6ca50ad541 100644 (file)
@@ -1025,7 +1025,10 @@ DEFTREECODE (POLYNOMIAL_CHREC, "polynomial_chrec", tcc_expression, 2)
    Use the interface in tree-iterator.h to access this node.  */
 DEFTREECODE (STATEMENT_LIST, "statement_list", tcc_exceptional, 0)
 
-/* Predicate assertion.  Artificial expression generated by the optimizers
+/* NOTE: This code is deprecated and should only be used internally by ipa* as
+   temporary construct.
+
+   Predicate assertion.  Artificial expression generated by the optimizers
    to keep track of predicate values.  This expression may only appear on
    the RHS of assignments.
 
index a863d2e50e5ecafa3f5da4dda98d9637261d07a9..4a19de1c94d7feb39e3184506871b9e140eb7f33 100644 (file)
@@ -1406,10 +1406,6 @@ class auto_suppress_location_wrappers
 #define OBJ_TYPE_REF_OBJECT(NODE) TREE_OPERAND (OBJ_TYPE_REF_CHECK (NODE), 1)
 #define OBJ_TYPE_REF_TOKEN(NODE)  TREE_OPERAND (OBJ_TYPE_REF_CHECK (NODE), 2)
 
-/* ASSERT_EXPR accessors.  */
-#define ASSERT_EXPR_VAR(NODE)  TREE_OPERAND (ASSERT_EXPR_CHECK (NODE), 0)
-#define ASSERT_EXPR_COND(NODE) TREE_OPERAND (ASSERT_EXPR_CHECK (NODE), 1)
-
 /* CALL_EXPR accessors.  */
 #define CALL_EXPR_FN(NODE) TREE_OPERAND (CALL_EXPR_CHECK (NODE), 1)
 #define CALL_EXPR_STATIC_CHAIN(NODE) TREE_OPERAND (CALL_EXPR_CHECK (NODE), 2)
index 5b12a776c6a7bd3cc14fc7222b91a846b5e22835..5019fea4587a072660c23eaedde7504e1e6b6a98 100644 (file)
@@ -944,49 +944,6 @@ simplify_using_ranges::vrp_visit_cond_stmt (gcond *stmt, edge *taken_edge_p)
       fprintf (dump_file, "\n");
     }
 
-  /* Compute the value of the predicate COND by checking the known
-     ranges of each of its operands.
-
-     Note that we cannot evaluate all the equivalent ranges here
-     because those ranges may not yet be final and with the current
-     propagation strategy, we cannot determine when the value ranges
-     of the names in the equivalence set have changed.
-
-     For instance, given the following code fragment
-
-        i_5 = PHI <8, i_13>
-       ...
-       i_14 = ASSERT_EXPR <i_5, i_5 != 0>
-       if (i_14 == 1)
-         ...
-
-     Assume that on the first visit to i_14, i_5 has the temporary
-     range [8, 8] because the second argument to the PHI function is
-     not yet executable.  We derive the range ~[0, 0] for i_14 and the
-     equivalence set { i_5 }.  So, when we visit 'if (i_14 == 1)' for
-     the first time, since i_14 is equivalent to the range [8, 8], we
-     determine that the predicate is always false.
-
-     On the next round of propagation, i_13 is determined to be
-     VARYING, which causes i_5 to drop down to VARYING.  So, another
-     visit to i_14 is scheduled.  In this second visit, we compute the
-     exact same range and equivalence set for i_14, namely ~[0, 0] and
-     { i_5 }.  But we did not have the previous range for i_5
-     registered, so vrp_visit_assignment thinks that the range for
-     i_14 has not changed.  Therefore, the predicate 'if (i_14 == 1)'
-     is not visited again, which stops propagation from visiting
-     statements in the THEN clause of that if().
-
-     To properly fix this we would need to keep the previous range
-     value for the names in the equivalence set.  This way we would've
-     discovered that from one visit to the other i_5 changed from
-     range [8, 8] to VR_VARYING.
-
-     However, fixing this apparent limitation may not be worth the
-     additional checking.  Testing on several code bases (GCC, DLV,
-     MICO, TRAMP3D and SPEC2000) showed that doing this results in
-     4 more predicates folded in SPEC.  */
-
   bool sop;
   val = vrp_evaluate_conditional_warnv_with_ops (stmt,
                                                 gimple_cond_code (stmt),