aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2005-04-05 09:06:23 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2005-04-05 07:06:23 +0000
commitc4cdbeb4802cec34a912e343629d8e28b20128c7 (patch)
tree1742287c835dba65c2423d55c9ca50faf649778d
parent3c5ead4814e7a0b4f155b84271665cbafd50a120 (diff)
downloadgcc-c4cdbeb4802cec34a912e343629d8e28b20128c7.zip
gcc-c4cdbeb4802cec34a912e343629d8e28b20128c7.tar.gz
gcc-c4cdbeb4802cec34a912e343629d8e28b20128c7.tar.bz2
re PR tree-optimization/19903 (ACATS cxa4006 cxa4017 fail at runtime)
PR tree-optimization/19903 * tree-chrec.c (chrec_convert): Return chrec_dont_know for constants that don't fit in their type after conversion. Co-Authored-By: Sebastian Pop <sebastian.pop@cri.ensmp.fr> From-SVN: r97607
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-chrec.c30
2 files changed, 36 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 9f3a372..bbbade7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-05 Eric Botcazou <ebotcazou@libertysurf.fr>
+ Sebastian Pop <sebastian.pop@cri.ensmp.fr>
+
+ PR tree-optimization/19903
+ * tree-chrec.c (chrec_convert): Return chrec_dont_know for constants
+ that don't fit in their type after conversion.
+
2005-04-05 Uros Bizjak <uros@kss-loka.si>
PR target/20421
diff --git a/gcc/tree-chrec.c b/gcc/tree-chrec.c
index a360301..b6276e9 100644
--- a/gcc/tree-chrec.c
+++ b/gcc/tree-chrec.c
@@ -1002,7 +1002,23 @@ nb_vars_in_chrec (tree chrec)
-/* Convert the initial condition of chrec to type. */
+/* Convert CHREC to TYPE. The following is rule is always true:
+ TREE_TYPE (chrec) == TREE_TYPE (CHREC_LEFT (chrec)) == TREE_TYPE
+ (CHREC_RIGHT (chrec)). An example of what could happen when adding
+ two chrecs and the type of the CHREC_RIGHT is different than
+ CHREC_LEFT is:
+
+ {(uint) 0, +, (uchar) 10} +
+ {(uint) 0, +, (uchar) 250}
+
+ that would produce a wrong result if CHREC_RIGHT is not (uint):
+
+ {(uint) 0, +, (uchar) 4}
+
+ instead of
+
+ {(uint) 0, +, (uint) 260}
+*/
tree
chrec_convert (tree type,
@@ -1037,6 +1053,18 @@ chrec_convert (tree type,
TREE_OVERFLOW (res) = 0;
if (CONSTANT_CLASS_P (res))
TREE_CONSTANT_OVERFLOW (res) = 0;
+
+ /* But reject constants that don't fit in their type after conversion.
+ This can happen if TYPE_MIN_VALUE or TYPE_MAX_VALUE are not the
+ natural values associated with TYPE_PRECISION and TYPE_UNSIGNED,
+ and can cause problems later when computing niters of loops. Note
+ that we don't do the check before converting because we don't want
+ to reject conversions of negative chrecs to unsigned types. */
+ if (TREE_CODE (res) == INTEGER_CST
+ && TREE_CODE (type) == INTEGER_TYPE
+ && !int_fits_type_p (res, type))
+ res = chrec_dont_know;
+
return res;
}
}