aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vrp.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@gcc.gnu.org>2005-11-08 16:09:51 -0500
committerDiego Novillo <dnovillo@gcc.gnu.org>2005-11-08 16:09:51 -0500
commitda11c5d2261283280dade0b9a7942ed56c4e67de (patch)
tree7ce2ce0fa788bb9692659c1a68227c1f9d006c4c /gcc/tree-vrp.c
parent230d8ead8c85ba9068412c1773401b0f1cd44148 (diff)
downloadgcc-da11c5d2261283280dade0b9a7942ed56c4e67de.zip
gcc-da11c5d2261283280dade0b9a7942ed56c4e67de.tar.gz
gcc-da11c5d2261283280dade0b9a7942ed56c4e67de.tar.bz2
re PR c++/23046 (ICE in set_value_range, at tree-vrp.c:191)
2005-11-08 James A. Morrison <phython@gcc.gnu.org> Diego Novillo <dnovillo@redhat.com> PR 23046 * tree-vrp.c (register_edge_assert_for): Do not register always-false predicates. testsuite/ PR 23046 * g++.dg/tree-ssa/pr23046.C: New test. From-SVN: r106656
Diffstat (limited to 'gcc/tree-vrp.c')
-rw-r--r--gcc/tree-vrp.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 929908b..d49c4d4 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -2504,6 +2504,24 @@ register_edge_assert_for (tree name, edge e, block_stmt_iterator si)
need to invert the sign comparison. */
if (is_else_edge)
comp_code = invert_tree_comparison (comp_code, 0);
+
+ /* Do not register always-false predicates. FIXME, this
+ works around a limitation in fold() when dealing with
+ enumerations. Given 'enum { N1, N2 } x;', fold will not
+ fold 'if (x > N2)' to 'if (0)'. */
+ if ((comp_code == GT_EXPR || comp_code == LT_EXPR)
+ && (INTEGRAL_TYPE_P (TREE_TYPE (val))
+ || SCALAR_FLOAT_TYPE_P (TREE_TYPE (val))))
+ {
+ tree min = TYPE_MIN_VALUE (TREE_TYPE (val));
+ tree max = TYPE_MAX_VALUE (TREE_TYPE (val));
+
+ if (comp_code == GT_EXPR && compare_values (val, max) == 0)
+ return false;
+
+ if (comp_code == LT_EXPR && compare_values (val, min) == 0)
+ return false;
+ }
}
}
else