OSDN Git Service

2004-06-24 Revital Eres <eres@il.ibm.com>
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Jun 2004 16:50:35 +0000 (16:50 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 24 Jun 2004 16:50:35 +0000 (16:50 +0000)
* loop-iv.c (iv_analyze, simple_set_p): Support for identifying
shifts of induction variable.
(iv_shift): New function.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83599 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/loop-iv.c

index da403d9..f51653b 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        * gimplify.c (gimplify_body): Watch for body vanishing.
index 0093743..e739a85 100644 (file)
@@ -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;
     }