This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lno] Fix bootstrap problems and regression
- From: pop <pop at icps dot u-strasbg dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 Jun 2004 03:16:59 +0200
- Subject: [lno] Fix bootstrap problems and regression
Hi,
Sorry for all the troubles that my patches have caused. Here is a
patch that shows no more regressions in the scev testsuite and that
bootstraps on powerpc-apple-darwin7.4.0, i686-pc-linux-gnu and
ia64-unknown-linux-gnu.
I had to sort of revert in part my patch on removing intervals, but
that was just for fixing users that rely on the fact that the code of
chrec_dont_know was not INTEGER_CST... I still have to more carefully
remove this node and fix the problems that occur.
Sebastian.
Index: ChangeLog.lno
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/ChangeLog.lno,v
retrieving revision 1.1.2.203
diff -d -u -p -r1.1.2.203 ChangeLog.lno
--- ChangeLog.lno 23 Jun 2004 18:59:54 -0000 1.1.2.203
+++ ChangeLog.lno 25 Jun 2004 00:16:13 -0000
@@ -1,3 +1,21 @@
+2004-06-24 Sebastian Pop <pop@cri.ensmp.fr>
+
+ * tree-chrec.c (chrec_fold_automatically_generated_operands,
+ chrec_merge):
+ Use chrec_dont_know instead of a call to chrec_contains_undetermined.
+ (tree_fold_factorial, tree_fold_binomial, chrec_evaluate): Resurrect.
+ (chrec_apply): Reinsert the cases that were removed.
+ (chrec_convert): Remove the check for NULL_TREE inserted two days ago.
+ * tree-scalar-evolution.c (follow_ssa_edge_in_rhs): As a sequel of
+ removing the tree_fold_* functions, the analyzed trees can contain
+ NON_LVALUE_EXPR nodes. Use STRIP_TYPE_NOPS for avoiding these nodes.
+ (number_of_iterations_in_loop): Add the missing open parenthesis in
+ the debugging dumps.
+ (initialize_scalar_evolutions_analyzer): Use an INTERVAL_CHREC for
+ constructing the chrec_dont_know node. This fixes some strange
+ problems that arise when chrec_dont_know is an INTEGER_CST.
+ * tree.def (INTERVAL_CHREC): Resurrect.
+
2004-06-23 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz>
* tree-chrec.c (chrec_merge): Handle case when one of the arguments
Index: tree-chrec.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-chrec.c,v
retrieving revision 1.1.2.30
diff -d -u -p -r1.1.2.30 tree-chrec.c
--- tree-chrec.c 23 Jun 2004 18:59:54 -0000 1.1.2.30
+++ tree-chrec.c 25 Jun 2004 00:16:13 -0000
@@ -227,8 +227,8 @@ static inline tree
chrec_fold_automatically_generated_operands (tree op0,
tree op1)
{
- if (chrec_contains_undetermined (op0)
- || chrec_contains_undetermined (op1))
+ if (op0 == chrec_dont_know
+ || op1 == chrec_dont_know)
return chrec_dont_know;
if (op0 == chrec_known
@@ -391,6 +391,65 @@ chrec_fold_multiply (tree type,
/* Operations. */
+/* The factorial. */
+
+static tree
+tree_fold_factorial (tree f)
+{
+ if (tree_int_cst_sgn (f) <= 0)
+ return integer_one_node;
+ else
+ return fold
+ (build (MULT_EXPR, integer_type_node, f,
+ tree_fold_factorial (fold (build (MINUS_EXPR, integer_type_node,
+ f, integer_one_node)))));
+}
+
+/* The binomial coefficient. */
+
+static tree
+tree_fold_binomial (tree n,
+ tree k)
+{
+ return fold
+ (build (EXACT_DIV_EXPR, integer_type_node, tree_fold_factorial (n),
+ fold (build (MULT_EXPR, integer_type_node,
+ tree_fold_factorial (k),
+ tree_fold_factorial
+ (fold (build (MINUS_EXPR, integer_type_node,
+ n, k)))))));
+}
+
+/* Helper function. Use the Newton's interpolating formula for
+ evaluating the value of the evolution function. */
+
+static tree
+chrec_evaluate (unsigned var,
+ tree chrec,
+ tree n,
+ tree k)
+{
+ tree type = chrec_type (chrec);
+ tree binomial_n_k = tree_fold_binomial (n, k);
+
+ if (TREE_CODE (chrec) == POLYNOMIAL_CHREC)
+ {
+ if (CHREC_VARIABLE (chrec) > var)
+ return chrec_evaluate (var, CHREC_LEFT (chrec), n, k);
+
+ if (CHREC_VARIABLE (chrec) == var)
+ return chrec_fold_plus
+ (type,
+ fold (build (MULT_EXPR, type, binomial_n_k, CHREC_LEFT (chrec))),
+ chrec_evaluate (var, CHREC_RIGHT (chrec), n,
+ fold (build (PLUS_EXPR, type, k, integer_one_node))));
+
+ return fold (build (MULT_EXPR, type, binomial_n_k, chrec));
+ }
+ else
+ return fold (build (MULT_EXPR, type, binomial_n_k, chrec));
+}
+
/* Evaluates "CHREC (X)" when the varying variable is VAR.
Example: Given the following parameters,
@@ -422,7 +481,7 @@ chrec_apply (unsigned var,
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "(chrec_apply \n");
-
+
if (evolution_function_is_affine_p (chrec))
{
/* "{a, +, b} (x)" -> "a + b*x". */
@@ -436,6 +495,14 @@ chrec_apply (unsigned var,
CHREC_RIGHT (chrec), x));
}
+ else if (TREE_CODE (chrec) != POLYNOMIAL_CHREC)
+ res = chrec;
+
+ else if (TREE_CODE (x) == INTEGER_CST
+ && tree_int_cst_sgn (x) == 1)
+ /* testsuite/.../ssa-chrec-38.c. */
+ res = chrec_evaluate (var, chrec, x, integer_zero_node);
+
else
res = chrec_dont_know;
@@ -594,19 +661,19 @@ tree
chrec_merge (tree chrec1,
tree chrec2)
{
- if (chrec1 == chrec_not_analyzed_yet)
- return chrec2;
- if (chrec2 == chrec_not_analyzed_yet)
- return chrec1;
-
- if (chrec_contains_undetermined (chrec1)
- || chrec_contains_undetermined (chrec2))
+ if (chrec1 == chrec_dont_know
+ || chrec2 == chrec_dont_know)
return chrec_dont_know;
if (chrec1 == chrec_known
|| chrec2 == chrec_known)
return chrec_known;
+ if (chrec1 == chrec_not_analyzed_yet)
+ return chrec2;
+ if (chrec2 == chrec_not_analyzed_yet)
+ return chrec1;
+
if (operand_equal_p (chrec1, chrec2, 0))
return chrec1;
@@ -851,8 +918,6 @@ chrec_convert (tree type,
return chrec;
ct = chrec_type (chrec);
- if (ct == NULL_TREE)
- return chrec_dont_know;
if (ct == type)
return chrec;
Index: tree-scalar-evolution.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-scalar-evolution.c,v
retrieving revision 1.1.2.62
diff -d -u -p -r1.1.2.62 tree-scalar-evolution.c
--- tree-scalar-evolution.c 23 Jun 2004 14:12:37 -0000 1.1.2.62
+++ tree-scalar-evolution.c 25 Jun 2004 00:16:14 -0000
@@ -1108,7 +1108,9 @@ follow_ssa_edge_in_rhs (struct loop *loo
/* This case is under the form "rhs0 + rhs1". */
rhs0 = TREE_OPERAND (rhs, 0);
rhs1 = TREE_OPERAND (rhs, 1);
-
+ STRIP_TYPE_NOPS (rhs0);
+ STRIP_TYPE_NOPS (rhs1);
+
if (TREE_CODE (rhs0) == SSA_NAME)
{
if (TREE_CODE (rhs1) == SSA_NAME)
@@ -1178,6 +1180,9 @@ follow_ssa_edge_in_rhs (struct loop *loo
/* This case is under the form "opnd0 = rhs0 - rhs1". */
rhs0 = TREE_OPERAND (rhs, 0);
rhs1 = TREE_OPERAND (rhs, 1);
+ STRIP_TYPE_NOPS (rhs0);
+ STRIP_TYPE_NOPS (rhs1);
+
if (TREE_CODE (rhs0) == SSA_NAME)
{
if (TREE_CODE (rhs1) == SSA_NAME)
@@ -1252,6 +1257,9 @@ follow_ssa_edge_in_rhs (struct loop *loo
/* This case is under the form "opnd0 = rhs0 * rhs1". */
rhs0 = TREE_OPERAND (rhs, 0);
rhs1 = TREE_OPERAND (rhs, 1);
+ STRIP_TYPE_NOPS (rhs0);
+ STRIP_TYPE_NOPS (rhs1);
+
if (TREE_CODE (rhs0) == SSA_NAME)
{
if (TREE_CODE (rhs1) == SSA_NAME)
@@ -2152,6 +2160,9 @@ number_of_iterations_in_loop (struct loo
if (res)
return res;
res = chrec_dont_know;
+
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ fprintf (dump_file, "(number_of_iterations_in_loop\n");
if (!loop_exit_edges (loop))
goto end;
@@ -2403,7 +2414,8 @@ initialize_scalar_evolutions_analyzer (v
if (chrec_dont_know == NULL_TREE)
{
chrec_not_analyzed_yet = NULL_TREE;
- chrec_dont_know = build_int_2 (2222, 0);
+ chrec_dont_know = build (INTERVAL_CHREC, integer_type_node,
+ build_int_2 (2222, 0), build_int_2 (3222, 0));
chrec_known = build_int_2 (3333, 0);
}
}
Index: tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.def,v
retrieving revision 1.52.2.21.2.10
diff -d -u -p -r1.52.2.21.2.10 tree.def
--- tree.def 22 Jun 2004 14:12:22 -0000 1.52.2.21.2.10
+++ tree.def 25 Jun 2004 00:16:15 -0000
@@ -897,6 +897,11 @@ DEFTREECODE (CATCH_EXPR, "catch_expr", '
expanding. */
DEFTREECODE (EH_FILTER_EXPR, "eh_filter_expr", 's', 2)
+/* Intervals.
+ Under the form: cr = [CHREC_LOW (cr), CHREC_UP (cr)].
+ CHREC_LOW and CHREC_UP contain INTEGER_CST nodes. */
+DEFTREECODE (INTERVAL_CHREC, "interval_chrec", 'e', 2)
+
/* Polynomial chains of recurrences.
Under the form: cr = {CHREC_LEFT (cr), +, CHREC_RIGHT (cr)}. */
DEFTREECODE (POLYNOMIAL_CHREC, "polynomial_chrec", 'e', 3)