diff options
author | Bin Cheng <amker@gcc.gnu.org> | 2015-02-13 05:44:46 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2015-02-13 05:44:46 +0000 |
commit | fc06280eb11be2316b12a51112cb62614141f32d (patch) | |
tree | 1306ae46686893d216153301b433362f1e20624d /gcc/tree-ssa-loop-niter.c | |
parent | 785f21af82139f512eb12f3318899c9f967409e6 (diff) | |
download | gcc-fc06280eb11be2316b12a51112cb62614141f32d.zip gcc-fc06280eb11be2316b12a51112cb62614141f32d.tar.gz gcc-fc06280eb11be2316b12a51112cb62614141f32d.tar.bz2 |
re PR tree-optimization/64705 (Bad code generation of sieve on x86-64 because of too aggressive IV optimizations)
PR tree-optimization/64705
* tree-ssa-loop-niter.h (expand_simple_operations): New parameter.
* tree-ssa-loop-niter.c (expand_simple_operations): New parameter.
* tree-ssa-loop-ivopts.c (extract_single_var_from_expr): New.
(find_bivs, find_givs_in_stmt_scev): Pass new argument to
expand_simple_operations.
testsuite
PR tree-optimization/64705
* gcc.dg/tree-ssa/pr64705.c: New test.
From-SVN: r220676
Diffstat (limited to 'gcc/tree-ssa-loop-niter.c')
-rw-r--r-- | gcc/tree-ssa-loop-niter.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index a677958..7f6c451 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -1563,10 +1563,11 @@ simplify_replace_tree (tree expr, tree old, tree new_tree) } /* Expand definitions of ssa names in EXPR as long as they are simple - enough, and return the new expression. */ + enough, and return the new expression. If STOP is specified, stop + expanding if EXPR equals to it. */ tree -expand_simple_operations (tree expr) +expand_simple_operations (tree expr, tree stop) { unsigned i, n; tree ret = NULL_TREE, e, ee, e1; @@ -1586,7 +1587,7 @@ expand_simple_operations (tree expr) for (i = 0; i < n; i++) { e = TREE_OPERAND (expr, i); - ee = expand_simple_operations (e); + ee = expand_simple_operations (e, stop); if (e == ee) continue; @@ -1605,7 +1606,8 @@ expand_simple_operations (tree expr) return ret; } - if (TREE_CODE (expr) != SSA_NAME) + /* Stop if it's not ssa name or the one we don't want to expand. */ + if (TREE_CODE (expr) != SSA_NAME || expr == stop) return expr; stmt = SSA_NAME_DEF_STMT (expr); @@ -1625,7 +1627,7 @@ expand_simple_operations (tree expr) && src->loop_father != dest->loop_father) return expr; - return expand_simple_operations (e); + return expand_simple_operations (e, stop); } if (gimple_code (stmt) != GIMPLE_ASSIGN) return expr; @@ -1645,7 +1647,7 @@ expand_simple_operations (tree expr) return e; if (code == SSA_NAME) - return expand_simple_operations (e); + return expand_simple_operations (e, stop); return expr; } @@ -1654,7 +1656,7 @@ expand_simple_operations (tree expr) { CASE_CONVERT: /* Casts are simple. */ - ee = expand_simple_operations (e); + ee = expand_simple_operations (e, stop); return fold_build1 (code, TREE_TYPE (expr), ee); case PLUS_EXPR: @@ -1669,7 +1671,7 @@ expand_simple_operations (tree expr) if (!is_gimple_min_invariant (e1)) return expr; - ee = expand_simple_operations (e); + ee = expand_simple_operations (e, stop); return fold_build2 (code, TREE_TYPE (expr), ee, e1); default: |