Commit ce4191ee by Roger Sayle Committed by Roger Sayle

loop.c (check_dbra_loop): Try swapping the comparison operands of the loop…

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
parent 8b93ca2d
2003-11-09 Roger Sayle <roger@eyesopen.com>
* 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.
2003-11-09 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* config/sparc/sparc.h (TARGET_CPU_CPP_BUILTINS): Fix sparc vs
......
......@@ -8017,6 +8017,22 @@ check_dbra_loop (struct loop *loop, int insn_count)
break;
}
/* Try swapping the comparison to identify a suitable biv. */
if (!bl)
for (bl = ivs->list; bl; bl = bl->next)
if (bl->biv_count == 1
&& ! bl->biv->maybe_multiple
&& bl->biv->dest_reg == XEXP (comparison, 1)
&& ! reg_used_between_p (regno_reg_rtx[bl->regno], bl->biv->insn,
first_compare))
{
comparison = gen_rtx_fmt_ee (swap_condition (GET_CODE (comparison)),
VOIDmode,
XEXP (comparison, 1),
XEXP (comparison, 0));
break;
}
if (! bl)
return 0;
......
......@@ -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 ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment