public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Do not use TYPE_CANONICAL in useless_type_conversion
@ 2015-09-30 22:11 Jan Hubicka
  2015-10-01  8:33 ` Richard Biener
  2015-10-01 14:11 ` Eric Botcazou
  0 siblings, 2 replies; 55+ messages in thread
From: Jan Hubicka @ 2015-09-30 22:11 UTC (permalink / raw)
  To: gcc-patches, rguenther

Hi,
this implements the idea we discussed at Cauldron to not use TYPE_CANONICAL for
useless_type_conversion_p.  The basic idea is that TYPE_CANONICAL is language
specific and should not be part of definition of the Gimple type system that should
be quite agnostic of language.

useless_type_conversion_p clearly is about operations on the type and those do not
depends on TYPE_CANONICAL or alias info. For LTO and C/Fortran interpoerability
rules we are forced to make TYPE_CANONICAL more coarse than it needs to be
that results in troubles with useless_type_conversion_p use.

After dropping the check I needed to solve two issues. First is that we need a
definition of useless conversions for aggregates. As discussed earlier I made
it to depend only on size. The basic idea is that only operations you can do on
gimple with those are moves and field accesses. Field accesses have
corresponding type into in COMPONENT_REF or MEM_REF, so we do not care about
conversions of those.  This caused three Ada failures on PPC64, because we can
not move between structures of same size but different mode.

Other failure introduced was 2 cases in C++ testsuite because we currently
do not handle OFFSET_TYPE at all.  I added the obvious check for TREE_TYPE
and BASE_TYPE to be compatible.
I think we can allow more of conversions between OFFSET_TYPEs and integer
types, but I would like to leave this for incremental changes. (It is probalby
not too important anyway).

Bootstrapped/regtested x86_64-linux except Ada and ppc64-linux for all languages
including Ada. OK?

I have reviewed the uses of useless_type_conversion_p on non-register types
and there are some oddities, will send separate patches for those.

Honza

	* gimple-expr.c (useless_type_conversion_p): Do not use TYPE_CANONICAL
	for defining useless conversions; make structure compatible if size
	and mode are.
