diff options
author | Bin Cheng <bin.cheng@arm.com> | 2013-09-02 09:58:41 +0000 |
---|---|---|
committer | Bin Cheng <amker@gcc.gnu.org> | 2013-09-02 09:58:41 +0000 |
commit | 85ff4ec64932ebee408be67a815011337e31e66b (patch) | |
tree | 9f83f99cc963362955b47f3ec80e0ed004f16b2f /gcc/tree-ssa-loop-ivopts.c | |
parent | fde6f97e082794374ec8000e7625f9d1c20dbcb2 (diff) | |
download | gcc-85ff4ec64932ebee408be67a815011337e31e66b.zip gcc-85ff4ec64932ebee408be67a815011337e31e66b.tar.gz gcc-85ff4ec64932ebee408be67a815011337e31e66b.tar.bz2 |
tree-ssa-loop-ivopts.c (set_autoinc_for_original_candidates): Find auto-increment use both before and after candidate.
* tree-ssa-loop-ivopts.c (set_autoinc_for_original_candidates):
Find auto-increment use both before and after candidate.
* gcc.target/arm/ivopts-orig_biv-inc.c: New testcase.
From-SVN: r202164
Diffstat (limited to 'gcc/tree-ssa-loop-ivopts.c')
-rw-r--r-- | gcc/tree-ssa-loop-ivopts.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 7cfe80d..c45f316 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4876,22 +4876,36 @@ set_autoinc_for_original_candidates (struct ivopts_data *data) for (i = 0; i < n_iv_cands (data); i++) { struct iv_cand *cand = iv_cand (data, i); - struct iv_use *closest = NULL; + struct iv_use *closest_before = NULL; + struct iv_use *closest_after = NULL; if (cand->pos != IP_ORIGINAL) continue; + for (j = 0; j < n_iv_uses (data); j++) { struct iv_use *use = iv_use (data, j); unsigned uid = gimple_uid (use->stmt); - if (gimple_bb (use->stmt) != gimple_bb (cand->incremented_at) - || uid > gimple_uid (cand->incremented_at)) + + if (gimple_bb (use->stmt) != gimple_bb (cand->incremented_at)) continue; - if (closest == NULL || uid > gimple_uid (closest->stmt)) - closest = use; + + if (uid < gimple_uid (cand->incremented_at) + && (closest_before == NULL + || uid > gimple_uid (closest_before->stmt))) + closest_before = use; + + if (uid > gimple_uid (cand->incremented_at) + && (closest_after == NULL + || uid < gimple_uid (closest_after->stmt))) + closest_after = use; } - if (closest == NULL || !autoinc_possible_for_pair (data, closest, cand)) - continue; - cand->ainc_use = closest; + + if (closest_before != NULL + && autoinc_possible_for_pair (data, closest_before, cand)) + cand->ainc_use = closest_before; + else if (closest_after != NULL + && autoinc_possible_for_pair (data, closest_after, cand)) + cand->ainc_use = closest_after; } } |