diff options
author | Daniel Berlin <dberlin@dberlin.org> | 2005-03-16 16:20:12 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@gcc.gnu.org> | 2005-03-16 16:20:12 +0000 |
commit | 705966423ac47536ac254d5752d40914e70ad793 (patch) | |
tree | 603a984e5a480221db03c600f853bdf7fde01ef4 /gcc | |
parent | ef6e9bc04fcb3bb4515ca67591177c6c8c04d236 (diff) | |
download | gcc-705966423ac47536ac254d5752d40914e70ad793.zip gcc-705966423ac47536ac254d5752d40914e70ad793.tar.gz gcc-705966423ac47536ac254d5752d40914e70ad793.tar.bz2 |
re PR tree-optimization/20490 (ICE: verify_stmts failed. (with -O -ftree-pre))
2005-03-16 Daniel Berlin <dberlin@dberlin.org>
Fix PR tree-optimization/20940
* tree-ssa-pre.c (create_expression_by_pieces): Use
force_gimple_operand on result of fold.
From-SVN: r96560
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr20940.c | 20 | ||||
-rw-r--r-- | gcc/tree-ssa-pre.c | 25 |
3 files changed, 48 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2afc12f..e1fffe1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2005-03-16 Daniel Berlin <dberlin@dberlin.org> + + Fix PR tree-optimization/20940 + + * tree-ssa-pre.c (create_expression_by_pieces): Use + force_gimple_operand on result of fold. + 2005-03-16 Andrew Pinski <pinskia@physics.uc.edu> * config/i386/emmintrin.h (_mm_extract_epi16): Correct the number diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr20940.c b/gcc/testsuite/gcc.dg/tree-ssa/pr20940.c new file mode 100644 index 0000000..8edc35e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr20940.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-pre" } */ +static int a; +static int b; + +typedef int gint; + +int blah () +{ + gint x = a; + gint y = b; + + x *= (x < 0) ? -1 : 0; + y *= (y < 0) ? -1 : 0; + + return (y * x); + +} + + diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index e179f0c..161d7e5 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1317,16 +1317,25 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts) case tcc_binary: { tree_stmt_iterator tsi; + tree forced_stmts; tree genop1, genop2; tree temp; + tree folded; tree op1 = TREE_OPERAND (expr, 0); tree op2 = TREE_OPERAND (expr, 1); genop1 = find_or_generate_expression (block, op1, stmts); genop2 = find_or_generate_expression (block, op2, stmts); temp = create_tmp_var (TREE_TYPE (expr), "pretmp"); add_referenced_tmp_var (temp); - newexpr = fold (build (TREE_CODE (expr), TREE_TYPE (expr), - genop1, genop2)); + + folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), + genop1, genop2)); + newexpr = force_gimple_operand (folded, &forced_stmts, false, NULL); + if (forced_stmts) + { + tsi = tsi_last (stmts); + tsi_link_after (&tsi, forced_stmts, TSI_CONTINUE_LINKING); + } newexpr = build (MODIFY_EXPR, TREE_TYPE (expr), temp, newexpr); NECESSARY (newexpr) = 0; @@ -1341,14 +1350,22 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts) case tcc_unary: { tree_stmt_iterator tsi; + tree forced_stmts; tree genop1; tree temp; + tree folded; tree op1 = TREE_OPERAND (expr, 0); genop1 = find_or_generate_expression (block, op1, stmts); temp = create_tmp_var (TREE_TYPE (expr), "pretmp"); add_referenced_tmp_var (temp); - newexpr = fold (build (TREE_CODE (expr), TREE_TYPE (expr), - genop1)); + folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), + genop1)); + newexpr = force_gimple_operand (folded, &forced_stmts, false, NULL); + if (forced_stmts) + { + tsi = tsi_last (stmts); + tsi_link_after (&tsi, forced_stmts, TSI_CONTINUE_LINKING); + } newexpr = build (MODIFY_EXPR, TREE_TYPE (expr), temp, newexpr); name = make_ssa_name (temp, newexpr); |