This is the mail archive of the gcc-bugs@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]

[Bug rtl-optimization/50037] Unroll factor exceeds max trip count


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50037

--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-11 12:12:56 UTC ---
The following patch makes us handle the canonical testcase on the tree level,
but not yet the original testcase (because of the * 2).

We should really preserve value-range information from VRP.

Index: gcc/tree-ssa-loop-niter.c
===================================================================
--- gcc/tree-ssa-loop-niter.c   (revision 177649)
+++ gcc/tree-ssa-loop-niter.c   (working copy)
@@ -126,6 +126,32 @@ determine_value_range (tree type, tree v
       return;
     }

+  /* Check if we can determine a value-range from VARs definition.
+     ???  We should simply preserve VRP information.  */
+  if (TREE_CODE (var) == SSA_NAME)
+    {
+      gimple def_stmt = SSA_NAME_DEF_STMT (var);
+      if (is_gimple_assign (def_stmt)
+         && gimple_assign_rhs_code (def_stmt) == BIT_AND_EXPR)
+       {
+         tree rhs2 = gimple_assign_rhs2 (def_stmt);
+         if (TREE_CODE (rhs2) == INTEGER_CST
+             && tree_int_cst_sgn (rhs2) > 0)
+           {
+             double_int maxdi;
+             if (TREE_INT_CST_HIGH (rhs2) == 0)
+               maxdi = double_int_mask (HOST_BITS_PER_WIDE_INT
+                                        - clz_hwi (TREE_INT_CST_LOW (rhs2)));
+             else
+               maxdi = double_int_mask (HOST_BITS_PER_DOUBLE_INT
+                                        - clz_hwi (TREE_INT_CST_LOW (rhs2)));
+             mpz_set_si (min, 0);
+             mpz_set_double_int (max, maxdi, true);
+             return;
+           }
+       }
+    }
+
   /* If the computation may wrap, we know nothing about the value, except for
      the range of the type.  */
   get_type_static_bounds (type, min, max);


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