aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenth@gcc.gnu.org>2005-06-03 15:15:46 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2005-06-03 15:15:46 +0000
commit548e34cdb7391d27e3d2342160bd417261b907a4 (patch)
tree09add2482e2b513aadcdf21508f776a89347e306 /gcc/fold-const.c
parentff5c4582e0aef13b6b0908db7a8819eba87c2115 (diff)
downloadgcc-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
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c12
1 files changed, 8 insertions, 4 deletions
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;