public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* No TBAA before ptr_derefs_may_alias_p?
@ 2014-01-31 15:24 Bingfeng Mei
  2014-01-31 15:27 ` Richard Biener
  0 siblings, 1 reply; 16+ messages in thread
From: Bingfeng Mei @ 2014-01-31 15:24 UTC (permalink / raw)
  To: gcc, Richard Biener

Hi,
I got this simple example to vectorize. Somehow, GCC (4.8) generates loop version because
it cannot determine alias between acc[i] write and x[i].real read. It is pretty obvious to me that they are not aliased based on TBAA information.

typedef struct
{
   short real;
   short imag;
} complex16_t;

void
libvector_AccSquareNorm_ref (unsigned long long  *acc,
                             const complex16_t *x, unsigned len)
{
    for (unsigned i = 0; i < len; i++)
    {
        acc[i] +=
            ((unsigned long long)((int)x[i].real * x[i].real)) +
            ((unsigned long long)((int)x[i].imag * x[i].imag));
    }
}

Tracing into how the alias information is calculated, I found it hits the following code
by calling ptr_derefs_may_alias_p and return true. ptr_derefs_may_alias_p doesn't contain
TBAA disambiguation code. Should we add check before that? 

  /* If we had an evolution in a MEM_REF BASE_OBJECT we do not know
     the size of the base-object.  So we cannot do any offset/overlap
     based analysis but have to rely on points-to information only.  */
  if (TREE_CODE (addr_a) == MEM_REF
      && DR_UNCONSTRAINED_BASE (a))
    {
      if (TREE_CODE (addr_b) == MEM_REF
	  && DR_UNCONSTRAINED_BASE (b))
	return ptr_derefs_may_alias_p (TREE_OPERAND (addr_a, 0),
				       TREE_OPERAND (addr_b, 0));
      else
	return ptr_derefs_may_alias_p (TREE_OPERAND (addr_a, 0),
				       build_fold_addr_expr (addr_b));
    }
  else if (TREE_CODE (addr_b) == MEM_REF
	   && DR_UNCONSTRAINED_BASE (b))
    return ptr_derefs_may_alias_p (build_fold_addr_expr (addr_a),
				   TREE_OPERAND (addr_b, 0));

  /* Otherwise DR_BASE_OBJECT is an access that covers the whole object
     that is being subsetted in the loop nest.  */
  if (DR_IS_WRITE (a) && DR_IS_WRITE (b))
    return refs_output_dependent_p (addr_a, addr_b);
  else if (DR_IS_READ (a) && DR_IS_WRITE (b))
    return refs_anti_dependent_p (addr_a, addr_b);
  return refs_may_alias_p (addr_a, addr_b);

This issue can be reproduced on trunk x86-64 gcc. 

Cheers,
Bingfeng Mei

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

end of thread, other threads:[~2014-02-03 14:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-31 15:24 No TBAA before ptr_derefs_may_alias_p? Bingfeng Mei
2014-01-31 15:27 ` Richard Biener
2014-01-31 17:01   ` Bingfeng Mei
2014-01-31 17:18   ` Bingfeng Mei
2014-01-31 21:32     ` Richard Biener
2014-02-03  9:51       ` Bingfeng Mei
2014-02-03  9:59         ` Jakub Jelinek
2014-02-03 10:14           ` Florian Weimer
2014-02-03 10:19             ` Richard Biener
2014-02-03 11:49               ` Bingfeng Mei
2014-02-03 13:17                 ` Richard Biener
2014-02-03 14:43                   ` Bingfeng Mei
2014-02-03 14:45                     ` Richard Biener
2014-02-03 10:15           ` Richard Biener
2014-02-03 10:36             ` Richard Biener
2014-02-03 11:58               ` Bingfeng Mei

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