convert.c (convert_to_integer): Don't do unsigned unless result or both inputs are...
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Fri, 23 Feb 2001 21:10:35 +0000 (21:10 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Fri, 23 Feb 2001 21:10:35 +0000 (16:10 -0500)
* convert.c (convert_to_integer): Don't do unsigned unless result or
both inputs are unsigned.

From-SVN: r40014

gcc/ChangeLog
gcc/convert.c

index a89be706dc20d813a009b5b1397f67ea9459ae34..1daa849639900fc6a69a5b7673e1a59e856bf8e7 100644 (file)
@@ -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.
 
index dd1b91a4e0b1bfb6a21e0f230a5e4bc8f18546e9..b97d08fa4f7a544838c9571cbac8852dab174a25 100644 (file)
@@ -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,