Commit 3cc247a8 by Richard Kenner Committed by Richard Kenner

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
parent ac50176d
Fri Feb 23 15:28:39 2001 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 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 * fold-const.c (fold_convert): Don't call size_int_type_wide if
input overflows. input overflows.
......
...@@ -310,13 +310,13 @@ convert_to_integer (type, expr) ...@@ -310,13 +310,13 @@ convert_to_integer (type, expr)
{ {
/* Don't do unsigned arithmetic where signed was wanted, /* Don't do unsigned arithmetic where signed was wanted,
or vice versa. 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. unsigned then can safely do the work as unsigned.
And we may need to do it as unsigned And we may need to do it as unsigned
if we truncate to the original size. */ if we truncate to the original size. */
typex = ((TREE_UNSIGNED (TREE_TYPE (expr)) typex = ((TREE_UNSIGNED (TREE_TYPE (expr))
|| TREE_UNSIGNED (TREE_TYPE (arg0)) || (TREE_UNSIGNED (TREE_TYPE (arg0))
|| TREE_UNSIGNED (TREE_TYPE (arg1))) && TREE_UNSIGNED (TREE_TYPE (arg1))))
? unsigned_type (typex) : signed_type (typex)); ? unsigned_type (typex) : signed_type (typex));
return convert (type, return convert (type,
fold (build (ex_form, typex, fold (build (ex_form, typex,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment