Commit abe0d774 by Revital Eres Committed by Roger Sayle

loop-iv.c (iv_analyze, [...]): Support for identifying shifts of induction variable.

2004-06-24  Revital Eres  <eres@il.ibm.com>

	* loop-iv.c (iv_analyze, simple_set_p): Support for identifying
	shifts of induction variable.
	(iv_shift): New function.

From-SVN: r83599
parent be1ba3d1
2004-06-24 Revital Eres <eres@il.ibm.com>
* loop-iv.c (iv_analyze, simple_set_p): Support for identifying
shifts of induction variable.
(iv_shift): New function.
2004-06-24 Richard Henderson <rth@redhat.com> 2004-06-24 Richard Henderson <rth@redhat.com>
* gimplify.c (gimplify_body): Watch for body vanishing. * gimplify.c (gimplify_body): Watch for body vanishing.
......
...@@ -222,6 +222,7 @@ simple_set_p (rtx lhs, rtx rhs) ...@@ -222,6 +222,7 @@ simple_set_p (rtx lhs, rtx rhs)
case PLUS: case PLUS:
case MINUS: case MINUS:
case MULT: case MULT:
case ASHIFT:
op0 = XEXP (rhs, 0); op0 = XEXP (rhs, 0);
op1 = XEXP (rhs, 1); op1 = XEXP (rhs, 1);
...@@ -238,6 +239,10 @@ simple_set_p (rtx lhs, rtx rhs) ...@@ -238,6 +239,10 @@ simple_set_p (rtx lhs, rtx rhs)
&& !CONSTANT_P (op1)) && !CONSTANT_P (op1))
return false; return false;
if (GET_CODE (rhs) == ASHIFT
&& CONSTANT_P (op0))
return false;
return true; return true;
default: default:
...@@ -589,6 +594,31 @@ iv_mult (struct rtx_iv *iv, rtx mby) ...@@ -589,6 +594,31 @@ iv_mult (struct rtx_iv *iv, rtx mby)
return true; return true;
} }
/* Evaluates shift of IV by constant CST. */
static bool
iv_shift (struct rtx_iv *iv, rtx mby)
{
enum machine_mode mode = iv->extend_mode;
if (GET_MODE (mby) != VOIDmode
&& GET_MODE (mby) != mode)
return false;
if (iv->extend == NIL)
{
iv->base = simplify_gen_binary (ASHIFT, mode, iv->base, mby);
iv->step = simplify_gen_binary (ASHIFT, mode, iv->step, mby);
}
else
{
iv->delta = simplify_gen_binary (ASHIFT, mode, iv->delta, mby);
iv->mult = simplify_gen_binary (ASHIFT, mode, iv->mult, mby);
}
return true;
}
/* The recursive part of get_biv_step. Gets the value of the single value /* The recursive part of get_biv_step. Gets the value of the single value
defined in INSN wrto initial value of REG inside loop, in shape described defined in INSN wrto initial value of REG inside loop, in shape described
at get_biv_step. */ at get_biv_step. */
...@@ -1032,7 +1062,14 @@ iv_analyze (rtx insn, rtx def, struct rtx_iv *iv) ...@@ -1032,7 +1062,14 @@ iv_analyze (rtx insn, rtx def, struct rtx_iv *iv)
mby = tmp; mby = tmp;
} }
break; break;
case ASHIFT:
if (CONSTANT_P (XEXP (rhs, 0)))
abort ();
op0 = XEXP (rhs, 0);
mby = XEXP (rhs, 1);
break;
default: default:
abort (); abort ();
} }
...@@ -1088,6 +1125,11 @@ iv_analyze (rtx insn, rtx def, struct rtx_iv *iv) ...@@ -1088,6 +1125,11 @@ iv_analyze (rtx insn, rtx def, struct rtx_iv *iv)
goto end; goto end;
break; break;
case ASHIFT:
if (!iv_shift (&iv0, mby))
goto end;
break;
default: default:
break; break;
} }
......
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