From: Jakub Jelinek Date: Tue, 25 Sep 2007 15:14:42 +0000 (+0200) Subject: re PR tree-optimization/32694 (ICE with long long arithmetic) X-Git-Tag: releases/gcc-4.2.2~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e73024af31bbb956049f7a53878b1dce0cca54b;p=thirdparty%2Fgcc.git re PR tree-optimization/32694 (ICE with long long arithmetic) PR tree-optimization/32694 2006-11-08 Roger Sayle * tree-ssa-propagate.c (set_rhs): Verify tcc_comparison the same way as tcc_binary. * tree-ssa-ccp.c (fold_stmt_r) : Use set_rhs to modify the condition after calling fold_binary. * gcc.c-torture/compile/20070925-1.c: New test. From-SVN: r128766 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 42d02125d917..4e676abd105b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2007-09-25 Jakub Jelinek + + PR tree-optimization/32694 + 2006-11-08 Roger Sayle + * tree-ssa-propagate.c (set_rhs): Verify tcc_comparison the same way + as tcc_binary. + * tree-ssa-ccp.c (fold_stmt_r) : Use set_rhs to modify + the condition after calling fold_binary. + 2007-09-24 Jakub Jelinek PR debug/33316 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7bfa71fc79c2..a301ef8bdb35 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-09-25 Jakub Jelinek + + PR tree-optimization/32694 + * gcc.c-torture/compile/20070925-1.c: New test. + 2007-09-24 Jakub Jelinek PR debug/33316 diff --git a/gcc/testsuite/gcc.c-torture/compile/20070925-1.c b/gcc/testsuite/gcc.c-torture/compile/20070925-1.c new file mode 100644 index 000000000000..188193bc9309 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20070925-1.c @@ -0,0 +1,22 @@ +/* PR tree-optimization/32694 */ + +typedef signed long long int WordS64; +typedef unsigned long long int Word64; + +int +foo (Word64 * p) +{ + while (1) + { + WordS64 c = 0x1llu; + WordS64 x = *p; + if (c >= 0) + { + if (x > (WordS64) 0x7FFFFFFFFFFFFFFFll - c) + return 6; + } + else if (x < (WordS64) 0x8000000000000000ll - c) + return 7; + p++; + } +} diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c index f16652d61ef6..f485b02e4cf2 100644 --- a/gcc/tree-ssa-ccp.c +++ b/gcc/tree-ssa-ccp.c @@ -2062,12 +2062,13 @@ fold_stmt_r (tree *expr_p, int *walk_subtrees, void *data) tem = fold_binary (TREE_CODE (op0), TREE_TYPE (op0), TREE_OPERAND (op0, 0), TREE_OPERAND (op0, 1)); - set = tem && is_gimple_condexpr (tem); + set = tem && set_rhs (expr_p, tem); fold_undefer_overflow_warnings (set, fold_stmt_r_data->stmt, 0); if (set) - TREE_OPERAND (expr, 0) = tem; - t = expr; - break; + { + t = *expr_p; + break; + } } default: diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index 56d6ecad97a3..c01a2cf65835 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -570,7 +570,8 @@ set_rhs (tree *stmt_p, tree expr) ssa_op_iter iter; /* Verify the constant folded result is valid gimple. */ - if (TREE_CODE_CLASS (code) == tcc_binary) + if (TREE_CODE_CLASS (code) == tcc_binary + || TREE_CODE_CLASS (code) == tcc_comparison) { if (!is_gimple_val (TREE_OPERAND (expr, 0)) || !is_gimple_val (TREE_OPERAND (expr, 1)))