Index: gimple-expr.c
===================================================================
--- gimple-expr.c	(revision 228267)
+++ gimple-expr.c	(working copy)
@@ -87,11 +87,6 @@ useless_type_conversion_p (tree outer_ty
   if (inner_type == outer_type)
     return true;
 
-  /* If we know the canonical types, compare them.  */
-  if (TYPE_CANONICAL (inner_type)
-      && TYPE_CANONICAL (inner_type) == TYPE_CANONICAL (outer_type))
-    return true;
-
   /* Changes in machine mode are never useless conversions unless we
      deal with aggregate types in which case we defer to later checks.  */
   if (TYPE_MODE (inner_type) != TYPE_MODE (outer_type)
@@ -270,12 +265,23 @@ useless_type_conversion_p (tree outer_ty
       return true;
     }
 
-  /* For aggregates we rely on TYPE_CANONICAL exclusively and require
-     explicit conversions for types involving to be structurally
-     compared types.  */
+  /* For aggregates compare only the size and mode.  Accesses to fields do have
+     a type information by themselves and thus we only care if we can i.e.
+     use the types in move operations.  */
   else if (AGGREGATE_TYPE_P (inner_type)
 	   && TREE_CODE (inner_type) == TREE_CODE (outer_type))
-    return false;
+    return (!TYPE_SIZE (outer_type)
+	    || (TYPE_SIZE (inner_type)
+		&& operand_equal_p (TYPE_SIZE (inner_type),
+				    TYPE_SIZE (outer_type), 0)))
+	   && TYPE_MODE (outer_type) == TYPE_MODE (inner_type);
+  else if (TREE_CODE (inner_type) == OFFSET_TYPE
+	   && TREE_CODE (inner_type) == TREE_CODE (outer_type))
+    return useless_type_conversion_p (TREE_TYPE (outer_type),
+				      TREE_TYPE (inner_type))
+	   && useless_type_conversion_p
+	        (TYPE_OFFSET_BASETYPE (outer_type),
+		 TYPE_OFFSET_BASETYPE (inner_type));
 
   return false;
 }

^ permalink raw reply	[flat|nested] 55+ messages in thread
* Re: Do not use TYPE_CANONICAL in useless_type_conversion
@ 2015-10-02 11:30 Bernd Edlinger
  2015-10-02 21:31 ` Eric Botcazou
  0 siblings, 1 reply; 55+ messages in thread
From: Bernd Edlinger @ 2015-10-02 11:30 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, Jan Hubicka, Richard Biener

Hi,

actually I do not quite understand why we need a TYPE_ALIGN_OK flag that is only used in Ada.
Somehow other languages seem to have no problem of that kind.

You remember, when I removed the TYPE_ALIGN_OK handing (initially it wasn't clear to me that
it's entire use is only to make Ada happy), all Ada tests continued to pass, even on ARM.
BTW: You promised me last year to give me an example where that makes a difference.


Thanks,
Bernd.
 		 	   		  

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

end of thread, other threads:[~2015-10-16 15:03 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-30 22:11 Do not use TYPE_CANONICAL in useless_type_conversion Jan Hubicka
2015-10-01  8:33 ` Richard Biener
2015-10-01 17:51   ` Jan Hubicka
2015-10-02  7:45     ` Richard Biener
2015-10-02  6:43   ` Jan Hubicka
2015-10-02  7:56     ` Richard Biener
2015-10-02 16:02       ` Jan Hubicka
2015-10-02 18:00         ` Jan Hubicka
2015-10-02 21:16           ` Eric Botcazou
2015-10-02 21:41             ` Jan Hubicka
2015-10-02 21:52               ` Jan Hubicka
2015-10-05 12:54                 ` Bernd Schmidt
2015-10-05 15:35                   ` Jan Hubicka
2015-10-06 11:18                     ` Richard Biener
2015-10-06 17:54                       ` Jan Hubicka
2015-10-07  6:00                         ` Jan Hubicka
2015-10-07  8:52                           ` Richard Biener
2015-10-08  3:49                             ` Jan Hubicka
2015-10-08  7:48                               ` Richard Biener
2015-10-08 16:20                                 ` Jan Hubicka
2015-10-08 10:51                               ` Richard Biener
2015-10-08 20:30                                 ` Jan Hubicka
2015-10-08 23:24                                   ` Jan Hubicka
2015-10-09  8:19                                     ` Richard Biener
2015-10-09  8:29                                       ` Eric Botcazou
2015-10-09  7:36                                   ` Eric Botcazou
2015-10-09 17:55                                     ` Jan Hubicka
2015-10-13  8:09                                       ` Alexandre Oliva
2015-10-13  8:39                                         ` Richard Biener
2015-10-13  9:20                                         ` Eric Botcazou
2015-10-13 16:36                                           ` Alexandre Oliva
2015-10-14  4:34                                             ` Jan Hubicka
2015-10-14 20:15                                               ` Alexandre Oliva
2015-10-08 10:54                               ` Eric Botcazou
2015-10-08 16:03                                 ` Jan Hubicka
2015-10-08 16:10                                 ` Andreas Schwab
2015-10-08 23:05                                   ` Jan Hubicka
2015-10-09  9:18                                     ` Andreas Schwab
2015-10-09 18:34                                       ` Jan Hubicka
2015-10-16  6:45                                       ` Jan Hubicka
2015-10-16 15:08                                         ` Andreas Schwab
2015-10-01 14:11 ` Eric Botcazou
2015-10-01 14:28   ` Richard Biener
2015-10-01 14:39     ` Eric Botcazou
2015-10-01 17:44       ` Jan Hubicka
2015-10-02  7:43         ` Eric Botcazou
2015-10-02  8:00           ` Richard Biener
2015-10-02  8:37             ` Eric Botcazou
2015-10-02  7:39       ` Richard Biener
2015-10-02  7:48         ` Eric Botcazou
2015-10-02  8:03           ` Richard Biener
2015-10-02 11:30 Bernd Edlinger
2015-10-02 21:31 ` Eric Botcazou
2015-10-03 16:23   ` Bernd Edlinger
2015-10-03 21:31     ` Eric Botcazou

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).