Index: include/polly/ScopInfo.h =================================================================== --- include/polly/ScopInfo.h +++ include/polly/ScopInfo.h @@ -238,8 +238,25 @@ /// @brief Is this a write memory access? bool isWrite() const { return isMustWrite() || isMayWrite(); } + /// @brief Get the original access function as read from IR. isl_map *getAccessRelation() const; + /// @brief Get the new access function imported or set by a pass + isl_map *getNewAccessRelation() const; + + /// @brief Check if a new access relation was imported or set. + bool hasNewAccessRelation() const { return newAccessRelation; } + + /// @brief Return the newset access relation known to this access. + isl_map *getNewestAccessRelation() const { + return hasNewAccessRelation() ? getNewAccessRelation() + : getAccessRelation(); + } + + /// @brief Return the access relation after the schedule was applied. + __isl_give isl_pw_multi_aff * + applyScheduleToAccessRelation(__isl_keep isl_union_map *Schedule) const; + /// @brief Return the space in which the access relation lives in. __isl_give isl_space *getAccessRelationSpace() const; @@ -266,9 +283,6 @@ /// @brief Return the access instruction of this memory access. Instruction *getAccessInstruction() const { return Inst; } - /// @brief Get the new access function imported from JSCOP file - isl_map *getNewAccessRelation() const; - /// Get the stride of this memory access in the specified Schedule. Schedule /// is a map from the statement to a schedule where the innermost dimension is /// the dimension of the innermost loop containing the statement. Index: lib/Analysis/ScopInfo.cpp =================================================================== --- lib/Analysis/ScopInfo.cpp +++ lib/Analysis/ScopInfo.cpp @@ -397,6 +397,18 @@ return isl_map_get_tuple_id(AccessRelation, isl_dim_out); } +isl_pw_multi_aff * +MemoryAccess::applyScheduleToAccessRelation(isl_union_map *USchedule) const { + isl_map *Schedule, *ScheduledAccRel; + isl_union_set *UDomain; + + UDomain = isl_union_set_from_set(getStatement()->getDomain()); + USchedule = isl_union_map_intersect_domain(USchedule, UDomain); + Schedule = isl_map_from_union_map(USchedule); + ScheduledAccRel = isl_map_apply_domain(getNewestAccessRelation(), Schedule); + return isl_pw_multi_aff_from_map(ScheduledAccRel); +} + isl_map *MemoryAccess::getAccessRelation() const { return isl_map_copy(AccessRelation); } @@ -618,9 +630,7 @@ isl_set *MemoryAccess::getStride(__isl_take const isl_map *Schedule) const { isl_map *S = const_cast(Schedule); - isl_map *AccessRelation = getNewAccessRelation(); - if (!AccessRelation) - AccessRelation = getAccessRelation(); + isl_map *AccessRelation = getNewestAccessRelation(); isl_space *Space = isl_space_range(isl_map_get_space(S)); isl_map *NextScatt = getEqualAndLarger(Space); Index: lib/CodeGen/BlockGenerators.cpp =================================================================== --- lib/CodeGen/BlockGenerators.cpp +++ lib/CodeGen/BlockGenerators.cpp @@ -165,25 +165,15 @@ } Value *BlockGenerator::getNewAccessOperand(const MemoryAccess &MA) { - isl_pw_multi_aff *PWSchedule, *PWAccRel; - isl_union_map *ScheduleU; - isl_map *Schedule, *AccRel; + isl_pw_multi_aff *PWAccRel; + isl_union_map *Schedule; isl_ast_expr *Expr; assert(ExprBuilder && Build && "Cannot generate new value without IslExprBuilder!"); - AccRel = MA.getNewAccessRelation(); - assert(AccRel && "We generate new code only for new access relations!"); - - ScheduleU = isl_ast_build_get_schedule(Build); - ScheduleU = isl_union_map_intersect_domain( - ScheduleU, isl_union_set_from_set(MA.getStatement()->getDomain())); - Schedule = isl_map_from_union_map(ScheduleU); - - PWSchedule = isl_pw_multi_aff_from_map(isl_map_reverse(Schedule)); - PWAccRel = isl_pw_multi_aff_from_map(AccRel); - PWAccRel = isl_pw_multi_aff_pullback_pw_multi_aff(PWAccRel, PWSchedule); + Schedule = isl_ast_build_get_schedule(Build); + PWAccRel = MA.applyScheduleToAccessRelation(Schedule); Expr = isl_ast_build_access_from_pw_multi_aff(Build, PWAccRel); Expr = isl_ast_expr_address_of(Expr); @@ -197,16 +187,14 @@ ValueMapT &GlobalMap, LoopToScevMapT <S) { const MemoryAccess &MA = Statement.getAccessFor(Inst); - isl_map *NewAccRel = MA.getNewAccessRelation(); Value *NewPointer; - if (NewAccRel) + if (MA.hasNewAccessRelation()) NewPointer = getNewAccessOperand(MA); else NewPointer = getNewValue(Pointer, BBMap, GlobalMap, LTS, getLoopForInst(Inst)); - isl_map_free(NewAccRel); return NewPointer; }