Add an AlignmentFromAssumptions Pass
authorHal Finkel <hfinkel@anl.gov>
Sun, 7 Sep 2014 20:05:11 +0000 (20:05 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sun, 7 Sep 2014 20:05:11 +0000 (20:05 +0000)
commit1d6c2d717d74eccc866d9a62b1631a265ef795fc
treec95cd4b02e7f8e74fe793117b1db60029b3af753
parent83d886db3a268b42eaac9988ee7e5f4af6c1a37e
Add an AlignmentFromAssumptions Pass

This adds a ScalarEvolution-powered transformation that updates load, store and
memory intrinsic pointer alignments based on invariant((a+q) & b == 0)
expressions. Many of the simple cases we can get with ValueTracking, but we
still need something like this for the more complicated cases (such as those
with an offset) that require some algebra. Note that gcc's
__builtin_assume_aligned's optional third argument provides exactly for this
kind of 'misalignment' offset for which this kind of logic is necessary.

The primary motivation is to fixup alignments for vector loads/stores after
vectorization (and unrolling). This pass is added to the optimization pipeline
just after the SLP vectorizer runs (which, admittedly, does not preserve SE,
although I imagine it could).  Regardless, I actually don't think that the
preservation matters too much in this case: SE computes lazily, and this pass
won't issue any SE queries unless there are any assume intrinsics, so there
should be no real additional cost in the common case (SLP does preserve DT and
LoopInfo).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217344 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm-c/Transforms/Scalar.h
include/llvm/InitializePasses.h
include/llvm/LinkAllPasses.h
include/llvm/Transforms/Scalar.h
lib/Transforms/IPO/PassManagerBuilder.cpp
lib/Transforms/Scalar/AlignmentFromAssumptions.cpp [new file with mode: 0644]
lib/Transforms/Scalar/CMakeLists.txt
lib/Transforms/Scalar/Scalar.cpp
test/Transforms/AlignmentFromAssumptions/simple.ll [new file with mode: 0644]