summaryrefslogtreecommitdiffstats
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authordnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-01 13:57:29 +0000
committerdnovillo <dnovillo@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-01 13:57:29 +0000
commitd461f9a92edee6820914016dd5b179d967f19b60 (patch)
treefce09b35d76668782499f03fb6d4aa8ccc08b2d7 /gcc/tree-vrp.c
parent6dc40b20fea5d2e2f8f32e78650bac0dfdb48e04 (diff)
downloadppe42-gcc-d461f9a92edee6820914016dd5b179d967f19b60.tar.gz
ppe42-gcc-d461f9a92edee6820914016dd5b179d967f19b60.zip
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104858 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 4aec9fcc4dd..21e6cf6d100 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -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
OpenPOWER on IntegriCloud