]> granicus.if.org Git - clang/commit
Emit @llvm.assume for non-parameter lvalue align_value-attribute loads
authorHal Finkel <hfinkel@anl.gov>
Sat, 4 Oct 2014 15:26:49 +0000 (15:26 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sat, 4 Oct 2014 15:26:49 +0000 (15:26 +0000)
commit8a079ddb3cad125c0f67679e534aec53e161c7e3
tree30ddebfcb8dc8b9f7c8f37c7a14e85b987132662
parent107c30e2395b1e3bd1584b134f5b9ef7bc352895
Emit @llvm.assume for non-parameter lvalue align_value-attribute loads

We already add the align parameter attribute for function parameters that have
the align_value attribute (or those with a typedef type having that attribute),
which is an important special case, but does not handle pointers with value
alignment assumptions that come into scope in any other way. To handle the
general case, emit an @llvm.assume-based alignment assumption whenever we load
the pointer-typed lvalue of an align_value-attributed variable (except for
function parameters, which we already deal with at entry).

I'll also note that this is more general than Intel's described support in:
  https://software.intel.com/en-us/articles/data-alignment-to-assist-vectorization
which states that the compiler inserts __assume_aligned directives in response
to align_value-attributed variables only for function parameters and for the
initializers of local variables. I think that we can make the optimizer deal
with this more-general scheme (which could lead to a lot of calls to
@llvm.assume inside of loop bodies, for example), but if not, I'll rework this
to be less aggressive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219052 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGExprScalar.cpp
test/CodeGen/align_value.cpp