[PATCH] D16878: Support accesses with differently sized types to the same array
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 4 02:09:40 PST 2016
grosser created this revision.
grosser added reviewers: jdoerfert, Meinersbur.
grosser added subscribers: llvm-commits, pollydev.
This allows code such as:
void multiple_types(char *Short, char *Float, char *Double) {
for (long i = 0; i < 100; i++) {
Short[i] = *(short *)&Short[2 * i];
Float[i] = *(float *)&Float[4 * i];
Double[i] = *(double *)&Double[8 * i];
}
}
To model such code we use as canonical element type of the modeled array the
smallest element type of all original array accesses, if type allocation sizes
are multiples of each other. Otherwise, we use a newly created iN type, where N
is the gcd of the allocation size of the types used in the accesses to this
array. Accesses with types larger as the canonical element type are modeled as
multiple accesses with the smaller type.
For example the second load access is modeled as:
{ Stmt_bb2[i0] -> MemRef_Float[o0] : 4i0 <= o0 <= 3 + 4i0 }
To support code-generating these memory accesses, we introduce a new method
getAccessAddressFunction that assigns each statement instance a single memory
location, the address we load from/store to. Currently we obtain this address by
taking the lexmin of the access function. We may consider keeping track of the
memory location more explicitly in the future.
We currently do _not_ handle multi-dimensional arrays as well as unaligned
accesses with element types of different size. This patch adds tests that ensure
we correctly invalidate a scop in case these accesses are found. Both types of
accesses can be handled using the very same model, but are left to be added in
the future.
We also move the initialization of the scop-context into the constructor to
ensure it is already available when invalidating the scop.
http://reviews.llvm.org/D16878
Files:
include/polly/ScopDetectionDiagnostic.h
include/polly/ScopInfo.h
include/polly/Support/ScopHelper.h
lib/Analysis/ScopDetection.cpp
lib/Analysis/ScopDetectionDiagnostic.cpp
lib/Analysis/ScopInfo.cpp
lib/CodeGen/BlockGenerators.cpp
lib/CodeGen/IslNodeBuilder.cpp
test/Isl/CodeGen/MemAccess/multiple_types.ll
test/Isl/CodeGen/MemAccess/multiple_types___%bb1---%bb22.jscop
test/Isl/CodeGen/multiple-types-invariant-load.ll
test/ScopDetectionDiagnostics/ReportDifferentElementSize.ll
test/ScopInfo/multiple-types-non-power-of-two-2.ll
test/ScopInfo/multiple-types-non-power-of-two.ll
test/ScopInfo/multiple-types-two-dimensional-2.ll
test/ScopInfo/multiple-types-two-dimensional.ll
test/ScopInfo/multiple-types-unaligned.ll
test/ScopInfo/multiple-types.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16878.46885.patch
Type: text/x-patch
Size: 45281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160204/01b27b9d/attachment.bin>
More information about the llvm-commits
mailing list