public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Do not generate useless integral conversions
@ 2014-06-24 10:55 Eric Botcazou
  2014-06-24 14:32 ` Richard Biener
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Botcazou @ 2014-06-24 10:55 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

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  <ebotcazou@adacore.com>

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


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1728 bytes --]

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)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-10-02 18:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-24 10:55 [patch] Do not generate useless integral conversions Eric Botcazou
2014-06-24 14:32 ` Richard Biener
2014-06-24 21:18   ` Eric Botcazou
2014-06-25  8:21     ` Richard Biener
2014-10-02 10:42       ` Eric Botcazou
2014-10-02 18:33         ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).