diff mbox

When not optimizing do not compute RTX memory attributes

Message ID 20151201070737.GA51402@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka Dec. 1, 2015, 7:07 a.m. UTC
Hi,
memory attributes are currently optimized and attached to RTL even when not
optimizing. This is obviously just a wasted effort.

Bootstrapped/regtested x86_64-linux, OK?

Honza
	* emit-rtl.c (set_mem_attrs, set_mem_attributes_minus_bitpos):
	Do not compute memory attributes when not optimizing.

Comments

Richard Biener Dec. 1, 2015, 10:42 a.m. UTC | #1
On Tue, 1 Dec 2015, Jan Hubicka wrote:

> Hi,
> memory attributes are currently optimized and attached to RTL even when not
> optimizing. This is obviously just a wasted effort.

Huh, are you sure?  What about globals used from different optimize
contexts?

> Bootstrapped/regtested x86_64-linux, OK?

I don't think so.  Did you bootstrap with BOOT_CFLAGS="-O0 -g"?

Richard.

> Honza
> 	* emit-rtl.c (set_mem_attrs, set_mem_attributes_minus_bitpos):
> 	Do not compute memory attributes when not optimizing.
> 
> Index: emit-rtl.c
> ===================================================================
> --- emit-rtl.c	(revision 231081)
> +++ emit-rtl.c	(working copy)
> @@ -336,7 +336,8 @@ static void
>  set_mem_attrs (rtx mem, mem_attrs *attrs)
>  {
>    /* If everything is the default, we can just clear the attributes.  */
> -  if (mem_attrs_eq_p (attrs, mode_mem_attrs[(int) GET_MODE (mem)]))
> +  if (!optimize
> +      || mem_attrs_eq_p (attrs, mode_mem_attrs[(int) GET_MODE (mem)]))
>      {
>        MEM_ATTRS (mem) = 0;
>        return;
> @@ -1749,6 +1750,9 @@ set_mem_attributes_minus_bitpos (rtx ref
>    struct mem_attrs attrs, *defattrs, *refattrs;
>    addr_space_t as;
>  
> +  if (!optimize)
> +    return;
> +
>    /* It can happen that type_for_mode was given a mode for which there
>       is no language-level type.  In which case it returns NULL, which
>       we can see here.  */
> 
>
Jan Hubicka Dec. 1, 2015, 6:39 p.m. UTC | #2
> On Tue, 1 Dec 2015, Jan Hubicka wrote:
> 
> > Hi,
> > memory attributes are currently optimized and attached to RTL even when not
> > optimizing. This is obviously just a wasted effort.
> 
> Huh, are you sure?  What about globals used from different optimize
> contexts?

Hmm, you are right - we will get worse code quality.  The code won't ICE
because MEM_ATTRS can legally be NULL - get_mem_attrs will then supply default
one for given mode, but we will miss code quality.  I will look into disabling
mem attrs for non-globals only.

It would be nice to get rid of those global persistent RTLs (and make DECL_RTL
to be function local hash)

Honza
diff mbox

Patch

Index: emit-rtl.c
===================================================================
--- emit-rtl.c	(revision 231081)
+++ emit-rtl.c	(working copy)
@@ -336,7 +336,8 @@  static void
 set_mem_attrs (rtx mem, mem_attrs *attrs)
 {
   /* If everything is the default, we can just clear the attributes.  */
-  if (mem_attrs_eq_p (attrs, mode_mem_attrs[(int) GET_MODE (mem)]))
+  if (!optimize
+      || mem_attrs_eq_p (attrs, mode_mem_attrs[(int) GET_MODE (mem)]))
     {
       MEM_ATTRS (mem) = 0;
       return;
@@ -1749,6 +1750,9 @@  set_mem_attributes_minus_bitpos (rtx ref
   struct mem_attrs attrs, *defattrs, *refattrs;
   addr_space_t as;
 
+  if (!optimize)
+    return;
+
   /* It can happen that type_for_mode was given a mode for which there
      is no language-level type.  In which case it returns NULL, which
      we can see here.  */