[LoopVectorize] Annotate versioned loop with noalias metadata
authorAdam Nemet <anemet@apple.com>
Thu, 17 Mar 2016 20:32:37 +0000 (20:32 +0000)
committerAdam Nemet <anemet@apple.com>
Thu, 17 Mar 2016 20:32:37 +0000 (20:32 +0000)
commitb0c4eae07339dce7d0d6e7e697fba37b41cb28cf
tree1efa158666c93c6a61aaaf66008bd36863fb5e2a
parent5eccf07df359955e5dd378bd886c1cfaee5e11f3
[LoopVectorize] Annotate versioned loop with noalias metadata

Summary:
Use the new LoopVersioning facility (D16712) to add noalias metadata in
the vector loop if we versioned with memchecks.  This can enable some
optimization opportunities further down the pipeline (see the included
test or the benchmark improvement quoted in D16712).

The test also covers the bug I had in the initial version in D16712.

The vectorizer did not previously use LoopVersioning.  The reason is
that the vectorizer performs its transformations in single shot.  It
creates an empty single-block vector loop that it then populates with
the widened, if-converted instructions.  Thus creating an intermediate
versioned scalar loop seems wasteful.

So this patch (rather than bringing in LoopVersioning fully) adds a
special interface to LoopVersioning to allow the vectorizer to add
no-alias annotation while still performing its own versioning.

As the vectorizer propagates metadata from the instructions in the
original loop to the vector instructions we also check the pointer in
the original instruction and see if LoopVersioning can add no-alias
metadata based on the issued memchecks.

Reviewers: hfinkel, nadav, mzolotukhin

Subscribers: mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D17191

llvm-svn: 263744
llvm/include/llvm/Transforms/Utils/LoopVersioning.h
llvm/lib/Transforms/Utils/LoopVersioning.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/noalias-md-licm.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/noalias-md.ll [new file with mode: 0644]