This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Handling shifts in loop-iv.c


Hello,

This patch enables the recognition of induction variables which are
shift of induction variables in loop-iv.c.

Bootstrapped & regression tests on POWER4. 

Revital



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

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


Index: loop-iv.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/loop-iv.c,v
retrieving revision 2.8
diff -c -3 -p -r2.8 loop-iv.c
*** loop-iv.c   19 May 2004 17:53:45 -0000      2.8
--- loop-iv.c   9 Jun 2004 06:01:37 -0000
*************** simple_set_p (rtx lhs, rtx rhs)
*** 222,227 ****
--- 222,228 ----
      case PLUS:
      case MINUS:
      case MULT:
+     case ASHIFT:
        op0 = XEXP (rhs, 0);
        op1 = XEXP (rhs, 1);
 
*************** simple_set_p (rtx lhs, rtx rhs)
*** 238,243 ****
--- 239,248 ----
          && !CONSTANT_P (op1))
        return false;
 
+       if (GET_CODE (rhs) == ASHIFT
+             && CONSTANT_P (op0))
+            return false;
+ 
        return true;
 
      default:
*************** iv_mult (struct rtx_iv *iv, rtx mby)
*** 589,594 ****
--- 594,625 ----
    return true;
  }
 
+ /* Evaluates shift of IV.  */
+ 
+ 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.  */
*************** iv_analyze (rtx insn, rtx def, struct rt
*** 1032,1037 ****
--- 1063,1075 ----
              mby = tmp;
            }
          break;
+ 
+     case ASHIFT:
+         if (CONSTANT_P (XEXP (rhs, 0)))
+           abort ();
+         op0 = XEXP (rhs, 0);
+         mby = XEXP (rhs, 1);
+         break;
 
        default:
          abort ();
*************** iv_analyze (rtx insn, rtx def, struct rt
*** 1088,1093 ****
--- 1126,1136 ----
        goto end;
        break;
 
+     case ASHIFT: 
+       if (!iv_shift (&iv0, mby))
+           goto end;
+       break;
+ 
      default:
        break;
      }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]