diff options
author | Bin Cheng <amker@gcc.gnu.org> | 2017-04-10 16:51:44 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2017-04-10 16:51:44 +0000 |
commit | aac69a62a1b459379367979406430cf282e347af (patch) | |
tree | ce538165c098e3055e063f69c9876a34ae4441db /gcc/tree-ssa-loop-ivopts.c | |
parent | 78a9876f98df16eaf58aec37b207fa8cbd2c946a (diff) | |
download | gcc-aac69a62a1b459379367979406430cf282e347af.zip gcc-aac69a62a1b459379367979406430cf282e347af.tar.gz gcc-aac69a62a1b459379367979406430cf282e347af.tar.bz2 |
re PR tree-optimization/80153 (ivopt generate wrong code)
PR tree-optimization/80153
* tree-affine.c (aff_combination_to_tree): Get base pointer from
the first element of pointer type aff_tree. Build result expr in
aff_tree's type.
(add_elt_to_tree): Convert to type unconditionally. Remove other
fold_convert calls.
* tree-ssa-loop-ivopts.c (alloc_iv): Pass in consistent types.
(rewrite_use_nonlinear_expr): Check invariant using iv information.
gcc/testsuite
PR tree-optimization/80153
* gcc.c-torture/execute/pr80153.c: New.
From-SVN: r246810
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index d5bd036..036e041 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -1171,7 +1171,7 @@ alloc_iv (struct ivopts_data *data, tree base, tree step, || contain_complex_addr_expr (expr)) { aff_tree comb; - tree_to_aff_combination (expr, TREE_TYPE (base), &comb); + tree_to_aff_combination (expr, TREE_TYPE (expr), &comb); base = fold_convert (TREE_TYPE (base), aff_combination_to_tree (&comb)); } @@ -7183,7 +7183,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, struct iv_use *use, struct iv_cand *cand) { tree comp; - tree op, tgt; + tree tgt; gassign *ass; gimple_stmt_iterator bsi; @@ -7194,6 +7194,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, if (cand->pos == IP_ORIGINAL && cand->incremented_at == use->stmt) { + tree op = NULL_TREE; enum tree_code stmt_code; gcc_assert (is_gimple_assign (use->stmt)); @@ -7213,14 +7214,19 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data, op = gimple_assign_rhs2 (use->stmt); else if (gimple_assign_rhs2 (use->stmt) == cand->var_before) op = gimple_assign_rhs1 (use->stmt); - else - op = NULL_TREE; } - else - op = NULL_TREE; - if (op && expr_invariant_in_loop_p (data->current_loop, op)) - return; + if (op != NULL_TREE) + { + if (expr_invariant_in_loop_p (data->current_loop, op)) + return; + if (TREE_CODE (op) == SSA_NAME) + { + struct iv *iv = get_iv (data, op); + if (iv != NULL && integer_zerop (iv->step)) + return; + } + } } comp = get_computation (data->current_loop, use, cand); |