diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-04-20 13:40:47 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2007-04-20 13:40:47 +0200 |
commit | 86122f7282ff1c895004881a9febde7bf15e928c (patch) | |
tree | d90632ae74816fc5e35d1e5f5e33db4f9a64e8d2 /gcc/fold-const.c | |
parent | c1673e1b5a35cd6fe10a088d458ca0133a71eebd (diff) | |
download | gcc-86122f7282ff1c895004881a9febde7bf15e928c.zip gcc-86122f7282ff1c895004881a9febde7bf15e928c.tar.gz gcc-86122f7282ff1c895004881a9febde7bf15e928c.tar.bz2 |
re PR tree-optimization/31632 (ICE in compare_values)
PR tree-optimization/31632
* fold-const.c (fold_binary): Use op0 and op1 instead of arg0
and arg1 for optimizations of comparison against min/max values.
Fold arg0 to arg1's type for optimizations of comparison against
min+1 and max-1 values.
* gcc.c-torture/compile/20070419-1.c: New test.
From-SVN: r123988
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 3f03cc9..6d2db7b 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11918,13 +11918,13 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return omit_one_operand (type, integer_zero_node, arg0); case GE_EXPR: - return fold_build2 (EQ_EXPR, type, arg0, arg1); + return fold_build2 (EQ_EXPR, type, op0, op1); case LE_EXPR: return omit_one_operand (type, integer_one_node, arg0); case LT_EXPR: - return fold_build2 (NE_EXPR, type, arg0, arg1); + return fold_build2 (NE_EXPR, type, op0, op1); /* The GE_EXPR and LT_EXPR cases above are not normally reached because of previous transformations. */ @@ -11940,11 +11940,15 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case GT_EXPR: arg1 = const_binop (PLUS_EXPR, arg1, build_int_cst (TREE_TYPE (arg1), 1), 0); - return fold_build2 (EQ_EXPR, type, arg0, arg1); + return fold_build2 (EQ_EXPR, type, + fold_convert (TREE_TYPE (arg1), arg0), + arg1); case LE_EXPR: arg1 = const_binop (PLUS_EXPR, arg1, build_int_cst (TREE_TYPE (arg1), 1), 0); - return fold_build2 (NE_EXPR, type, arg0, arg1); + return fold_build2 (NE_EXPR, type, + fold_convert (TREE_TYPE (arg1), arg0), + arg1); default: break; } @@ -11957,7 +11961,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) return omit_one_operand (type, integer_zero_node, arg0); case LE_EXPR: - return fold_build2 (EQ_EXPR, type, arg0, arg1); + return fold_build2 (EQ_EXPR, type, op0, op1); case GE_EXPR: return omit_one_operand (type, integer_one_node, arg0); @@ -11975,10 +11979,14 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) { case GE_EXPR: arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - return fold_build2 (NE_EXPR, type, arg0, arg1); + return fold_build2 (NE_EXPR, type, + fold_convert (TREE_TYPE (arg1), arg0), + arg1); case LT_EXPR: arg1 = const_binop (MINUS_EXPR, arg1, integer_one_node, 0); - return fold_build2 (EQ_EXPR, type, arg0, arg1); + return fold_build2 (EQ_EXPR, type, + fold_convert (TREE_TYPE (arg1), arg0), + arg1); default: break; } @@ -11998,12 +12006,11 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) and X >= signed_max+1 because previous transformations. */ if (code == LE_EXPR || code == GT_EXPR) { - tree st0, st1; - st0 = lang_hooks.types.signed_type (TREE_TYPE (arg0)); - st1 = lang_hooks.types.signed_type (TREE_TYPE (arg1)); - return fold_build2 (code == LE_EXPR ? GE_EXPR: LT_EXPR, - type, fold_convert (st0, arg0), - build_int_cst (st1, 0)); + tree st; + st = lang_hooks.types.signed_type (TREE_TYPE (arg1)); + return fold_build2 (code == LE_EXPR ? GE_EXPR : LT_EXPR, + type, fold_convert (st, arg0), + build_int_cst (st, 0)); } } } |