Commit fde5c44c by James A. Morrison Committed by Diego Novillo

re PR tree-optimization/23604 (wrong code due to VRP)


	PR 23604
	* tree-vrp.c (extract_range_from_assert): For !=
	assertions, only build an anti-range if LIMIT is a
	single-valued range.

testsuite/

	PR 23604
	* gcc.c-torture/execute/pr23604.c: New test.

Co-Authored-By: Diego Novillo <dnovillo@redhat.com>

From-SVN: r104858
parent 03551860
2005-10-01 James A. Morrison <phython@gcc.gnu.org>
Diego Novillo <dnovillo@redhat.com>
PR 23604
* tree-vrp.c (extract_range_from_assert): For !=
assertions, only build an anti-range if LIMIT is a
single-valued range.
2005-09-30 Richard Earnshaw <richard.earnshaw@arm.com>
* arm.md (movqi): On thumb when optimizing, handle loading from
......
2005-10-01 James A. Morrison <phython@gcc.gnu.org>
Diego Novillo <dnovillo@redhat.com>
PR 23604
* gcc.c-torture/execute/pr23604.c: New test.
2005-10-01 Paul Thomas <pault@gcc.gnu.org>
PR fortran/16404
extern void abort (void);
int g(int i, int j)
{
if (i>-1)
if (i<2)
{
if (i != j)
{
if (j != 0)
return 0;
}
}
return 1;
}
int main(void)
{
if (!g(1, 0))
abort ();
return 0;
}
......@@ -774,17 +774,32 @@ extract_range_from_assert (value_range_t *vr_p, tree expr)
LIMIT's range was ~[0, 0], the assertion 'VAR != LIMIT' does
not imply that VAR's range is [0, 0]. So, in the case of
anti-ranges, we just assert the inequality using LIMIT and
not its anti-range. */
if (limit_vr == NULL
|| limit_vr->type == VR_ANTI_RANGE)
not its anti-range.
If LIMIT_VR is a range, we can only use it to build a new
anti-range if LIMIT_VR is a single-valued range. For
instance, if LIMIT_VR is [0, 1], the predicate
VAR != [0, 1] does not mean that VAR's range is ~[0, 1].
Rather, it means that for value 0 VAR should be ~[0, 0]
and for value 1, VAR should be ~[1, 1]. We cannot
represent these ranges.
The only situation in which we can build a valid
anti-range is when LIMIT_VR is a single-valued range
(i.e., LIMIT_VR->MIN == LIMIT_VR->MAX). In that case,
build the anti-range ~[LIMIT_VR->MIN, LIMIT_VR->MAX]. */
if (limit_vr
&& limit_vr->type == VR_RANGE
&& compare_values (limit_vr->min, limit_vr->max) == 0)
{
min = limit;
max = limit;
min = limit_vr->min;
max = limit_vr->max;
}
else
{
min = limit_vr->min;
max = limit_vr->max;
/* In any other case, we cannot use LIMIT's range to build a
valid anti-range. */
min = max = limit;
}
/* If MIN and MAX cover the whole range for their type, then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment