Hi,

https://gcc.gnu.org/ml/gcc-patches/2012-03/msg00491.html changed the old 
signed_type_for/unsigned_type_for functions and made them always return an 
integer type, whereas they would previously leave integral types unchanged.
I don't see any justification for the latter and this has the annoying effect 
of generating useless integral conversions in convert.c, for example between 
boolean types and integer types of the same precision.

The attached patch restores the old behavior for them.  Bootstrapped/regtested 
on x86_64-suse-linux, OK for the mainline?


2014-06-24  Eric Botcazou  <ebotca...@adacore.com>

        * tree.c (signed_or_unsigned_type_for): Treat integral types equally.


-- 
Eric Botcazou
Index: tree.c
===================================================================
--- tree.c	(revision 211927)
+++ tree.c	(working copy)
@@ -10684,14 +10684,14 @@ int_cst_value (const_tree x)
   return val;
 }
 
-/* If TYPE is an integral or pointer type, return an integer type with
+/* If TYPE is an integral or pointer type, return an integral type with
    the same precision which is unsigned iff UNSIGNEDP is true, or itself
-   if TYPE is already an integer type of signedness UNSIGNEDP.  */
+   if TYPE is already an integral type of signedness UNSIGNEDP.  */
 
 tree
 signed_or_unsigned_type_for (int unsignedp, tree type)
 {
-  if (TREE_CODE (type) == INTEGER_TYPE && TYPE_UNSIGNED (type) == unsignedp)
+  if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type) == unsignedp)
     return type;
 
   if (TREE_CODE (type) == VECTOR_TYPE)
@@ -10713,9 +10713,9 @@ signed_or_unsigned_type_for (int unsigne
   return build_nonstandard_integer_type (TYPE_PRECISION (type), unsignedp);
 }
 
-/* If TYPE is an integral or pointer type, return an integer type with
+/* If TYPE is an integral or pointer type, return an integral type with
    the same precision which is unsigned, or itself if TYPE is already an
-   unsigned integer type.  */
+   unsigned integral type.  */
 
 tree
 unsigned_type_for (tree type)
@@ -10723,9 +10723,9 @@ unsigned_type_for (tree type)
   return signed_or_unsigned_type_for (1, type);
 }
 
-/* If TYPE is an integral or pointer type, return an integer type with
+/* If TYPE is an integral or pointer type, return an integral type with
    the same precision which is signed, or itself if TYPE is already a
-   signed integer type.  */
+   signed integral type.  */
 
 tree
 signed_type_for (tree type)

Reply via email to