tree-scalar-evolution.c (instantiate_parameters_1, [...]): Compute the size of an...
authorSebastian Pop <pop@cri.ensmp.fr>
Fri, 4 Nov 2005 19:10:04 +0000 (20:10 +0100)
committerSebastian Pop <spop@gcc.gnu.org>
Fri, 4 Nov 2005 19:10:04 +0000 (19:10 +0000)
PR/18595
* tree-scalar-evolution.c (instantiate_parameters_1,
instantiate_parameters, resolve_mixers): Compute the size of an
expression to be instantiated and give up the instantiation if the
size exceeds PARAM_SCEV_MAX_EXPR_SIZE.

From-SVN: r106501

gcc/ChangeLog
gcc/tree-scalar-evolution.c

index 5c49c95c073f87c440f14c8ef110a80a9a4981a7..efcd296333c653275ae6455f25b6d35f8d70cd1f 100644 (file)
@@ -1,3 +1,11 @@
+2005-11-04  Sebastian Pop  <pop@cri.ensmp.fr>
+
+       PR/18595
+       * tree-scalar-evolution.c (instantiate_parameters_1,
+       instantiate_parameters, resolve_mixers): Compute the size of an
+       expression to be instantiated and give up the instantiation if the
+       size exceeds PARAM_SCEV_MAX_EXPR_SIZE.
+
 2005-11-04  Richard Guenther  <rguenther@suse.de>
 
        * tree-flow.h (ref_contains_indirect_ref): Rename to
index b13cac134c0f3e8421d51a9c793b54d406d6f667..104445af1ecf57f6fd5423623129423eac0dca9a 100644 (file)
@@ -1982,7 +1982,8 @@ loop_closed_phi_def (tree var)
 /* Analyze all the parameters of the chrec that were left under a symbolic form,
    with respect to LOOP.  CHREC is the chrec to instantiate.  CACHE is the cache
    of already instantiated values.  FLAGS modify the way chrecs are
-   instantiated.  */
+   instantiated.  SIZE_EXPR is used for computing the size of the expression to
+   be instantiated, and to stop if it exceeds some limit.  */
 
 /* Values for FLAGS.  */
 enum
@@ -1995,12 +1996,17 @@ enum
 };
   
 static tree
-instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache)
+instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache,
+                         int size_expr)
 {
   tree res, op0, op1, op2;
   basic_block def_bb;
   struct loop *def_loop;
 
+  /* Give up if the expression is larger than the MAX that we allow.  */
+  if (size_expr++ > PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
+    return chrec_dont_know;
+
   if (automatically_generated_chrec_p (chrec)
       || is_gimple_min_invariant (chrec))
     return chrec;
@@ -2068,7 +2074,7 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
        }
 
       else if (res != chrec_dont_know)
-       res = instantiate_parameters_1 (loop, res, flags, cache);
+       res = instantiate_parameters_1 (loop, res, flags, cache, size_expr);
 
       bitmap_clear_bit (already_instantiated, SSA_NAME_VERSION (chrec));
 
@@ -2078,12 +2084,12 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
 
     case POLYNOMIAL_CHREC:
       op0 = instantiate_parameters_1 (loop, CHREC_LEFT (chrec),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
        return chrec_dont_know;
 
       op1 = instantiate_parameters_1 (loop, CHREC_RIGHT (chrec),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op1 == chrec_dont_know)
        return chrec_dont_know;
 
@@ -2094,12 +2100,12 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
 
     case PLUS_EXPR:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
        return chrec_dont_know;
 
       op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op1 == chrec_dont_know)
        return chrec_dont_know;
 
@@ -2110,12 +2116,12 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
 
     case MINUS_EXPR:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
        return chrec_dont_know;
 
       op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op1 == chrec_dont_know)
        return chrec_dont_know;
 
@@ -2126,12 +2132,12 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
 
     case MULT_EXPR:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
        return chrec_dont_know;
 
       op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op1 == chrec_dont_know)
        return chrec_dont_know;
 
@@ -2144,7 +2150,7 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
     case CONVERT_EXPR:
     case NON_LVALUE_EXPR:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
         return chrec_dont_know;
 
@@ -2174,17 +2180,17 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
     {
     case 3:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
        return chrec_dont_know;
 
       op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op1 == chrec_dont_know)
        return chrec_dont_know;
 
       op2 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 2),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op2 == chrec_dont_know)
         return chrec_dont_know;
 
@@ -2198,12 +2204,12 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
 
     case 2:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
        return chrec_dont_know;
 
       op1 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 1),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op1 == chrec_dont_know)
         return chrec_dont_know;
 
@@ -2214,7 +2220,7 @@ instantiate_parameters_1 (struct loop *loop, tree chrec, int flags, htab_t cache
            
     case 1:
       op0 = instantiate_parameters_1 (loop, TREE_OPERAND (chrec, 0),
-                                     flags, cache);
+                                     flags, cache, size_expr);
       if (op0 == chrec_dont_know)
         return chrec_dont_know;
       if (op0 == TREE_OPERAND (chrec, 0))
@@ -2252,7 +2258,8 @@ instantiate_parameters (struct loop *loop,
       fprintf (dump_file, ")\n");
     }
  
-  res = instantiate_parameters_1 (loop, chrec, INSERT_SUPERLOOP_CHRECS, cache);
+  res = instantiate_parameters_1 (loop, chrec, INSERT_SUPERLOOP_CHRECS, cache,
+                                 0);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
@@ -2275,7 +2282,7 @@ static tree
 resolve_mixers (struct loop *loop, tree chrec)
 {
   htab_t cache = htab_create (10, hash_scev_info, eq_scev_info, del_scev_info);
-  tree ret = instantiate_parameters_1 (loop, chrec, FOLD_CONVERSIONS, cache);
+  tree ret = instantiate_parameters_1 (loop, chrec, FOLD_CONVERSIONS, cache, 0);
   htab_delete (cache);
   return ret;
 }