diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-11-09 14:33:20 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-11-09 14:33:20 +0000 |
commit | e0156fe8b342395dbb5b46922f1835d6eb4ccdc3 (patch) | |
tree | c993edb42c75d10e8adc5feee8d68fa2f583bc7e /gcc/unroll.c | |
parent | 438f54ba84e38eec8d4de1c8c36e8ae03c1c9f2a (diff) | |
download | gcc-e0156fe8b342395dbb5b46922f1835d6eb4ccdc3.tar.gz |
* loop.c (check_dbra_loop): Try swapping the comparison operands
of the loop condition to identify a suitable induction variable.
* unroll.c (loop_iterations): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@73391 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/unroll.c')
-rw-r--r-- | gcc/unroll.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/unroll.c b/gcc/unroll.c index 38659d461cb..cc415a795b6 100644 --- a/gcc/unroll.c +++ b/gcc/unroll.c @@ -3421,7 +3421,20 @@ loop_iterations (struct loop *loop) "Loop iterations: Iteration var not an integer.\n"); return 0; } - else if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == BASIC_INDUCT) + + /* Try swapping the comparison to identify a suitable iv. */ + if (REG_IV_TYPE (ivs, REGNO (iteration_var)) != BASIC_INDUCT + && REG_IV_TYPE (ivs, REGNO (iteration_var)) != GENERAL_INDUCT + && GET_CODE (comparison_value) == REG + && REGNO (comparison_value) < ivs->n_regs) + { + rtx temp = comparison_value; + comparison_code = swap_condition (comparison_code); + comparison_value = iteration_var; + iteration_var = temp; + } + + if (REG_IV_TYPE (ivs, REGNO (iteration_var)) == BASIC_INDUCT) { if (REGNO (iteration_var) >= ivs->n_regs) abort (); |