diff options
author | Jeff Law <law@redhat.com> | 2013-05-24 11:13:38 -0600 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2013-05-24 11:13:38 -0600 |
commit | 2343af65585862c38ab76e78387c2ae60c93f227 (patch) | |
tree | a8e876918b34462b5e7b7c8a733d2aeed5023f1d /gcc/tree-vrp.c | |
parent | dd1c676f756ac4d885e1629a76c5735fa79544a1 (diff) | |
download | gcc-2343af65585862c38ab76e78387c2ae60c93f227.zip gcc-2343af65585862c38ab76e78387c2ae60c93f227.tar.gz gcc-2343af65585862c38ab76e78387c2ae60c93f227.tar.bz2 |
re PR tree-optimization/57124 (254.gap@spec2000 got miscompare after r198413)
PR tree-optimization/57124
* tree-vrp.c (simplify_cond_using_ranges): Only simplify a
conversion feeding a condition if the range has an overflow
if -fstrict-overflow. Add warnings for when we do make the
transformation.
PR tree-optimization/57124
* gcc.c-torture/execute/pr57124.c: New test.
* gcc.c-torture/execute/pr57124.x: Set -fno-strict-overflow.
From-SVN: r199305
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r-- | gcc/tree-vrp.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 66c50ca..ec7ef8f 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -8670,8 +8670,32 @@ simplify_cond_using_ranges (gimple stmt) && range_fits_type_p (vr, TYPE_PRECISION (TREE_TYPE (op0)), TYPE_UNSIGNED (TREE_TYPE (op0))) - && int_fits_type_p (op1, TREE_TYPE (innerop))) + && int_fits_type_p (op1, TREE_TYPE (innerop)) + /* The range must not have overflowed, or if it did overflow + we must not be wrapping/trapping overflow and optimizing + with strict overflow semantics. */ + && ((!is_negative_overflow_infinity (vr->min) + && !is_positive_overflow_infinity (vr->max)) + || TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (innerop)))) { + /* If the range overflowed and the user has asked for warnings + when strict overflow semantics were used to optimize code, + issue an appropriate warning. */ + if ((is_negative_overflow_infinity (vr->min) + || is_positive_overflow_infinity (vr->max)) + && issue_strict_overflow_warning (WARN_STRICT_OVERFLOW_CONDITIONAL)) + { + location_t location; + + if (!gimple_has_location (stmt)) + location = input_location; + else + location = gimple_location (stmt); + warning_at (location, OPT_Wstrict_overflow, + "assuming signed overflow does not occur when " + "simplifying conditional"); + } + tree newconst = fold_convert (TREE_TYPE (innerop), op1); gimple_cond_set_lhs (stmt, innerop); gimple_cond_set_rhs (stmt, newconst); |