tree-ssa-loop-ivopts.c (find_bivs, [...]): Apply expand_simple_operations to bases...
authorZdenek Dvorak <dvorakz@suse.cz>
Tue, 17 May 2005 20:02:56 +0000 (22:02 +0200)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Tue, 17 May 2005 20:02:56 +0000 (20:02 +0000)
* tree-ssa-loop-ivopts.c (find_bivs, find_givs_in_stmt_scev): Apply
expand_simple_operations to bases of the ivs.
(tree_int_cst_sign_bit): Export.
* tree-flow.h (expand_simple_operations): Declare.
* tree-ssa-loop-niter.c (number_of_iterations_cond): Use
tree_int_cst_sign_bit.
(expand_simple_operations): Export.
* tree.h (tree_int_cst_sign_bit): Declare.

From-SVN: r99853

gcc/ChangeLog
gcc/tree-flow.h
gcc/tree-ssa-loop-ivopts.c
gcc/tree-ssa-loop-niter.c
gcc/tree.h

index 141be32fece47d5538b4800ab8fa63ffcd84f47c..45a3de5b575fb7c7f908e1b9a28daa8124dcde20 100644 (file)
@@ -1,3 +1,14 @@
+2005-05-17  Zdenek Dvorak  <dvorakz@suse.cz>
+
+       * tree-ssa-loop-ivopts.c (find_bivs, find_givs_in_stmt_scev): Apply
+       expand_simple_operations to bases of the ivs.
+       (tree_int_cst_sign_bit): Export.
+       * tree-flow.h (expand_simple_operations): Declare.
+       * tree-ssa-loop-niter.c (number_of_iterations_cond): Use
+       tree_int_cst_sign_bit.
+       (expand_simple_operations): Export.
+       * tree.h (tree_int_cst_sign_bit): Declare.
+
 2005-05-17  Zdenek Dvorak  <dvorakz@suse.cz>
 
        * tree-cfg.c (tree_can_merge_blocks_p): Allow phi nodes in the
index 90bef3763f97d38d0cc8b3ee03f27d56b83886f3..273a26ce49c814ba9cb82467f694f416a12341a0 100644 (file)
@@ -725,6 +725,7 @@ bool tree_duplicate_loop_to_header_edge (struct loop *, edge, struct loops *,
                                         unsigned int *, int);
 struct loop *tree_ssa_loop_version (struct loops *, struct loop *, tree,
                                    basic_block *);
+tree expand_simple_operations (tree);
 
 /* In tree-ssa-loop-im.c  */
 /* The possibilities of statement movement.  */
index 00e7849e7f86bab3e835d6978c2fd06e930431a4..af121c4489d4c3b063a60391d93aff91500c7326 100644 (file)
@@ -992,6 +992,7 @@ find_bivs (struct ivopts_data *data)
        continue;
 
       base = PHI_ARG_DEF_FROM_EDGE (phi, loop_preheader_edge (loop));
+      base = expand_simple_operations (base);
       if (contains_abnormal_ssa_name_p (base)
          || contains_abnormal_ssa_name_p (step))
        continue;
@@ -1062,6 +1063,7 @@ find_givs_in_stmt_scev (struct ivopts_data *data, tree stmt,
 
   if (!simple_iv (loop, stmt, TREE_OPERAND (stmt, 1), base, step, true))
     return false;
+  *base = expand_simple_operations (*base);
 
   if (contains_abnormal_ssa_name_p (*base)
       || contains_abnormal_ssa_name_p (*step))
@@ -2536,7 +2538,7 @@ var_at_stmt (struct loop *loop, struct iv_cand *cand, tree stmt)
 /* Return the most significant (sign) bit of T.  Similar to tree_int_cst_msb,
    but the bit is determined from TYPE_PRECISION, not MODE_BITSIZE.  */
 
-static int
+int
 tree_int_cst_sign_bit (tree t)
 {
   unsigned bitno = TYPE_PRECISION (TREE_TYPE (t)) - 1;
index b3bde288a4857d7b81c771acec3020f81b479d6a..38f7b42d46c7dacc589e5714575d89c4a9e10f97 100644 (file)
@@ -189,10 +189,10 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
   /* Ignore loops of while (i-- < 10) type.  */
   if (code != NE_EXPR)
     {
-      if (step0 && !tree_expr_nonnegative_p (step0))
+      if (step0 && tree_int_cst_sign_bit (step0))
        return;
 
-      if (!zero_p (step1) && tree_expr_nonnegative_p (step1))
+      if (!zero_p (step1) && !tree_int_cst_sign_bit (step1))
        return;
     }
 
@@ -366,7 +366,7 @@ number_of_iterations_cond (tree type, tree base0, tree step0,
       if (!zero_p (step1))
        step0 = fold_unary_to_constant (NEGATE_EXPR, type, step1);
       step1 = NULL_TREE;
-      if (!tree_expr_nonnegative_p (fold_convert (signed_niter_type, step0)))
+      if (tree_int_cst_sign_bit (fold_convert (signed_niter_type, step0)))
        {
          step0 = fold_unary_to_constant (NEGATE_EXPR, type, step0);
          base1 = fold_build1 (NEGATE_EXPR, type, base1);
@@ -627,7 +627,7 @@ simplify_replace_tree (tree expr, tree old, tree new)
 /* Expand definitions of ssa names in EXPR as long as they are simple
    enough, and return the new expression.  */
 
-static tree
+tree
 expand_simple_operations (tree expr)
 {
   unsigned i, n;
index 60b7943cf35802cc0f7c37621a29314c6ec796ba..8dc989435bb2412d1c8b053fd848768d7170d0a4 100644 (file)
@@ -2953,6 +2953,7 @@ extern int host_integerp (tree, int);
 extern HOST_WIDE_INT tree_low_cst (tree, int);
 extern int tree_int_cst_msb (tree);
 extern int tree_int_cst_sgn (tree);
+extern int tree_int_cst_sign_bit (tree);
 extern int tree_expr_nonnegative_p (tree);
 extern bool may_negate_without_overflow_p (tree);
 extern tree get_inner_array_type (tree);