summaryrefslogtreecommitdiff
path: root/gcc/tree-chrec.c
diff options
context:
space:
mode:
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-28 16:49:12 +0000
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-28 16:49:12 +0000
commit136335a28f44c3eeab45ca715f30c6dcfe59e1b4 (patch)
tree393da7d6a3e8965560f998f6bfda921dfff70f2b /gcc/tree-chrec.c
parent8c8a79f4327e1a826a73e3cf8934e0a6c85f2f42 (diff)
downloadgcc-136335a28f44c3eeab45ca715f30c6dcfe59e1b4.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111568 138bc75d-0d04-0410-961f-82ee72b054a4
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);
}