aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2005-02-06 19:48:58 +0100
committerZdenek Dvorak <rakdver@gcc.gnu.org>2005-02-06 18:48:58 +0000
commit3520b7452c46c56f64697dcdad55160cdf947d39 (patch)
tree10830e1a2a76f15e0178f61c26c6ab42113944c8 /gcc
parentb0a168b645d310b6bf2638967562cfab8f89d555 (diff)
downloadgcc-3520b7452c46c56f64697dcdad55160cdf947d39.zip
gcc-3520b7452c46c56f64697dcdad55160cdf947d39.tar.gz
gcc-3520b7452c46c56f64697dcdad55160cdf947d39.tar.bz2
tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Do not add unnecessary cast to original induction variable increments.
* tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Do not add unnecessary cast to original induction variable increments. From-SVN: r94681
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/tree-ssa-loop-ivopts.c27
2 files changed, 29 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 83c0ed5..a498661 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,10 @@
2005-02-06 Zdenek Dvorak <dvorakz@suse.cz>
+ * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Do not add
+ unnecessary cast to original induction variable increments.
+
+2005-02-06 Zdenek Dvorak <dvorakz@suse.cz>
+
PR tree-optimization/18219
* tree-ssa-loop-ivopts.c (get_computation_at): Produce computations
in distributed form.
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 05f4a8d..b5f693e 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -4542,11 +4542,32 @@ static void
rewrite_use_nonlinear_expr (struct ivopts_data *data,
struct iv_use *use, struct iv_cand *cand)
{
- tree comp = unshare_expr (get_computation (data->current_loop,
- use, cand));
+ tree comp;
tree op, stmts, tgt, ass;
block_stmt_iterator bsi, pbsi;
-
+
+ /* An important special case -- if we are asked to express value of
+ the original iv by itself, just exit; there is no need to
+ introduce a new computation (that might also need casting the
+ variable to unsigned and back). */
+ if (cand->pos == IP_ORIGINAL
+ && TREE_CODE (use->stmt) == MODIFY_EXPR
+ && TREE_OPERAND (use->stmt, 0) == cand->var_after)
+ {
+ op = TREE_OPERAND (use->stmt, 1);
+
+ /* Be a bit careful. In case variable is expressed in some
+ complicated way, rewrite it so that we may get rid of this
+ complicated expression. */
+ if ((TREE_CODE (op) == PLUS_EXPR
+ || TREE_CODE (op) == MINUS_EXPR)
+ && TREE_OPERAND (op, 0) == cand->var_before
+ && TREE_CODE (TREE_OPERAND (op, 1)) == INTEGER_CST)
+ return;
+ }
+
+ comp = unshare_expr (get_computation (data->current_loop,
+ use, cand));
switch (TREE_CODE (use->stmt))
{
case PHI_NODE: