summaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorJeff Law <law@redhat.com>2006-02-28 09:49:12 -0700
committerJeff Law <law@gcc.gnu.org>2006-02-28 09:49:12 -0700
commite5c7f9f582b4148974efae8c9289652601909753 (patch)
tree393da7d6a3e8965560f998f6bfda921dfff70f2b /gcc/tree-chrec.c
parentea45681a7a59fe9c8b2b3df10f403d21a49eebe9 (diff)
downloadgcc-e5c7f9f582b4148974efae8c9289652601909753.tar.gz
tree-chrec.c (chrec_convert_aggressive): Do not eliminate conversions where TYPE_MIN_VALUE/TYPE_MAX_VALUE do not cover...
* tree-chrec.c (chrec_convert_aggressive): Do not eliminate conversions where TYPE_MIN_VALUE/TYPE_MAX_VALUE do not cover the range allowed by TYPE_PRECISION. From-SVN: r111568
Diffstat (limited to 'gcc/tree-chrec.c')
-rw-r--r--gcc/tree-chrec.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index b1587a5f91d..8edc5b9bbec 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -1219,6 +1219,26 @@ chrec_convert_aggressive (tree type, tree chrec)
if (!rc)
rc = chrec_convert (type, right, NULL_TREE);
+ /* Ada creates sub-types where TYPE_MIN_VALUE/TYPE_MAX_VALUE do not
+ cover the entire range of values allowed by TYPE_PRECISION.
+
+ We do not want to optimize away conversions to such types. Long
+ term I'd rather see the Ada front-end fixed. */
+ if (INTEGRAL_TYPE_P (type))
+ {
+ tree t;
+
+ t = upper_bound_in_type (type, inner_type);
+ if (! TYPE_MAX_VALUE (type)
+ || ! operand_equal_p (TYPE_MAX_VALUE (type), t, 0))
+ return NULL_TREE;
+
+ t = lower_bound_in_type (type, inner_type);
+ if (! TYPE_MIN_VALUE (type)
+ || ! operand_equal_p (TYPE_MIN_VALUE (type), t, 0))
+ return NULL_TREE;
+ }
+
return build_polynomial_chrec (CHREC_VARIABLE (chrec), lc, rc);
}