From 7587869b947a230a18dc90a4911eb29c71b0759d Mon Sep 17 00:00:00 2001 From: rakdver Date: Fri, 19 May 2006 13:24:42 +0000 Subject: [PATCH] * tree-vrp.c (valid_value_p): New function. (adjust_range_with_scev): Fail if the value of bound is not simple. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@113907 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/tree-vrp.c | 23 +++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c4a65123d45..f8a4de183c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-05-19 Zdenek Dvorak + + * tree-vrp.c (valid_value_p): New function. + (adjust_range_with_scev): Fail if the value of bound is not + simple. + 2006-05-19 Richard Sandiford * config/mips/linux-unwind.h: Include diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index d487df62caa..1734d44eccf 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -409,6 +409,22 @@ vrp_expr_computes_nonzero (tree expr) return false; } +/* Returns true if EXPR is a valid value (as expected by compare_values) -- + a gimple invariant, or SSA_NAME +- CST. */ + +static bool +valid_value_p (tree expr) +{ + if (TREE_CODE (expr) == SSA_NAME) + return true; + + if (TREE_CODE (expr) == PLUS_EXPR + || TREE_CODE (expr) == MINUS_EXPR) + return (TREE_CODE (TREE_OPERAND (expr, 0)) == SSA_NAME + && TREE_CODE (TREE_OPERAND (expr, 1)) == INTEGER_CST); + + return is_gimple_min_invariant (expr); +} /* Compare two values VAL1 and VAL2. Return @@ -1974,9 +1990,12 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop, tree stmt, step = evolution_part_in_loop_num (chrec, loop->num); /* If STEP is symbolic, we can't know whether INIT will be the - minimum or maximum value in the range. */ + minimum or maximum value in the range. Also, unless INIT is + a simple expression, compare_values and possibly other functions + in tree-vrp won't be able to handle it. */ if (step == NULL_TREE - || !is_gimple_min_invariant (step)) + || !is_gimple_min_invariant (step) + || !valid_value_p (init)) return; /* Do not adjust ranges when chrec may wrap. */ -- 2.11.0