summaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-21 08:48:55 +0000
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>2005-04-21 08:48:55 +0000
commita89ef955863b1fcc19f862bf6c15b02650040f67 (patch)
treef3f2b4031060687272842eac011220d90325c975 /gcc/tree-chrec.c
parent0e2551653f01c4cc2cbe2bc67c2711fe73f37a02 (diff)
downloadlinaro-gcc-a89ef955863b1fcc19f862bf6c15b02650040f67.tar.gz
linaro-gcc-a89ef955863b1fcc19f862bf6c15b02650040f67.tar.bz2
linaro-gcc-a89ef955863b1fcc19f862bf6c15b02650040f67.zip
PR/20742
* Makefile.in (tree-chrec.o): Depend on params.h. * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98497 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index b6276e929fd..967a3cd8158 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -35,6 +35,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "varray.h"
#include "tree-chrec.h"
#include "tree-pass.h"
+#include "params.h"
@@ -286,11 +287,17 @@ chrec_fold_plus_1 (enum tree_code code,
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;
+ }
}
}
}
@@ -374,7 +381,7 @@ chrec_fold_multiply (tree type,
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);
}
}
}
@@ -478,8 +485,8 @@ chrec_evaluate (unsigned var, tree chrec, tree n, unsigned int k)
binomial_n_k = tree_fold_binomial (type, n, k);
if (!binomial_n_k)
return chrec_dont_know;
- arg1 = fold (build2 (MULT_EXPR, type,
- CHREC_LEFT (chrec), binomial_n_k));
+ arg1 = fold_build2 (MULT_EXPR, type,
+ CHREC_LEFT (chrec), binomial_n_k);
return chrec_fold_plus (type, arg0, arg1);
}
@@ -487,7 +494,7 @@ chrec_evaluate (unsigned var, tree chrec, tree n, unsigned int k)
if (!binomial_n_k)
return chrec_dont_know;
- return fold (build2 (MULT_EXPR, type, chrec, binomial_n_k));
+ return fold_build2 (MULT_EXPR, type, chrec, binomial_n_k);
}
/* Evaluates "CHREC (X)" when the varying variable is VAR.
@@ -717,7 +724,7 @@ reset_evolution_in_loop (unsigned loop_num,
{
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),
@@ -862,29 +869,34 @@ chrec_contains_undetermined (tree chrec)
}
}
-/* 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: