From ce4191eed16e15397cc09bba95d8ef603ba05359 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sun, 9 Nov 2003 14:33:20 +0000 Subject: loop.c (check_dbra_loop): Try swapping the comparison operands of the loop condition to identify a... * 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. From-SVN: r73391 --- gcc/unroll.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'gcc/unroll.c') diff --git a/gcc/unroll.c b/gcc/unroll.c index 38659d4..cc415a7 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 (); -- cgit v1.1