From 3cc247a81a4e4ed0abb83a096333671f882d15ff Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Fri, 23 Feb 2001 21:10:35 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 3 +++ gcc/convert.c | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a89be706dc2..1daa8496399 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ Fri Feb 23 15:28:39 2001 Richard Kenner + * 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 dd1b91a4e0b..b97d08fa4f7 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, -- 2.30.2