public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Strip NOP_EXPR before building MEM
@ 2016-08-28 17:59 Jan Hubicka
  2016-08-30 10:25 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Hubicka @ 2016-08-28 17:59 UTC (permalink / raw)
  To: gcc-patches

Hi,
I have noticed that ivopts build MEM_REF (NOP_EXPR (address))
where NOP_EXPR converts one pointer type to another.  Later it tries
to expand it that on strict alignment targets punt on determining
the alignment and winds expensive memory reference.

It seems to make no sense to have NOP_EXPR here, but in addition
I think we want to somehow preserve alignment from original MEM_REF?

Honza

	* tree-ssa-lop-ivopts.c (get_computation_cost_at):
	strip nops before building mem ref
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 62ba71b..bd92031 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -5058,7 +5058,10 @@ fallback:
     return infinite_cost;
 
   if (address_p)
-    comp = build_simple_mem_ref (comp);
+    {
+      STRIP_NOPS (comp);
+      comp = build_simple_mem_ref (comp);
+    }
 
   cost = comp_cost (computation_cost (comp, speed), 0);
 

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

* Re: Strip NOP_EXPR before building MEM
  2016-08-28 17:59 Strip NOP_EXPR before building MEM Jan Hubicka
@ 2016-08-30 10:25 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2016-08-30 10:25 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: GCC Patches

On Sun, Aug 28, 2016 at 7:59 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> I have noticed that ivopts build MEM_REF (NOP_EXPR (address))
> where NOP_EXPR converts one pointer type to another.  Later it tries
> to expand it that on strict alignment targets punt on determining
> the alignment and winds expensive memory reference.
>
> It seems to make no sense to have NOP_EXPR here, but in addition
> I think we want to somehow preserve alignment from original MEM_REF?

As you noticed the type carries semantics thus if you want to fix it this
way then you need to make build_simple_mem_ref strip the nops _after_
remembering the type to use for the MEM_REF (and the aliasing).

After all you are changing *(int *)&large-struct to *&large-struct with
your patch - certainly not what you intended?

Sth like

@@ -4618,6 +4623,7 @@ build_simple_mem_ref_loc (location_t loc
   HOST_WIDE_INT offset = 0;
   tree ptype = TREE_TYPE (ptr);
   tree tem;
+  STRIP_NOPS (ptr);
   /* For convenience allow addresses that collapse to a simple base
      and offset.  */
   if (TREE_CODE (ptr) == ADDR_EXPR


Richard.

> Honza
>
>         * tree-ssa-lop-ivopts.c (get_computation_cost_at):
>         strip nops before building mem ref
> diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
> index 62ba71b..bd92031 100644
> --- a/gcc/tree-ssa-loop-ivopts.c
> +++ b/gcc/tree-ssa-loop-ivopts.c
> @@ -5058,7 +5058,10 @@ fallback:
>      return infinite_cost;
>
>    if (address_p)
> -    comp = build_simple_mem_ref (comp);
> +    {
> +      STRIP_NOPS (comp);
> +      comp = build_simple_mem_ref (comp);
> +    }
>
>    cost = comp_cost (computation_cost (comp, speed), 0);
>

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

end of thread, other threads:[~2016-08-30 10:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-28 17:59 Strip NOP_EXPR before building MEM Jan Hubicka
2016-08-30 10:25 ` Richard Biener

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