diff options
author | Richard Kenner <kenner@vlsi1.ultra.nyu.edu> | 2001-02-23 21:10:35 +0000 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 2001-02-23 16:10:35 -0500 |
commit | 3cc247a81a4e4ed0abb83a096333671f882d15ff (patch) | |
tree | 08fee81497a15c508d229f0af6f7c1ba4ea059d2 | |
parent | ac50176d22e5a67355cde8740a2acac344c0e35d (diff) | |
download | gcc-3cc247a81a4e4ed0abb83a096333671f882d15ff.zip gcc-3cc247a81a4e4ed0abb83a096333671f882d15ff.tar.gz gcc-3cc247a81a4e4ed0abb83a096333671f882d15ff.tar.bz2 |
convert.c (convert_to_integer): Don't do unsigned unless result or both inputs are unsigned.
* convert.c (convert_to_integer): Don't do unsigned unless result or
both inputs are unsigned.
From-SVN: r40014
-rw-r--r-- | gcc/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/convert.c | 6 |
2 files changed, 6 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a89be70..1daa849 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ Fri Feb 23 15:28:39 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> + * convert.c (convert_to_integer): Don't do unsigned unless result or + both inputs are unsigned. + * fold-const.c (fold_convert): Don't call size_int_type_wide if input overflows. diff --git a/gcc/convert.c b/gcc/convert.c index dd1b91a..b97d08f 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -310,13 +310,13 @@ convert_to_integer (type, expr) { /* Don't do unsigned arithmetic where signed was wanted, or vice versa. - Exception: if either of the original operands were + Exception: if both of the original operands were unsigned then can safely do the work as unsigned. And we may need to do it as unsigned if we truncate to the original size. */ typex = ((TREE_UNSIGNED (TREE_TYPE (expr)) - || TREE_UNSIGNED (TREE_TYPE (arg0)) - || TREE_UNSIGNED (TREE_TYPE (arg1))) + || (TREE_UNSIGNED (TREE_TYPE (arg0)) + && TREE_UNSIGNED (TREE_TYPE (arg1)))) ? unsigned_type (typex) : signed_type (typex)); return convert (type, fold (build (ex_form, typex, |