diff options
author | Richard Guenther <rguenth@gcc.gnu.org> | 2005-06-03 15:15:46 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2005-06-03 15:15:46 +0000 |
commit | 548e34cdb7391d27e3d2342160bd417261b907a4 (patch) | |
tree | 09add2482e2b513aadcdf21508f776a89347e306 | |
parent | ff5c4582e0aef13b6b0908db7a8819eba87c2115 (diff) | |
download | gcc-548e34cdb7391d27e3d2342160bd417261b907a4.zip gcc-548e34cdb7391d27e3d2342160bd417261b907a4.tar.gz gcc-548e34cdb7391d27e3d2342160bd417261b907a4.tar.bz2 |
re PR middle-end/21858 (ICE in compare_values, at tree-vrp.c:301)
2005-06-03 Richard Guenther <rguenth@gcc.gnu.org>
PR middle-end/21858
* fold-const.c (fold_binary): Fix type mismatches in folding
of comparisons.
* gcc.dg/pr21858.c: New testcase.
From-SVN: r100539
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr21858.c | 15 |
4 files changed, 34 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 465f49a..97461ba 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-06-03 Richard Guenther <rguenth@gcc.gnu.org> + + PR middle-end/21858 + * fold-const.c (fold_binary): Fix type mismatches in folding + of comparisons. + 2005-06-03 Kazu Hirata <kazu@codesourcery.com> * cgraph.c, cgraphunit.c, config/mips/mips.c: Fix comment diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 721701b..21a5b1a 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9303,12 +9303,16 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) switch (code) { case GE_EXPR: - arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - return fold_build2 (GT_EXPR, type, arg0, arg1); + arg1 = const_binop (MINUS_EXPR, arg1, + build_int_cst (TREE_TYPE (arg1), 1), 0); + return fold_build2 (GT_EXPR, type, arg0, + fold_convert (TREE_TYPE (arg0), arg1)); case LT_EXPR: - arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - return fold_build2 (LE_EXPR, type, arg0, arg1); + arg1 = const_binop (MINUS_EXPR, arg1, + build_int_cst (TREE_TYPE (arg1), 1), 0); + return fold_build2 (LE_EXPR, type, arg0, + fold_convert (TREE_TYPE (arg0), arg1)); default: break; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 705985f..4129b3f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-06-03 Richard Guenther <rguenth@gcc.gnu.org> + + PR middle-end/21858 + * gcc.dg/pr21858.c: New testcase. + 2005-06-03 Paolo Bonzini <bonzini@gnu.org> PR tree-optimization/21292 diff --git a/gcc/testsuite/gcc.dg/pr21858.c b/gcc/testsuite/gcc.dg/pr21858.c new file mode 100644 index 0000000..41cd240 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr21858.c @@ -0,0 +1,15 @@ +/* Fold used to create a GT_EXPR of pointer vs. integer types, + which caused us to ICE in VRP. */ + +/* { dg-do compile } */ +/* { dg-options "-Os -w" } */ + +unsigned int dsdblm_GetBlockAddress(); +void error_LocalAssert(void); +int dsdblm_CreateBlock(unsigned int address) +{ + address = dsdblm_GetBlockAddress(); + if (address >= (void*)0x00020000) + error_LocalAssert(); + return address; +} |