summaryrefslogtreecommitdiff
path: root/gcc/unroll.c
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-09 14:33:20 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-11-09 14:33:20 +0000
commite0156fe8b342395dbb5b46922f1835d6eb4ccdc3 (patch)
treec993edb42c75d10e8adc5feee8d68fa2f583bc7e /gcc/unroll.c
parent438f54ba84e38eec8d4de1c8c36e8ae03c1c9f2a (diff)
downloadgcc-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.c15
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 ();