aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorZdenek Dvorak <dvorakz@suse.cz>2005-09-20 09:09:20 +0200
committerZdenek Dvorak <rakdver@gcc.gnu.org>2005-09-20 07:09:20 +0000
commit2282a0e6d49a6ad125c39340bf404bfddfa72fce (patch)
treeee911e5a5331d4a03e36339c0a1164fe6ef47658 /gcc/tree-chrec.c
parent3a3c28db2425a15fe9b24635f0aa99249e4b64c6 (diff)
downloadgcc-2282a0e6d49a6ad125c39340bf404bfddfa72fce.zip
gcc-2282a0e6d49a6ad125c39340bf404bfddfa72fce.tar.gz
gcc-2282a0e6d49a6ad125c39340bf404bfddfa72fce.tar.bz2
re PR tree-optimization/18463 (suboptimal use of fancy x86 addressing modes)
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. From-SVN: r104443
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index 88b27d8..0bf1d38 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