aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2005-10-07 18:12:11 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2005-10-07 18:12:11 +0000
commit4c17e288380c5b3ff5350fbe83357e077b9213d5 (patch)
treebfb09f8e50fe34c54fd0b2b25446451c3bd85d21 /gcc/fold-const.c
parent002a9071e6fe429c55e02c5b678b4e47282d05ca (diff)
downloadgcc-4c17e288380c5b3ff5350fbe83357e077b9213d5.zip
gcc-4c17e288380c5b3ff5350fbe83357e077b9213d5.tar.gz
gcc-4c17e288380c5b3ff5350fbe83357e077b9213d5.tar.bz2
re PR middle-end/24227 (ICE in compare_values, at tree-vrp.c:415)
2005-10-07 Richard Guenther <rguenther@suse.de> PR middle-end/24227 * fold-const.c (fold_binary): Fix operand types during folding of X op (A, Y). Evaluation order of the side-effects of X and A are frontend-defined, so ensure we honour that even for tcc_comparison class operands; eased by removing duplicate code. * gcc.c-torture/compile/pr24227.c: New testcase. From-SVN: r105096
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 0190c32..015930e 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -7113,26 +7113,18 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
return fold_convert (type, tem);
}
- if (TREE_CODE_CLASS (code) == tcc_comparison
- && TREE_CODE (arg0) == COMPOUND_EXPR)
- return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
- fold_build2 (code, type, TREE_OPERAND (arg0, 1), arg1));
- else if (TREE_CODE_CLASS (code) == tcc_comparison
- && TREE_CODE (arg1) == COMPOUND_EXPR)
- return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0),
- fold_build2 (code, type, arg0, TREE_OPERAND (arg1, 1)));
- else if (TREE_CODE_CLASS (code) == tcc_binary
- || TREE_CODE_CLASS (code) == tcc_comparison)
+ if (TREE_CODE_CLASS (code) == tcc_binary
+ || TREE_CODE_CLASS (code) == tcc_comparison)
{
if (TREE_CODE (arg0) == COMPOUND_EXPR)
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
- fold_build2 (code, type, TREE_OPERAND (arg0, 1),
- arg1));
+ fold_build2 (code, type,
+ TREE_OPERAND (arg0, 1), op1));
if (TREE_CODE (arg1) == COMPOUND_EXPR
&& reorder_operands_p (arg0, TREE_OPERAND (arg1, 0)))
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0),
fold_build2 (code, type,
- arg0, TREE_OPERAND (arg1, 1)));
+ op0, TREE_OPERAND (arg1, 1)));
if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0))
{