Implement evolution_function_right_is_integer_cst.
authorSebastian Pop <sebastian.pop@amd.com>
Fri, 31 Jul 2009 02:39:06 +0000 (02:39 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 31 Jul 2009 02:39:06 +0000 (02:39 +0000)
2009-07-30  Sebastian Pop  <sebastian.pop@amd.com>

* tree-chrec.c (evolution_function_right_is_integer_cst): New.
* tree-chrec.h (evolution_function_right_is_integer_cst): Declared.

From-SVN: r150299

gcc/ChangeLog
gcc/tree-chrec.c
gcc/tree-chrec.h

index 2a06489a0830a04f41b387ea99734424eb8bb8e8..7bb289a058cc06d275da91bd22d2b898442fe7ec 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-30  Sebastian Pop  <sebastian.pop@amd.com>
+
+       * tree-chrec.c (evolution_function_right_is_integer_cst): New.
+       * tree-chrec.h (evolution_function_right_is_integer_cst): Declared.
+
 2009-07-30  Sebastian Pop  <sebastian.pop@amd.com>
 
        * tree-chrec.c (operator_is_linear): Handle BIT_NOT_EXPR.
index caf7428dc4ea7f78a212df81ec6886607e1d38a2..33d9f18c099971775aface9bfd3f70460e770692 100644 (file)
@@ -1487,3 +1487,33 @@ scev_is_linear_expression (tree scev)
       return false;
     }
 }
+
+/* Determines whether the expression CHREC contains only interger consts
+   in the right parts.  */
+
+bool
+evolution_function_right_is_integer_cst (const_tree chrec)
+{
+  if (chrec == NULL_TREE)
+    return false;
+
+  switch (TREE_CODE (chrec))
+    {
+    case INTEGER_CST:
+      return true;
+
+    case POLYNOMIAL_CHREC:
+      if (!evolution_function_right_is_integer_cst (CHREC_RIGHT (chrec)))
+       return false;
+
+      if (TREE_CODE (CHREC_LEFT (chrec)) == POLYNOMIAL_CHREC
+       && !evolution_function_right_is_integer_cst (CHREC_LEFT (chrec)))
+       return false;
+
+      return true;
+
+    default:
+      return false;
+    }
+}
+
index db45eedc595a8f5ed341189950af4f0b6c103e05..f21aa74d795f927c03249904114a80eb4edce693 100644 (file)
@@ -86,6 +86,7 @@ extern bool evolution_function_is_univariate_p (const_tree);
 extern unsigned nb_vars_in_chrec (tree);
 extern bool evolution_function_is_invariant_p (tree, int);
 extern bool scev_is_linear_expression (tree);
+extern bool evolution_function_right_is_integer_cst (const_tree);
 
 /* Determines whether CHREC is equal to zero.  */