This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix the one entry mem{{,p}cpy,move,set} optimization aliasing issues (PR middle-end/29272)


On Sun, Oct 08, 2006 at 10:47:14PM -0700, Mark Mitchell wrote:
> >+  /* If var is a VAR_DECL or a component thereof,
> >+     we can use its alias set, otherwise we'd need to make
> >+     sure we go through alias set 0.  */
> >+  inner = var;
> >+  while (handled_component_p (inner))
> >+    inner = TREE_OPERAND (inner, 0);
> >+  if (! SSA_VAR_P (inner))
> >+    return 0;
> 
> This predicate should be factored out as a function, so that we avoid 
> code duplication.

Will do.

>  It looks like your solution means that we're not 
> going to use an inline block copy (and will instead call the libc 
> version of memset) for cases like those in your testcase.

No, the normal inline memcpy etc. will be used if the function returns
here 0.  Before my patch, fold_builtin_memory_op predecessors
would always return 0 unless the length was 0 or src identical to dest,
all that means is that it isn't folded at tree opt time and stays
as __builtin_memcpy (dest, src, len) call until expand, at which point
expand_builtin_memcpy does its job.

> However, I think that Ian's suggesting that we don't need to be so 
> conservative.  Ian, am I following correctly?

The problem is that the tree optimizers often optimize the ref_all types
out.  Last mail on this was Eric suggesting to put the REF_ALL on
the inner pointer rather than outer, if that results in alias set
0 on the access, that surely could help in some cases to not loose
that REF_ALL types, but I don't see what e.g. prevents the optimization
to be done when we have
  p = &q->t;
  ...
  p0 = (ref_all) p; /* These two stmts come from __builtin_memcpy folding.  */
  p0->s = x; 
and later on some other pass notices that p is &q->t and optimizes
that into q->t.s = x; the same way how my attempt
  p0 = (ref_all) &p->s;
  *p0 = x;
was optimized into p->s = x; 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]