aboutsummaryrefslogtreecommitdiff
path: root/gcc/unroll.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2003-11-09 14:33:20 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2003-11-09 14:33:20 +0000
commitce4191eed16e15397cc09bba95d8ef603ba05359 (patch)
treec993edb42c75d10e8adc5feee8d68fa2f583bc7e /gcc/unroll.c
parent8b93ca2dd22f8e6d2c3a5ab70d5d79c6ee6b665a (diff)
downloadgcc-ce4191eed16e15397cc09bba95d8ef603ba05359.zip
gcc-ce4191eed16e15397cc09bba95d8ef603ba05359.tar.gz
gcc-ce4191eed16e15397cc09bba95d8ef603ba05359.tar.bz2
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
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 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 ();