aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAldy Hernandez <aldyh@gcc.gnu.org>2019-04-16 13:50:39 +0000
committerAldy Hernandez <aldyh@gcc.gnu.org>2019-04-16 13:50:39 +0000
commit88fcebb6cf8c245049f59c1b8af6a471d991082c (patch)
treed63d33f96550533d9d4e29d967327e8a2f012b58 /gcc
parent4927afc428f1ee90fe7f798d2e1a6dd6e3ef19f3 (diff)
downloadgcc-88fcebb6cf8c245049f59c1b8af6a471d991082c.zip
gcc-88fcebb6cf8c245049f59c1b8af6a471d991082c.tar.gz
gcc-88fcebb6cf8c245049f59c1b8af6a471d991082c.tar.bz2
Fix fall out from merge.
Differences from trunk at merge point are: > FAIL: gcc.dg/uninit-pred-6_c.c bogus warning (test for bogus messages, line 25) Expected. Long-standing regression in our branch. Jeff has mentioned he has a work-in-progress to fix this. < XFAIL: gcc.dg/pr80776-1.c (test for bogus messages, line 22) < XFAIL: gcc.dg/Walloca-6.c (test for excess errors) Expected. Ranger is smarter than mainline. > XFAIL: gcc.dg/tree-ssa/rvrp-abs-3.c scan-tree-dump rvrp "return 1;" Known failure. We need to handle IMAGPART_EXPR. > FAIL: gcc.dg/tree-ssa/builtin-fprintf-warn-2.c note (test for warnings, line 87) > FAIL: gcc.dg/tree-ssa/builtin-fprintf-warn-2.c (test for warnings, line 155) > FAIL: gcc.dg/tree-ssa/builtin-fprintf-warn-2.c (test for warnings, line 207) > FAIL: gcc.dg/tree-ssa/builtin-fprintf-warn-2.c (test for warnings, line 265) > FAIL: gcc.dg/tree-ssa/builtin-fprintf-warn-2.c (test for warnings, line 323) > FAIL: gcc.dg/tree-ssa/builtin-fprintf-warn-2.c (test for warnings, line 87) > FAIL: gcc.dg/tree-ssa/builtin-printf-warn-2.c (test for warnings, line 124) > FAIL: gcc.dg/tree-ssa/builtin-printf-warn-2.c (test for warnings, line 176) > FAIL: gcc.dg/tree-ssa/builtin-printf-warn-2.c (test for warnings, line 234) > FAIL: gcc.dg/tree-ssa/builtin-printf-warn-2.c (test for warnings, line 292) > FAIL: gcc.dg/tree-ssa/builtin-printf-warn-2.c (test for warnings, line 71) REGRESSION: Aldy From-SVN: r270392
Diffstat (limited to 'gcc')
-rw-r--r--gcc/calls.c3
-rw-r--r--gcc/gimple-ssa-sprintf.c16
-rw-r--r--gcc/gimple-ssa-warn-restrict.c7
-rw-r--r--gcc/range-op.c30
-rw-r--r--gcc/range.c37
-rw-r--r--gcc/range.h37
-rw-r--r--gcc/ssa-range.h2
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-24.c39
-rw-r--r--gcc/tree-ssa-dom.c1
9 files changed, 99 insertions, 73 deletions
diff --git a/gcc/calls.c b/gcc/calls.c
index cfc6f56..87f112c 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -1263,7 +1263,8 @@ get_size_range (tree exp, tree range[2], bool allow_zero /* = false */,
r = value_range_to_irange (exptype, kind, min, max);
}
else if (!call || TREE_CODE (exp) != SSA_NAME || !integral
- || !ranger.range_of_expr (r, exp, call))
+ || !ranger.range_of_expr (r, exp, call)
+ || r.undefined_p ())
{
/* Use the full range of the type of the expression when
no value range information is available. */
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 9868fe7..e566c31 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -4265,10 +4265,26 @@ pass_sprintf_length::execute (function *fun)
{
init_target_to_host_charmap ();
+ /* Dominator and SCEV info is needed for range refinement of PHIs in
+ the on-demand ranger (which uses loop_ranger). */
+ calculate_dominance_info (CDI_DOMINATORS);
+ bool use_scev = optimize > 0 && flag_printf_return_value;
+ if (use_scev)
+ {
+ loop_optimizer_init (LOOPS_NORMAL);
+ scev_initialize ();
+ }
+
basic_block bb;
FOR_EACH_BB_FN (bb, fun)
sprintf_walk (bb);
+ if (use_scev)
+ {
+ scev_finalize ();
+ loop_optimizer_finalize ();
+ }
+
/* Clean up object size info. */
fini_object_sizes ();
return 0;
diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c
index 31437c3..036bf3b 100644
--- a/gcc/gimple-ssa-warn-restrict.c
+++ b/gcc/gimple-ssa-warn-restrict.c
@@ -329,12 +329,7 @@ builtin_memref::extend_offset_range (tree offset)
as signed. */
wide_int min, max;
value_range_kind rng = ranger_get_range_info (call, offset, &min, &max);
- if (rng == VR_RANGE)
- {
- offrange[0] += offset_int::from (min, SIGNED);
- offrange[1] += offset_int::from (max, SIGNED);
- }
- else if (rng == VR_ANTI_RANGE && wi::lts_p (max, min))
+ if (rng == VR_ANTI_RANGE && wi::lts_p (max, min))
{
/* Convert an anti-range whose upper bound is less than
its lower bound to a signed range. */
diff --git a/gcc/range-op.c b/gcc/range-op.c
index ad110f4..106d92b 100644
--- a/gcc/range-op.c
+++ b/gcc/range-op.c
@@ -149,10 +149,10 @@ min_limit (const_tree type)
return wi::min_value (TYPE_PRECISION (type) , TYPE_SIGN (type));
}
-// If the range of either operand is undefined, set the result to undefined and
-// return true. THis is a common routine to most functions as
-// undefined is a viral condition, so if either operand it undefined,
-// so is the result.
+// If the range of either operand is undefined, set the result to
+// undefined and return true. This is a common routine to most
+// functions as undefined is a viral condition, so if either operand
+// is undefined, so is the result.
inline bool
empty_range_check (irange& r, const irange& op1, const irange & op2, tree type)
@@ -671,6 +671,12 @@ op_wi (enum tree_code code, irange &r, tree rh_type,
r.set_varying (type);
return false;
+ case ABSU_EXPR:
+ wide_int_range_absu (new_lb, new_ub, TYPE_PRECISION (r.type ()),
+ lh_lb, lh_ub);
+ r.union_ (irange (unsigned_type_for (r.type ()), new_lb, new_ub));
+ return true;
+
default:
return false;
}
@@ -739,13 +745,13 @@ op_rr (enum tree_code code, irange& r, const irange& lh, const irange& rh)
return res && !r.varying_p ();
}
-/* Perform a unary operation on a range. */
+/* Perform a unary operation on a range. TYPE is the type of the
+ resulting operation (and thus R). */
static bool
-op_rr_unary (enum tree_code code, irange &r, const irange &lh)
+op_rr_unary (enum tree_code code, irange &r, const irange &lh, tree type)
{
bool res = false;
- tree type = lh.type ();
// Clear and set result type.
r.set_undefined (type);
@@ -1967,12 +1973,12 @@ class operator_identity : public trange_operator
class operator_abs : public trange_operator
{
public:
- operator_abs () : trange_operator (ABS_EXPR) { }
+ operator_abs (enum tree_code code) : trange_operator (code) { }
virtual bool fold_range (irange& r, const irange& op1,
const irange& op2) const;
virtual bool op1_range (irange& r,
const irange& lhs, const irange& op2) const;
-} op_abs;
+} op_abs (ABS_EXPR), op_absu (ABSU_EXPR);
bool
operator_abs::fold_range (irange &r,
@@ -1982,13 +1988,17 @@ operator_abs::fold_range (irange &r,
if (empty_range_check (r, lh, rh, type))
return true;
- return op_rr_unary (ABS_EXPR, r, lh);
+ return op_rr_unary (code, r, lh, type);
}
bool
operator_abs::op1_range (irange& r,
const irange& lhs, const irange& op2) const
{
+ // FIXME: ?? Andrew TODO ??
+ if (code == ABSU_EXPR)
+ return false;
+
tree type = lhs.type ();
if (empty_range_check (r, lhs, op2, type))
return true;
diff --git a/gcc/range.c b/gcc/range.c
index 8c68f8b..a91def8 100644
--- a/gcc/range.c
+++ b/gcc/range.c
@@ -164,19 +164,6 @@ irange_storage::set_empty_pair (unsigned i, unsigned j, tree type)
}
}
-// Return TRUE if pair [i, j] is marked as empty.
-
-inline bool
-irange_storage::empty_pair_p (unsigned i, unsigned j, tree type) const
-{
- unsigned precision = wi::get_precision (trailing_bounds[0]);
- if (precision == 1 && TYPE_SIGN (type) == SIGNED)
- return (trailing_bounds[i] == wi::zero (precision)
- && trailing_bounds[j] == wi::one (precision));
- return (trailing_bounds[i] == wi::one (precision)
- && trailing_bounds[j] == wi::zero (precision));
-}
-
irange::irange (tree type, const irange_storage *storage)
{
m_type = type;
@@ -222,30 +209,6 @@ irange::set_varying (tree type)
init (type, min, max);
}
-// Return true if this range is the full range for its type.
-
-bool
-irange::varying_p () const
-{
- irange tmp;
- tmp.set_varying (m_type);
- return (*this == tmp);
-}
-
-inline bool
-irange::zero_p () const
-{
- unsigned prec = TYPE_PRECISION (m_type);
- return *this == irange (m_type, wi::zero (prec), wi::zero (prec));
-}
-
-inline bool
-irange::non_zero_p () const
-{
- unsigned prec = TYPE_PRECISION (m_type);
- return *this == irange (m_type, wi::zero (prec), wi::zero (prec), INVERSE);
-}
-
bool
irange::valid_p () const
{
diff --git a/gcc/range.h b/gcc/range.h
index f38f4d0..581dc7e 100644
--- a/gcc/range.h
+++ b/gcc/range.h
@@ -187,6 +187,30 @@ irange::supports_type_p (tree type)
return NULL;
}
+inline bool
+irange::zero_p () const
+{
+ unsigned prec = TYPE_PRECISION (m_type);
+ return *this == irange (m_type, wi::zero (prec), wi::zero (prec));
+}
+
+inline bool
+irange::non_zero_p () const
+{
+ unsigned prec = TYPE_PRECISION (m_type);
+ return *this == irange (m_type, wi::zero (prec), wi::zero (prec), INVERSE);
+}
+
+// Return true if this range is the full range for its type.
+
+inline bool
+irange::varying_p () const
+{
+ irange tmp;
+ tmp.set_varying (m_type);
+ return (*this == tmp);
+}
+
// An irange is memory inefficient, so this class is used to store
// them in memory. It is a variable length structure that contains
// the sub-range pairs as well as the non-zero bitmask. The number of
@@ -266,4 +290,17 @@ irange_storage::ggc_alloc_init (const irange &ir)
return stow;
}
+// Return TRUE if pair [i, j] is marked as empty.
+
+inline bool
+irange_storage::empty_pair_p (unsigned i, unsigned j, tree type) const
+{
+ unsigned precision = wi::get_precision (trailing_bounds[0]);
+ if (precision == 1 && TYPE_SIGN (type) == SIGNED)
+ return (trailing_bounds[i] == wi::zero (precision)
+ && trailing_bounds[j] == wi::one (precision));
+ return (trailing_bounds[i] == wi::one (precision)
+ && trailing_bounds[j] == wi::zero (precision));
+}
+
#endif // GCC_RANGE_H
diff --git a/gcc/ssa-range.h b/gcc/ssa-range.h
index 025b463..d2cdc6b 100644
--- a/gcc/ssa-range.h
+++ b/gcc/ssa-range.h
@@ -206,7 +206,7 @@ on_demand_get_range_on_stmt (irange &r, tree ssa, gimple *stmt)
{
if (!cfun->cfg)
return false;
- global_ranger ranger;
+ loop_ranger ranger;
bool ret;
ret = ranger.range_of_expr (r, ssa, stmt);
if (ret && r.varying_p ())
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-24.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-24.c
index 51cd892..43b550e 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-24.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-24.c
@@ -6,44 +6,49 @@
int result;
int shouldnt_happen_from_bb4;
-void __GIMPLE (startwith ("thread1")) foo (int arg1, int arg2)
+void __GIMPLE (ssa, startwith ("thread1")) foo (int xarg1, int xarg2)
{
int v1;
int _14;
unsigned int _15;
unsigned int _16;
-
- bb_2:
- if (arg1 == arg2)
- goto bb_3;
+ int arg1;
+ int arg2;
+
+ __BB(2):
+ arg1_597 = xarg1_9(D);
+ arg2_598 = xarg2_10(D);
+ if (arg1_597 == arg2_598)
+ goto __BB3;
else
- goto bb_4;
+ goto __BB4;
- bb_3:
+ __BB(3):
result = 1;
- goto bb_5;
+ goto __BB5;
- bb_4:
+ __BB(4):
result = 2;
+ goto __BB5;
- bb_5:
- v1_595 = __PHI (bb_3: arg1, bb_4: 0);
+ __BB(5):
+ v1_595 = __PHI (__BB3: arg1_597, __BB4: 0);
_14 = v1_595 * 3600;
_15 = (unsigned int) _14;
_16 = _15 / 60U;
if (_16 > 389U)
- goto bb_6;
+ goto __BB6;
else
- goto bb_7;
+ goto __BB7;
- bb_6:
+ __BB(6):
shouldnt_happen_from_bb4 = 0;
- goto bb_8;
+ goto __BB8;
- bb_7:
+ __BB(7):
result = 3;
- bb_8:
+ __BB(8):
return;
}
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 37f1578..32b4d8e 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -1985,7 +1985,6 @@ dom_opt_dom_walker::optimize_stmt (basic_block bb, gimple_stmt_iterator *si,
edge retval = NULL;
old_stmt = stmt = gsi_stmt (*si);
- was_noreturn = is_gimple_call (stmt) && gimple_call_noreturn_p (stmt);
if (dump_file && (dump_flags & TDF_DETAILS))
{