diff options
| author | Sebastian Pop <spop@codeaurora.org> | 2014-04-08 21:20:44 +0000 |
|---|---|---|
| committer | Sebastian Pop <spop@codeaurora.org> | 2014-04-08 21:20:44 +0000 |
| commit | 1801668af3cbc51a1f8bab552f3896eb30268cfa (patch) | |
| tree | 602a155dd8b0c5f665c69eb1ebb73cd8bf1b329e /polly/lib/Analysis/ScopInfo.cpp | |
| parent | 0a31e042195765e7ac48f6f96e891348354ef2dd (diff) | |
| download | bcm5719-llvm-1801668af3cbc51a1f8bab552f3896eb30268cfa.tar.gz bcm5719-llvm-1801668af3cbc51a1f8bab552f3896eb30268cfa.zip | |
delinearize memory access functions
llvm-svn: 205799
Diffstat (limited to 'polly/lib/Analysis/ScopInfo.cpp')
| -rw-r--r-- | polly/lib/Analysis/ScopInfo.cpp | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/polly/lib/Analysis/ScopInfo.cpp b/polly/lib/Analysis/ScopInfo.cpp index fe8bafe8b91..245d68311ef 100644 --- a/polly/lib/Analysis/ScopInfo.cpp +++ b/polly/lib/Analysis/ScopInfo.cpp @@ -337,21 +337,37 @@ MemoryAccess::MemoryAccess(const IRAccess &Access, const Instruction *AccInst, Type = Access.isRead() ? READ : MUST_WRITE; - isl_pw_aff *Affine = SCEVAffinator::getPwAff(Statement, Access.getOffset()); + int Size = Access.Subscripts.size(); + assert(Size > 0 && "access function with no subscripts"); + AccessRelation = NULL; + + for (int i = 0; i < Size; ++i) { + isl_pw_aff *Affine = + SCEVAffinator::getPwAff(Statement, Access.Subscripts[i]); + + if (i == Size - 1) { + // Divide the access function of the last subscript by the size of the + // elements in the array. + // + // A stride one array access in C expressed as A[i] is expressed in + // LLVM-IR as something like A[i * elementsize]. This hides the fact that + // two subsequent values of 'i' index two values that are stored next to + // each other in memory. By this division we make this characteristic + // obvious again. + isl_val *v; + v = isl_val_int_from_si(isl_pw_aff_get_ctx(Affine), + Access.getElemSizeInBytes()); + Affine = isl_pw_aff_scale_down_val(Affine, v); + } - // Divide the access function by the size of the elements in the array. - // - // A stride one array access in C expressed as A[i] is expressed in LLVM-IR - // as something like A[i * elementsize]. This hides the fact that two - // subsequent values of 'i' index two values that are stored next to each - // other in memory. By this division we make this characteristic obvious - // again. - isl_val *v; - v = isl_val_int_from_si(isl_pw_aff_get_ctx(Affine), - Access.getElemSizeInBytes()); - Affine = isl_pw_aff_scale_down_val(Affine, v); + isl_map *SubscriptMap = isl_map_from_pw_aff(Affine); + + if (!AccessRelation) + AccessRelation = SubscriptMap; + else + AccessRelation = isl_map_flat_range_product(AccessRelation, SubscriptMap); + } - AccessRelation = isl_map_from_pw_aff(Affine); isl_space *Space = Statement->getDomainSpace(); AccessRelation = isl_map_set_tuple_id( AccessRelation, isl_dim_in, isl_space_get_tuple_id(Space, isl_dim_set)); |

