[LLVMdev] strict aliasing and LLVM

Xinliang David Li xinliangli at gmail.com
Thu Oct 28 22:35:42 PDT 2010


As simple as

void foo (int n, double *p, int *q)
{
   for (int i = 0; i < n; i++)
     *p += *q;
}

clang -O2 -fstrict-aliasing -emit-llvm -o foo.bc -c foo.c
llc -enable-tbaa -O2 -filetype=asm -o foo.s foo.bc

Memory accesses remain in the loop.

The following works fine:

void foo(int n, double *restrict p, int * restrict *q)
{
  ...
}

By the way, Is there a performance category in the llvm bug database?

Thanks,

David

On Thu, Oct 28, 2010 at 5:59 PM, Dan Gohman <gohman at apple.com> wrote:

>
> On Oct 28, 2010, at 2:43 PM, Xinliang David Li wrote:
>
> >
> >
> > 2010/10/27 Rafael EspĂ­ndola <rafael.espindola at gmail.com>
> > 2010/10/27 Xinliang David Li <xinliangli at gmail.com>:
> > > Thanks. Just built clang and saw the meta data and annotations on the
> memory
> > > accesses --  is any opt pass consuming the information?
> >
> > The tests in test/Analysis/TypeBasedAliasAnalysis suggest that at
> > least licm is using it. Also note that
> > lib/Analysis/TypeBasedAliasAnalysis.cpp defines as enable-tbaa option
> > that is off by default.
>
> LICM, GVN, and DSE are the major consumers right now. That said, the
> current TBAA implementation is not very advanced yet.
>
> > I tried the option -- no much differences in the generated code.
>
> Can you give an example of code you'd expect to be optimized which isn't?
>
> Dan
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101028/d688e25b/attachment.html>


More information about the llvm-dev mailing list