+2005-06-06 Sebastian Pop <pop@cri.ensmp.fr>
+
+ PR tree-optimization/20742
+ * params.def (PARAM_SCEV_MAX_EXPR_SIZE): New parameter with
+ default value 20.
+ * tree-chrec.c: Depend on params.h. Replace build with buildN,
+ and fold build with fold_buildN.
+ (chrec_fold_plus_1): Fail with a chrec_don_know when the size of
+ the expression exceeds PARAM_SCEV_MAX_EXPR_SIZE.
+ (tree_contains_chrecs): Compute an estimation of the size of the
+ given expression.
+ * tree-chrec.h (tree_contains_chrecs): Modify its declaration.
+ (tree_does_not_contain_chrecs): Update the use of tree_contains_chrecs.
+ * tree-scalar-evolution.c (simple_iv): Ditto.
+ * doc/invoke.texi (scev-max-expr-size): Documented.
+
2005-06-04 Richard Henderson <rth@redhat.com>
PR target/21888
#include "varray.h"
#include "tree-chrec.h"
#include "tree-pass.h"
+#include "params.h"
\f
build_int_cst_type (type, -1)));
default:
- if (tree_contains_chrecs (op0)
- || tree_contains_chrecs (op1))
- return build (code, type, op0, op1);
- else
- return fold (build (code, type, op0, op1));
+ {
+ int size = 0;
+ if ((tree_contains_chrecs (op0, &size)
+ || tree_contains_chrecs (op1, &size))
+ && size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
+ return build2 (code, type, op0, op1);
+ else if (size < PARAM_VALUE (PARAM_SCEV_MAX_EXPR_SIZE))
+ return fold (build2 (code, type, op0, op1));
+ else
+ return chrec_dont_know;
+ }
}
}
}
return op0;
if (integer_zerop (op1))
return build_int_cst_type (type, 0);
- return fold (build (MULT_EXPR, type, op0, op1));
+ return fold (build2 (MULT_EXPR, type, op0, op1));
}
}
}
{
if (TREE_CODE (chrec) == POLYNOMIAL_CHREC
&& CHREC_VARIABLE (chrec) > loop_num)
- return build
+ return build2
(TREE_CODE (chrec),
build_int_cst (NULL_TREE, CHREC_VARIABLE (chrec)),
reset_evolution_in_loop (loop_num, CHREC_LEFT (chrec), new_evol),
}
}
-/* Determines whether the tree EXPR contains chrecs. */
+/* Determines whether the tree EXPR contains chrecs, and increment
+ SIZE if it is not a NULL pointer by an estimation of the depth of
+ the tree. */
bool
-tree_contains_chrecs (tree expr)
+tree_contains_chrecs (tree expr, int *size)
{
if (expr == NULL_TREE)
return false;
+
+ if (size)
+ (*size)++;
if (tree_is_chrec (expr))
return true;
-
+
switch (TREE_CODE_LENGTH (TREE_CODE (expr)))
{
case 3:
- if (tree_contains_chrecs (TREE_OPERAND (expr, 2)))
+ if (tree_contains_chrecs (TREE_OPERAND (expr, 2), size))
return true;
case 2:
- if (tree_contains_chrecs (TREE_OPERAND (expr, 1)))
+ if (tree_contains_chrecs (TREE_OPERAND (expr, 1), size))
return true;
case 1:
- if (tree_contains_chrecs (TREE_OPERAND (expr, 0)))
+ if (tree_contains_chrecs (TREE_OPERAND (expr, 0), size))
return true;
default:
extern bool chrec_contains_symbols (tree);
extern bool chrec_contains_symbols_defined_in_loop (tree, unsigned);
extern bool chrec_contains_undetermined (tree);
-extern bool tree_contains_chrecs (tree);
+extern bool tree_contains_chrecs (tree, int *);
extern bool evolution_function_is_affine_multivariate_p (tree);
extern bool evolution_function_is_univariate_p (tree);
extern unsigned nb_vars_in_chrec (tree);
static inline bool
tree_does_not_contain_chrecs (tree expr)
{
- return !tree_contains_chrecs (expr);
+ return !tree_contains_chrecs (expr, NULL);
}
/* Determines whether CHREC is a loop invariant with respect to LOOP_NUM.