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
This commit is contained in:
parent
dd1c676f75
commit
2343af6558
@ -1,3 +1,11 @@
|
||||
2013-05-24 Jeff Law <law@redhat.com>
|
||||
|
||||
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.
|
||||
|
||||
2013-05-24 Dehao Chen <dehao@google.com>
|
||||
|
||||
* gcc/tree-cfg.c (locus_discrim_map): Fix the typo.
|
||||
|
@ -1,3 +1,9 @@
|
||||
2013-05-24 Jeff Law <law@redhat.com>
|
||||
|
||||
PR tree-optimization/57124
|
||||
* gcc.c-torture/execute/pr57124.c: New test.
|
||||
* gcc.c-torture/execute/pr57124.x: Set -fno-strict-overflow.
|
||||
|
||||
2013-05-24 Martin Jambor <mjambor@suse.cz>
|
||||
|
||||
PR tree-optimization/57294
|
||||
|
27
gcc/testsuite/gcc.c-torture/execute/pr57124.c
Normal file
27
gcc/testsuite/gcc.c-torture/execute/pr57124.c
Normal file
@ -0,0 +1,27 @@
|
||||
__attribute__ ((noinline))
|
||||
foo(short unsigned int *p1, short unsigned int *p2)
|
||||
{
|
||||
short unsigned int x1, x4;
|
||||
int x2, x3, x5, x6;
|
||||
unsigned int x7;
|
||||
|
||||
x1 = *p1;
|
||||
x2 = (int) x1;
|
||||
x3 = x2 * 65536;
|
||||
x4 = *p2;
|
||||
x5 = (int) x4;
|
||||
x6 = x3 + x4;
|
||||
x7 = (unsigned int) x6;
|
||||
if (x7 <= 268435455U)
|
||||
abort ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
short unsigned int x, y;
|
||||
x = -5;
|
||||
y = -10;
|
||||
foo (&x, &y);
|
||||
}
|
||||
|
2
gcc/testsuite/gcc.c-torture/execute/pr57124.x
Normal file
2
gcc/testsuite/gcc.c-torture/execute/pr57124.x
Normal file
@ -0,0 +1,2 @@
|
||||
set additional_flags "-fno-strict-overflow"
|
||||
return 0
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user