From 88d02c9e3e2d8e03745271bac7541767d9f553b5 Mon Sep 17 00:00:00 2001 From: rakdver Date: Tue, 20 Sep 2005 07:09:20 +0000 Subject: PR tree-optimization/18463 * tree-chrec.c (chrec_convert): Return fold_converted chrec if converting it directly is not possible. (chrec_convert_aggressive): New function. * tree-chrec.h (chrec_convert_aggressive): Declare. * tree-scalar-evolution.c (instantiate_parameters_1, resolve_mixers): Fold chrec conversions aggressively if asked to. (instantiate_parameters): Modified because of changes in instantiate_parameters_1. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104443 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-chrec.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'gcc/tree-chrec.c') diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c index 88b27d84aa6..0bf1d384592 100644 --- a/gcc/tree-chrec.c +++ b/gcc/tree-chrec.c @@ -1164,9 +1164,7 @@ chrec_convert (tree type, tree chrec, tree at_stmt) fprintf (dump_file, "\n)\n"); } - /* Directly convert to "don't know": no worth dealing with - difficult cases. */ - return chrec_dont_know; + return fold_convert (type, chrec); } return build_polynomial_chrec (CHREC_VARIABLE (chrec), @@ -1201,6 +1199,35 @@ chrec_convert (tree type, tree chrec, tree at_stmt) return res; } +/* Convert CHREC to TYPE, without regard to signed overflows. Returns the new + chrec if something else than what chrec_convert would do happens, NULL_TREE + otherwise. */ + +tree +chrec_convert_aggressive (tree type, tree chrec) +{ + tree inner_type, left, right, lc, rc; + + if (automatically_generated_chrec_p (chrec) + || TREE_CODE (chrec) != POLYNOMIAL_CHREC) + return NULL_TREE; + + inner_type = TREE_TYPE (chrec); + if (TYPE_PRECISION (type) > TYPE_PRECISION (inner_type)) + return NULL_TREE; + + left = CHREC_LEFT (chrec); + right = CHREC_RIGHT (chrec); + lc = chrec_convert_aggressive (type, left); + if (!lc) + lc = chrec_convert (type, left, NULL_TREE); + rc = chrec_convert_aggressive (type, right); + if (!rc) + rc = chrec_convert (type, right, NULL_TREE); + + return build_polynomial_chrec (CHREC_VARIABLE (chrec), lc, rc); +} + /* Returns the type of the chrec. */ tree -- cgit v1.2.1