[llvm-branch-commits] [polly] r246029 - Only use instructions as insert locations for SCEVExpander
Author: grosser Date: Wed Aug 26 06:01:14 2015 New Revision: 246029 URL: http://llvm.org/viewvc/llvm-project?rev=246029&view=rev Log: Only use instructions as insert locations for SCEVExpander SCEVExpander, which we are using during code generation, only allows instructions as insert locations, but breaks in case BasicBlock->end() iterators are passed to it due to it trying to obtain the basic block in which code should be generated by calling Instruction->getParent(), which is not defined for ->end() iterators. This change adds an assert to Polly that ensures we only pass valid instructions to SCEVExpander and it fixes one case, where we used IRBuilder->SetInsertBlock() to set an ->end() insert location which was later passed to SCEVExpander. In general, Polly is always trying to build up the CFG first, before we actually insert instructions into the CFG sceleton. As a result, each basic block should already have at least one branch instruction before we start adding code. Hence, always requiring the IRBuilder insert location to be set to a real instruction should always be possible. Thanks Utpal Bora for his help with test case reduction. This is a backport from r243830 as it was committed on trunk. Added: polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll Modified: polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp Modified: polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp?rev=246029&r1=246028&r2=246029&view=diff == --- polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp (original) +++ polly/branches/release_37/lib/CodeGen/BlockGenerators.cpp Wed Aug 26 06:01:14 2015 @@ -123,6 +123,8 @@ Value *BlockGenerator::getNewValue(ScopS ->getParent() ->getDataLayout(), "polly"); +assert(Builder.GetInsertPoint() != Builder.GetInsertBlock()->end() && + "Only instructions can be insert points for SCEVExpander"); Value *Expanded = Expander.expandCodeFor(NewScev, Old->getType(), Builder.GetInsertPoint()); @@ -1116,7 +1118,7 @@ void RegionGenerator::copyStmt(ScopStmt ValueMapT &RegionMap = RegionMaps[BBCopy]; RegionMap.insert(BlockMap.begin(), BlockMap.end()); -Builder.SetInsertPoint(BBCopy); +Builder.SetInsertPoint(BICopy); copyInstScalar(Stmt, BI, RegionMap, GlobalMap, LTS); BICopy->eraseFromParent(); } Added: polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll?rev=246029&view=auto == --- polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll (added) +++ polly/branches/release_37/test/Isl/CodeGen/non-affine-phi-node-expansion.ll Wed Aug 26 06:01:14 2015 @@ -0,0 +1,54 @@ +; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +%struct.wombat = type {[4 x i32]} + +; CHECK: polly.stmt.bb3.entry: ; preds = %polly.start +; CHECK: br label %polly.stmt.bb3 + +; CHECK: polly.stmt.bb3: ; preds = %polly.stmt.bb3.entry +; CHECK: %polly.subregion.iv = phi i32 [ 0, %polly.stmt.bb3.entry ] +; CHECK: %polly.subregion.iv.inc = add i32 %polly.subregion.iv, 1 +; CHECK: br i1 true, label %polly.stmt.bb4, label %polly.stmt.bb5 + +; CHECK: polly.stmt.bb4: ; preds = %polly.stmt.bb3 +; CHECK: br label %polly.stmt.bb13.exit + +; CHECK: polly.stmt.bb5: ; preds = %polly.stmt.bb3 +; CHECK: %tmp7_p_scalar_ = load i32, i32* %B, !alias.scope !0, !noalias !2 +; CHECK: store i32 %tmp7_p_scalar_, i32* %polly.access.cast.arg2, !alias.scope !3, !noalias !4 +; CHECK: br label %polly.stmt.bb13.exit + +; Function Attrs: nounwind uwtable +define void @quux(%struct.wombat* %arg, i32* %B) { +bb: + br i1 undef, label %bb2, label %bb1 + +bb1: ; preds = %bb + br label %bb2 + +bb2: ; preds = %bb1, %bb + %tmp = phi i1 [ true, %bb ], [ undef, %bb1 ] + br label %bb3 + +bb3: ; preds = %bb13, %bb2 + br i1 %tmp, label %bb4, label %bb5 + +bb4: ; preds = %bb3 + br label %bb13 + +bb5: ; preds = %bb3 + %tmp7 = load i32, i32* %B + %tmp12 = getelementptr inbounds %struct.wombat, %struct.wombat* %arg, i64 0, i32 0, i64 0 + store i32
[llvm-branch-commits] [polly] r259694 - Merging: https://llvm.org/svn/llvm-project/polly/trunk@259659
Author: grosser Date: Wed Feb 3 15:12:05 2016 New Revision: 259694 URL: http://llvm.org/viewvc/llvm-project?rev=259694&view=rev Log: Merging: https://llvm.org/svn/llvm-project/polly/trunk@259659 roperly build shared libraries if LLVM_LINK_LLVM_DYLIB is enabled. Contributed-by: Jack Howarth Modified: polly/branches/release_38/lib/CMakeLists.txt Modified: polly/branches/release_38/lib/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/CMakeLists.txt?rev=259694&r1=259693&r2=259694&view=diff == --- polly/branches/release_38/lib/CMakeLists.txt (original) +++ polly/branches/release_38/lib/CMakeLists.txt Wed Feb 3 15:12:05 2016 @@ -77,6 +77,13 @@ if (BUILD_SHARED_LIBS) link_directories( ${LLVM_LIBRARY_DIR} ) +elseif (LLVM_LINK_LLVM_DYLIB) + target_link_libraries(Polly +LLVM + ) + link_directories( +${LLVM_LIBRARY_DIR} + ) endif() # Build a monolithic Polly.a and a thin module LLVMPolly.moduleext that links to ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r259707 - Merged: https://llvm.org/svn/llvm-project/polly/trunk@259337
Author: grosser Date: Wed Feb 3 15:42:58 2016 New Revision: 259707 URL: http://llvm.org/viewvc/llvm-project?rev=259707&view=rev Log: Merged: https://llvm.org/svn/llvm-project/polly/trunk@259337 ScopInfo: use std::distance to shorten code [NFC] Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/Analysis/ScopInfo.cpp?rev=259707&r1=259706&r2=259707&view=diff == --- polly/branches/release_38/lib/Analysis/ScopInfo.cpp (original) +++ polly/branches/release_38/lib/Analysis/ScopInfo.cpp Wed Feb 3 15:42:58 2016 @@ -1966,13 +1966,8 @@ static inline unsigned getNumBlocksInReg if (!RN->isSubRegion()) return 1; - unsigned NumBlocks = 0; Region *R = RN->getNodeAs(); - for (auto BB : R->blocks()) { -(void)BB; -NumBlocks++; - } - return NumBlocks; + return std::distance(R->block_begin(), R->block_end()); } static bool containsErrorBlock(RegionNode *RN, const Region &R, LoopInfo &LI, ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r259706 - Merged: https://llvm.org/svn/llvm-project/polly/trunk@258632
Author: grosser Date: Wed Feb 3 15:42:56 2016 New Revision: 259706 URL: http://llvm.org/viewvc/llvm-project?rev=259706&view=rev Log: Merged: https://llvm.org/svn/llvm-project/polly/trunk@258632 ScopInfo: Simplify code by folding definition into if Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/Analysis/ScopInfo.cpp?rev=259706&r1=259705&r2=259706&view=diff == --- polly/branches/release_38/lib/Analysis/ScopInfo.cpp (original) +++ polly/branches/release_38/lib/Analysis/ScopInfo.cpp Wed Feb 3 15:42:56 2016 @@ -3458,8 +3458,7 @@ void Scop::buildSchedule( auto &LSchedulePair = LoopSchedules[L]; LSchedulePair.second += getNumBlocksInRegionNode(RN); - ScopStmt *Stmt = getStmtForRegionNode(RN); - if (Stmt) { + if (auto *Stmt = getStmtForRegionNode(RN)) { auto *UDomain = isl_union_set_from_set(Stmt->getDomain()); auto *StmtSchedule = isl_schedule_from_domain(UDomain); LSchedulePair.first = combineInSequence(LSchedulePair.first, StmtSchedule); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r259708 - Merged: https://llvm.org/svn/llvm-project/polly/trunk@259347
Author: grosser Date: Wed Feb 3 15:43:01 2016 New Revision: 259708 URL: http://llvm.org/viewvc/llvm-project?rev=259708&view=rev Log: Merged: https://llvm.org/svn/llvm-project/polly/trunk@259347 ScopInfo: Drop dead code in schedule description In https://llvm.org/svn/llvm-project/polly/trunk@251870 code was committed to avoid a failure in the presence of infinite loops, but the test case committed along with this change passes without the actual change. I looked back into the code and also checked with the original committer (Johannes), but could not find the reason why the code is needed. The introduction of LoopStacks for buildSchedule in one of the next commits will make it even more clear that this code is not needed, but I remove this ahead of time to facilitate bisecting in case I missed something. Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/Analysis/ScopInfo.cpp?rev=259708&r1=259707&r2=259708&view=diff == --- polly/branches/release_38/lib/Analysis/ScopInfo.cpp (original) +++ polly/branches/release_38/lib/Analysis/ScopInfo.cpp Wed Feb 3 15:43:01 2016 @@ -3464,15 +3464,6 @@ void Scop::buildSchedule( while (L && NumVisited == L->getNumBlocks()) { auto *PL = L->getParentLoop(); -// Either we have a proper loop and we also build a schedule for the -// parent loop or we have a infinite loop that does not have a proper -// parent loop. In the former case this conditional will be skipped, in -// the latter case however we will break here as we do not build a domain -// nor a schedule for a infinite loop. -assert(LoopSchedules.count(PL) || LSchedule == nullptr); -if (!LoopSchedules.count(PL)) - break; - auto &PSchedulePair = LoopSchedules[PL]; if (LSchedule) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r259711 - Merged: https://llvm.org/svn/llvm-project/polly/trunk@258803
Author: grosser Date: Wed Feb 3 15:43:14 2016 New Revision: 259711 URL: http://llvm.org/viewvc/llvm-project?rev=259711&view=rev Log: Merged: https://llvm.org/svn/llvm-project/polly/trunk@258803 [FIX] Domain generation error due to loops in non-affine regions Added: polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop-2.ll Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/Analysis/ScopInfo.cpp?rev=259711&r1=259710&r2=259711&view=diff == --- polly/branches/release_38/lib/Analysis/ScopInfo.cpp (original) +++ polly/branches/release_38/lib/Analysis/ScopInfo.cpp Wed Feb 3 15:43:14 2016 @@ -2066,7 +2066,7 @@ void Scop::buildDomains(Region *R) { } void Scop::buildDomainsWithBranchConstraints(Region *R) { - RegionInfo &RI = *R->getRegionInfo(); + auto &BoxedLoops = *SD.getBoxedLoops(&getRegion()); // To create the domain for each block in R we iterate over all blocks and // subregions in R and propagate the conditions under which the current region @@ -2141,10 +2141,8 @@ void Scop::buildDomainsWithBranchConstra // Do not adjust the number of dimensions if we enter a boxed loop or are // in a non-affine subregion or if the surrounding loop stays the same. Loop *SuccBBLoop = LI.getLoopFor(SuccBB); - Region *SuccRegion = RI.getRegionFor(SuccBB); - if (SD.isNonAffineSubRegion(SuccRegion, &getRegion())) -while (SuccBBLoop && SuccRegion->contains(SuccBBLoop)) - SuccBBLoop = SuccBBLoop->getParentLoop(); + while (BoxedLoops.count(SuccBBLoop)) +SuccBBLoop = SuccBBLoop->getParentLoop(); if (BBLoop != SuccBBLoop) { Added: polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop-2.ll URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop-2.ll?rev=259711&view=auto == --- polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop-2.ll (added) +++ polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop-2.ll Wed Feb 3 15:43:14 2016 @@ -0,0 +1,55 @@ +; RUN: opt %loadPolly -polly-allow-nonaffine-loops -polly-scops -analyze < %s | FileCheck %s +; RUN: opt %loadPolly -polly-allow-nonaffine-loops -polly-codegen -analyze +; +; CHECK:Stmt_loop3 +; CHECK:Domain := +; CHECK:[indvar] -> { Stmt_loop3[0] : indvar >= 101 or indvar <= 99 }; +; CHECK:Schedule := +; CHECK:[indvar] -> { Stmt_loop3[i0] -> [0, 0] : indvar >= 101 or indvar <= 99 }; +; CHECK:Stmt_loop2__TO__loop +; CHECK:Domain := +; CHECK:[indvar] -> { Stmt_loop2__TO__loop[] : indvar <= 99 or indvar >= 101 }; +; CHECK:Schedule := +; CHECK:[indvar] -> { Stmt_loop2__TO__loop[] -> [1, 0] : indvar >= 101 or indvar <= 99 }; +; +define void @foo(i64* %A, i64 %p) { +entry: + br label %loop + +loop: + %indvar.3 = phi i64 [0, %entry], [%indvar.3, %loop], [%indvar.next.3, %next2], [%indvar.next.3, %cond] + %indvar = phi i64 [0, %entry], [%indvar.next, %loop], [0, %next2], [0, %cond] + %indvar.next = add i64 %indvar, 1 + fence seq_cst + %cmp = icmp eq i64 %indvar, 100 + br i1 %cmp, label %next, label %loop + +next: + %indvar.next.3 = add i64 %indvar.3, 1 + %cmp.3 = icmp eq i64 %indvar, 100 + br i1 %cmp.3, label %loop3, label %exit + +loop3: + %indvar.6 = phi i64 [0, %next], [%indvar.next.6, %loop3] + %indvar.next.6 = add i64 %indvar.6, 1 + %cmp.6 = icmp eq i64 %indvar.6, 100 + br i1 %cmp.3, label %loop3, label %loop2 + +loop2: + %indvar.2 = phi i64 [0, %loop3], [%indvar.next.2, %loop2], [0, %cond] + %indvar.next.2 = add i64 %indvar.2, 1 + %prod = mul i64 %indvar.2, %indvar.2 + store i64 %indvar, i64* %A + %cmp.2 = icmp eq i64 %prod, 100 + br i1 %cmp.2, label %loop2, label %next2 + +next2: + %cmp.4 = icmp eq i64 %p, 100 + br i1 %cmp.4, label %loop, label %cond + +cond: + br i1 false, label %loop, label %loop2 + +exit: + ret void +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r259710 - Merged: https://llvm.org/svn/llvm-project/polly/trunk@258802
Author: grosser Date: Wed Feb 3 15:43:09 2016 New Revision: 259710 URL: http://llvm.org/viewvc/llvm-project?rev=259710&view=rev Log: Merged: https://llvm.org/svn/llvm-project/polly/trunk@258802 [FIX] Build correct domain for non-affine region SCoPs Added: polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop.ll Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/Analysis/ScopInfo.cpp?rev=259710&r1=259709&r2=259710&view=diff == --- polly/branches/release_38/lib/Analysis/ScopInfo.cpp (original) +++ polly/branches/release_38/lib/Analysis/ScopInfo.cpp Wed Feb 3 15:43:09 2016 @@ -2035,11 +2035,12 @@ void Scop::removeErrorBlockDomains() { void Scop::buildDomains(Region *R) { + bool IsOnlyNonAffineRegion = SD.isNonAffineSubRegion(R, R); auto *EntryBB = R->getEntry(); - int LD = getRelativeLoopDepth(LI.getLoopFor(EntryBB)); + auto *L = IsOnlyNonAffineRegion ? nullptr : LI.getLoopFor(EntryBB); + int LD = getRelativeLoopDepth(L); auto *S = isl_set_universe(isl_space_set_alloc(getIslCtx(), 0, LD + 1)); - Loop *L = LI.getLoopFor(EntryBB); while (LD-- >= 0) { S = addDomainDimId(S, LD + 1, L); L = L->getParentLoop(); @@ -2047,7 +2048,7 @@ void Scop::buildDomains(Region *R) { DomainMap[EntryBB] = S; - if (SD.isNonAffineSubRegion(R, R)) + if (IsOnlyNonAffineRegion) return; buildDomainsWithBranchConstraints(R); Added: polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop.ll URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop.ll?rev=259710&view=auto == --- polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop.ll (added) +++ polly/branches/release_38/test/ScopInfo/non-affine-region-with-loop.ll Wed Feb 3 15:43:09 2016 @@ -0,0 +1,41 @@ +; RUN: opt %loadPolly -polly-allow-nonaffine-loops -polly-scops -analyze < %s | FileCheck %s +; RUN: opt %loadPolly -polly-allow-nonaffine-loops -polly-codegen -analyze +; +; CHECK: Domain := +; CHECK-NEXT: { Stmt_loop2__TO__loop[] }; +; +define void @foo(i64* %A, i64 %p) { +entry: + br label %loop + +loop: + %indvar.3 = phi i64 [0, %entry], [%indvar.3, %loop], [%indvar.next.3, %next2], [%indvar.next.3, %cond] + %indvar = phi i64 [0, %entry], [%indvar.next, %loop], [0, %next2], [0, %cond] + %indvar.next = add i64 %indvar, 1 + fence seq_cst + %cmp = icmp eq i64 %indvar, 100 + br i1 %cmp, label %next, label %loop + +next: + %indvar.next.3 = add i64 %indvar.3, 1 + %cmp.3 = icmp eq i64 %indvar, 100 + br i1 %cmp.3, label %loop2, label %exit + +loop2: + %indvar.2 = phi i64 [0, %next], [%indvar.next.2, %loop2], [0, %cond] + %indvar.next.2 = add i64 %indvar.2, 1 + %prod = mul i64 %indvar.2, %indvar.2 + store i64 %indvar, i64* %A + %cmp.2 = icmp eq i64 %prod, 100 + br i1 %cmp.2, label %loop2, label %next2 + +next2: + %cmp.4 = icmp eq i64 %p, 100 + br i1 %cmp.4, label %loop, label %cond + +cond: + br i1 false, label %loop, label %loop2 + +exit: + ret void +} ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [polly] r259709 - Merged: https://llvm.org/svn/llvm-project/polly/trunk@259354
Author: grosser Date: Wed Feb 3 15:43:06 2016 New Revision: 259709 URL: http://llvm.org/viewvc/llvm-project?rev=259709&view=rev Log: Merged: https://llvm.org/svn/llvm-project/polly/trunk@259354 ScopInfo: Correct schedule construction For schedule generation we assumed that the reverse post order traversal used by the domain generation is sufficient, however it is not. Once a loop is discovered, we have to completely traverse it, before we can generate the schedule for any block/region that is only reachable through a loop exiting block. To this end, we add a "loop stack" that will keep track of loops we discovered during the traversal but have not yet traversed completely. We will never visit a basic block (or region) outside the most recent (thus smallest) loop in the loop stack but instead queue such blocks (or regions) in a waiting list. If the waiting list is not empty and (might) contain blocks from the most recent loop in the loop stack the next block/region to visit is drawn from there, otherwise from the reverse post order iterator. We exploit the new property of loops being always completed before additional loops are processed, by removing the LoopSchedules map and instead keep all information in LoopStack. This clarifies that we indeed always only keep a stack of in-process loops, but will never keep incomplete schedules for an arbitrary set of loops. As a result, we can simplify some of the existing code. This patch also adds some more documentation about how our schedule construction works. This fixes http://llvm.org/PR25879 This patch is an modified version of Johannes Doerfert's initial fix. Differential Revision: http://reviews.llvm.org/D15679 Added: polly/branches/release_38/test/ScopInfo/schedule-const-post-dominator-walk-2.ll polly/branches/release_38/test/ScopInfo/schedule-const-post-dominator-walk.ll Modified: polly/branches/release_38/include/polly/ScopInfo.h polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/include/polly/ScopInfo.h?rev=259709&r1=259708&r2=259709&view=diff == --- polly/branches/release_38/include/polly/ScopInfo.h (original) +++ polly/branches/release_38/include/polly/ScopInfo.h Wed Feb 3 15:43:06 2016 @@ -1404,17 +1404,62 @@ private: /// the dimensionality of the underlying ScopArrayInfo object. void updateAccessDimensionality(); - /// @brief Build Schedule for the SCoP region. - /// + /// @brief Construct the schedule of this SCoP. void buildSchedule(); - /// @brief Build Schedule for the region @p RN. + /// @brief A loop stack element to keep track of per-loop information during + ///schedule construction. + typedef struct LoopStackElement { +// The loop for which we keep information. +Loop *L; + +// The (possibly incomplete) schedule for this loop. +isl_schedule *Schedule; + +// The number of basic blocks in the current loop, for which a schedule has +// already been constructed. +unsigned NumBlocksProcessed; + +LoopStackElement(Loop *L, __isl_give isl_schedule *S, + unsigned NumBlocksProcessed) +: L(L), Schedule(S), NumBlocksProcessed(NumBlocksProcessed){}; + } LoopStackElementTy; + + /// @brief The loop stack used for schedule construction. + /// + /// The loop stack keeps track of schedule information for a set of nested + /// loops as well as an (optional) 'nullptr' loop that models the outermost + /// schedule dimension. The loops in a loop stack always have a parent-child + /// relation where the loop at position n is the parent of the loop at + /// position n + 1. + typedef SmallVector LoopStackTy; + + /// @brief Construct schedule information for a given Region and add the + ///derived information to @p LoopStack. + /// + /// Given a Region we derive schedule information for all RegionNodes + /// contained in this region ensuring that the assigned execution times + /// correctly model the existing control flow relations. + /// + /// @param R The region which to process. + /// @param LoopStack A stack of loops that are currently under + /// construction. + void buildSchedule(Region *R, LoopStackTy &LoopStack); + + /// @brief Build Schedule for the region node @p RN and add the derived + ///information to @p LoopStack. + /// + /// In case @p RN is a BasicBlock or a non-affine Region, we construct the + /// schedule for this @p RN and also finalize loop schedules in case the + /// current @p RN completes the loop. + /// + /// In case @p RN is a not-non-affine Region, we delegate the construction to + /// buildSchedule(Region *R, ...). /// - /// @param RN The current region traversed. - /// @param LoopSchedules Map from loops to their sched
[llvm-branch-commits] [polly] r262614 - Merge: https://llvm.org/svn/llvm-project/polly/trunk@262612
Author: grosser Date: Thu Mar 3 06:58:57 2016 New Revision: 262614 URL: http://llvm.org/viewvc/llvm-project?rev=262614&view=rev Log: Merge: https://llvm.org/svn/llvm-project/polly/trunk@262612 [FIX] Consolidation of loads with same pointer but different access relation This should fix PR19422. Thanks to Jeremy Huddleston Sequoia for reporting this. Thanks to Roman Gareev for his investigation and the reduced test case. Added: polly/branches/release_38/test/ScopInfo/invariant_load_distinct_parameter_valuations.ll Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp Modified: polly/branches/release_38/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/lib/Analysis/ScopInfo.cpp?rev=262614&r1=262613&r2=262614&view=diff == --- polly/branches/release_38/lib/Analysis/ScopInfo.cpp (original) +++ polly/branches/release_38/lib/Analysis/ScopInfo.cpp Thu Mar 3 06:58:57 2016 @@ -2820,12 +2820,30 @@ void Scop::addInvariantLoads(ScopStmt &S if (PointerSCEV != std::get<0>(IAClass)) continue; - Consolidated = true; + // If the pointer and the type is equal check if the access function wrt. + // to the domain is equal too. It can happen that the domain fixes + // parameter values and these can be different for distinct part of the + // SCoP. If this happens we cannot consolitate the loads but need to + // create a new invariant load equivalence class. + auto &MAs = std::get<1>(IAClass); + if (!MAs.empty()) { +auto *LastMA = MAs.front(); + +auto *AR = isl_map_range(MA->getAccessRelation()); +auto *LastAR = isl_map_range(LastMA->getAccessRelation()); +bool SameAR = isl_set_is_equal(AR, LastAR); +isl_set_free(AR); +isl_set_free(LastAR); + +if (!SameAR) + continue; + } // Add MA to the list of accesses that are in this class. - auto &MAs = std::get<1>(IAClass); MAs.push_front(MA); + Consolidated = true; + // Unify the execution context of the class and this statement. isl_set *&IAClassDomainCtx = std::get<2>(IAClass); if (IAClassDomainCtx) Added: polly/branches/release_38/test/ScopInfo/invariant_load_distinct_parameter_valuations.ll URL: http://llvm.org/viewvc/llvm-project/polly/branches/release_38/test/ScopInfo/invariant_load_distinct_parameter_valuations.ll?rev=262614&view=auto == --- polly/branches/release_38/test/ScopInfo/invariant_load_distinct_parameter_valuations.ll (added) +++ polly/branches/release_38/test/ScopInfo/invariant_load_distinct_parameter_valuations.ll Thu Mar 3 06:58:57 2016 @@ -0,0 +1,114 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s +; +; Check that we do not consolidate the invariant loads to smp[order - 1] and +; smp[order - 2] in the blocks %0 and %16. While they have the same pointer +; operand (SCEV) they do not have the same access relation due to the +; instanciation of "order" from their domain. +; +; CHECK: Invariant Accesses: { +; CHECK-NEXT:ReadAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT:[order, n] -> { Stmt_bb1[] -> MemRef_smp[1] }; +; CHECK-NEXT:Execution Context: [order, n] -> { : order = 2 } +; CHECK-NEXT:ReadAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT:[order, n] -> { Stmt_bb1[] -> MemRef_smp[0] }; +; CHECK-NEXT:Execution Context: [order, n] -> { : order = 2 } +; CHECK-NEXT:ReadAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT:[order, n] -> { Stmt_bb16[] -> MemRef_smp[2] }; +; CHECK-NEXT:Execution Context: [order, n] -> { : order = 3 } +; CHECK-NEXT:ReadAccess := [Reduction Type: NONE] [Scalar: 0] +; CHECK-NEXT:[order, n] -> { Stmt_bb16[] -> MemRef_smp[1] }; +; CHECK-NEXT:Execution Context: [order, n] -> { : order = 3 } +; CHECK-NEXT:} +; +; ModuleID = '/home/johannes/Downloads/test_case.ll' +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +; Function Attrs: nounwind uwtable +define void @encode_residual_fixed(i32* %res, i32* %smp, i32 %n, i32 %order) { +bb: + br label %.split + +.split: ; preds = %bb + switch i32 %order, label %bb32 [ +i32 2, label %bb1 +i32 3, label %bb16 + ] + +bb1: ; preds = %.split + %tmp = add nsw i32 %order, -1 + %tmp2 = sext i32 %tmp to i64 + %tmp3 = getelementptr inbounds i32, i32* %smp, i64 %tmp2 + %tmp4 = load i32, i32* %tmp3, align 4 + %tmp5 = add nsw i32 %order, -2 + %tmp6 = sext i32 %tmp5 to i64 + %tmp7 = getelementptr inbounds i32, i32* %smp, i64 %tmp6 + %tmp8 = load i32, i32* %tmp7, align 4 + %tmp9 = sub