This helper is called by tree_expr_nonzero_warnv_p(), a helper that is
gating a call to fold_overflow_warning() that we want to eliminate.
For now let's change the comment from tree_expr_nonzero_warnv_p() to
mention that we're throwing overflow warnings just for certain cases,
not all. We'll change that comment again when we get to work on
tree_expr_nonzero_warnv_p().
The helper is renamed to remove the "warn" from its name since it
doesn't throw or set any overflow warnings anymore.
gcc/ChangeLog:
* fold-const.cc (mask_with_tz): Changed comment that describes
tree_expr_nonzero_warnv_p warn on overflow behavior.
(tree_expr_nonzero_warnv_p): Removed strict_overflow_p flag.
(tree_unary_nonzero_warnv_p): Renamed to tree_unary_nonzero_p.
(tree_unary_nonzero_p): Removed strict_overflow_p flag.
* fold-const.h (tree_unary_nonzero_warnv_p): Renamed to
tree_unary_nonzero_p.
(tree_unary_nonzero_p): Removed strict_overflow_p flag.
---
gcc/fold-const.cc | 29 ++++++++++++-----------------
gcc/fold-const.h | 2 +-
2 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 144d0a116b2..d97ed7e48b6 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -10794,9 +10794,10 @@ mask_with_tz (tree type, const wide_int &x, const
wide_int &y)
For floating point we further ensure that T is not denormal.
Similar logic is present in nonzero_address in rtlanal.h.
- If the return value is based on the assumption that signed overflow
- is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't
- change *STRICT_OVERFLOW_P. */
+ For certain tree code classes, if the return value is based on
+ the assumption that signed overflow is undefined, set
+ *STRICT_OVERFLOW_P to true; otherwise, don't change
+ *STRICT_OVERFLOW_P. */
static bool
tree_expr_nonzero_warnv_p (tree t, bool *strict_overflow_p)
@@ -10812,8 +10813,7 @@ tree_expr_nonzero_warnv_p (tree t, bool
*strict_overflow_p)
switch (TREE_CODE_CLASS (code))
{
case tcc_unary:
- return tree_unary_nonzero_warnv_p (code, type, TREE_OPERAND (t, 0),
- strict_overflow_p);
+ return tree_unary_nonzero_p (code, type, TREE_OPERAND (t, 0));
case tcc_binary:
case tcc_comparison:
return tree_binary_nonzero_warnv_p (code, type,
@@ -10832,8 +10832,7 @@ tree_expr_nonzero_warnv_p (tree t, bool
*strict_overflow_p)
switch (code)
{
case TRUTH_NOT_EXPR:
- return tree_unary_nonzero_warnv_p (code, type, TREE_OPERAND (t, 0),
- strict_overflow_p);
+ return tree_unary_nonzero_p (code, type, TREE_OPERAND (t, 0));
case TRUTH_AND_EXPR:
case TRUTH_OR_EXPR:
@@ -15221,21 +15220,17 @@ tree_expr_nonnegative_p (tree t)
/* Return true when (CODE OP0) is an address and is known to be nonzero.
For floating point we further ensure that T is not denormal.
- Similar logic is present in nonzero_address in rtlanal.h.
-
- If the return value is based on the assumption that signed overflow
- is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't
- change *STRICT_OVERFLOW_P. */
+ Similar logic is present in nonzero_address in rtlanal.h. */
bool
-tree_unary_nonzero_warnv_p (enum tree_code code, tree type, tree op0,
- bool *strict_overflow_p)
+tree_unary_nonzero_p (enum tree_code code, tree type, tree op0)
{
+ bool sub_strict_overflow_p = false;
switch (code)
{
case ABS_EXPR:
return tree_expr_nonzero_warnv_p (op0,
- strict_overflow_p);
+ &sub_strict_overflow_p);
case NOP_EXPR:
{
@@ -15244,13 +15239,13 @@ tree_unary_nonzero_warnv_p (enum tree_code code, tree
type, tree op0,
return (TYPE_PRECISION (outer_type) >= TYPE_PRECISION (inner_type)
&& tree_expr_nonzero_warnv_p (op0,
- strict_overflow_p));
+ &sub_strict_overflow_p));
}
break;
case NON_LVALUE_EXPR:
return tree_expr_nonzero_warnv_p (op0,
- strict_overflow_p);
+ &sub_strict_overflow_p);
default:
break;
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index 49d481398a7..0e6b3306034 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -162,7 +162,7 @@ extern bool ptr_difference_const (tree, tree, poly_int64 *);
extern enum tree_code invert_tree_comparison (enum tree_code, bool);
extern bool inverse_conditions_p (const_tree, const_tree);
-extern bool tree_unary_nonzero_warnv_p (enum tree_code, tree, tree, bool *);
+extern bool tree_unary_nonzero_p (enum tree_code, tree, tree);
extern bool tree_binary_nonzero_warnv_p (enum tree_code, tree, tree, tree op1,
bool *);
extern bool tree_single_nonzero_warnv_p (tree, bool *);
--
2.43.0