From e5c7f9f582b4148974efae8c9289652601909753 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Tue, 28 Feb 2006 09:49:12 -0700 Subject: [PATCH] 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 --- gcc/ChangeLog | 4 ++++ gcc/tree-chrec.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3484670a0a6..7ba31346670 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2006-02-28 Jeff Law + * 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. + * tree.h (strct phi_arg_d): Remove unused NONZERO field. 2006-02-28 Dorit Nuzman 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); }