From: Revital Eres Date: Thu, 24 Jun 2004 16:50:35 +0000 (+0000) Subject: loop-iv.c (iv_analyze, [...]): Support for identifying shifts of induction variable. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=abe0d774cf58aa24fd3d9f73c2ac913e7dc65e03;p=gcc.git loop-iv.c (iv_analyze, [...]): Support for identifying shifts of induction variable. 2004-06-24 Revital Eres * loop-iv.c (iv_analyze, simple_set_p): Support for identifying shifts of induction variable. (iv_shift): New function. From-SVN: r83599 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index da403d9ba00..f51653b2a79 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-24 Revital Eres + + * loop-iv.c (iv_analyze, simple_set_p): Support for identifying + shifts of induction variable. + (iv_shift): New function. + 2004-06-24 Richard Henderson * gimplify.c (gimplify_body): Watch for body vanishing. diff --git a/gcc/loop-iv.c b/gcc/loop-iv.c index 0093743c105..e739a852bce 100644 --- a/gcc/loop-iv.c +++ b/gcc/loop-iv.c @@ -222,6 +222,7 @@ simple_set_p (rtx lhs, rtx rhs) case PLUS: case MINUS: case MULT: + case ASHIFT: op0 = XEXP (rhs, 0); op1 = XEXP (rhs, 1); @@ -238,6 +239,10 @@ simple_set_p (rtx lhs, rtx rhs) && !CONSTANT_P (op1)) return false; + if (GET_CODE (rhs) == ASHIFT + && CONSTANT_P (op0)) + return false; + return true; default: @@ -589,6 +594,31 @@ iv_mult (struct rtx_iv *iv, rtx mby) 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 defined in INSN wrto initial value of REG inside loop, in shape described at get_biv_step. */ @@ -1032,7 +1062,14 @@ iv_analyze (rtx insn, rtx def, struct rtx_iv *iv) mby = tmp; } break; - + + case ASHIFT: + if (CONSTANT_P (XEXP (rhs, 0))) + abort (); + op0 = XEXP (rhs, 0); + mby = XEXP (rhs, 1); + break; + default: abort (); } @@ -1088,6 +1125,11 @@ iv_analyze (rtx insn, rtx def, struct rtx_iv *iv) goto end; break; + case ASHIFT: + if (!iv_shift (&iv0, mby)) + goto end; + break; + default: break; }