summaryrefslogtreecommitdiff
path: root/polly/lib/CodeGen/BlockGenerators.cpp
AgeCommit message (Collapse)Author
2015-08-30Remove isNew from getOrCreateAllocaTobias Grosser
This commit drops some dead code. Specifically, there is no need to initialize the virtual memory locations of scalars in BlockGenerator::handleOutsideUsers, the function that initalizes the escape map that keeps track of out-of-scope uses of scalar values. We already model instructions inside the scop that are used outside the scope (escaping instructions) as scalar memory writes at the position of the instruction. As a result, the virtual memory location of this instructions is already initialized when code-generating the corresponding virtual scalar write and consequently does not need to be initialized later on when generating the set of escaping values. Code references: In TempScopInfo::buildScalarDependences we detect scalar cross-statement dependences for all instructions (including PHIs) that have uses outside of the scop's region: // Check whether or not the use is in the SCoP. if (!R->contains(UseParent)) { AnyCrossStmtUse = true; continue; } We use this information in TempScopInfo::buildAccessFunctions were we build scalar write memory accesses for all these instructions: if (!isa<StoreInst>(Inst) && buildScalarDependences(Inst, &R, NonAffineSubRegion)) { // If the Instruction is used outside the statement, we need to build the // write access. IRAccess ScalarAccess(IRAccess::MUST_WRITE, Inst, ZeroOffset, 1, true, Inst); Functions.push_back(std::make_pair(ScalarAccess, Inst)); } Reviewers: jdoerfert Subscribers: pollydev, llvm-commits Differential Revision: http://reviews.llvm.org/D12472 llvm-svn: 246383
2015-08-29Remove some code duplication when creating Allocas [NFC]Tobias Grosser
llvm-svn: 246364
2015-08-28BlockGenerator: Make scalar memory locations accessibleTobias Grosser
For external users, the memory locations into which we generate scalar values may be of interest. This change introduces two functions that allow to obtain (or create) the AllocInsts for a given BasePointer. We use this change to simplify the code in BlockGenerators. llvm-svn: 246285
2015-08-27BlockGenerator: Add the possiblity to pass a set of new access functionsTobias Grosser
This change allows the BlockGenerator to be reused in contexts where we want to provide different/modified isl_ast_expressions, which are not only changed to a different access relation than the original statement, but which may indeed be different for each code-generated instance of the statement. We ensure testing of this feature by moving Polly's support to import changed access functions through a jscop file to use the BlockGenerators support for generating arbitary access functions if provided. This commit should not change the behavior of Polly for now. The diff is rather large, but most changes are due to us passing the NewAccesses hash table through functions. This style, even though rather verbose, matches what is done throughout the BlockGenerator with other per-statement properties. llvm-svn: 246144
2015-08-21Fix 'unused variable' warning in NASSERTS buildTobias Grosser
llvm-svn: 245723
2015-08-18Move early exit to the beginning of the functionMichael Kruse
If the function exits early there is no reason to enter the loop. llvm-svn: 245316
2015-08-18Introduce the ScopExpander as a SCEVExpander replacementJohannes Doerfert
The SCEVExpander cannot deal with all SCEVs Polly allows in all kinds of expressions. To this end we introduce a ScopExpander that handles the additional expressions separatly and falls back to the SCEVExpander for everything else. Reviewers: grosser, Meinersbur Subscribers: #polly Differential Revision: http://reviews.llvm.org/D12066 llvm-svn: 245288
2015-08-17Add a field to the memory access class for a related value.Johannes Doerfert
The new field in the MemoryAccess allows us to track a value related to that access: - For real memory accesses the value is the loaded result or the stored value. - For straigt line scalar accesses it is the access instruction itself. - For PHI operand accesses it is the operand value. We use this value to simplify code which deduced information about the value later in the Polly pipeline and was known to be error prone. Reviewers: grosser, Meinsersbur Subscribers: #polly Differential Revision: http://reviews.llvm.org/D12062 llvm-svn: 245213
2015-08-17[FIX] Create location if a needed value was not yet demotedJohannes Doerfert
This allows the code generation to continue working even if a needed value (that is reloaded anyway) was not yet demoted. Instead of failing it will now create the location for future demotion to memory and load from that location. The stores will use the same location and by construction execute before the load even if the textual order in the generated AST is otherwise. Reviewers: grosser, Meinersbur Subscribers: #polly Differential Revision: http://reviews.llvm.org/D12072 llvm-svn: 245203
2015-08-16Remove trivially true conditionJohannes Doerfert
llvm-svn: 245174
2015-08-13Enable code generation of scalar dependences from function argumentsTobias Grosser
This change extends the BlockGenerator to not only allow Instructions as base elements of scalar dependences, but any llvm::Value. This allows us to code-generate scalar dependences which reference function arguments, as they arise when moddeling read-only scalar dependences. llvm-svn: 244874
2015-08-11BlockGenerator: Do not store 'store' statements in BBMapTobias Grosser
A store statement has no return value and can consequently not be referenced from another statement. llvm-svn: 244576
2015-08-08Add an assertionMichael Kruse
Check whether a block is a direct predecessor. llvm-svn: 244401
2015-08-04Optionally model read-only scalarsTobias Grosser
Even though read-only accesses to scalars outside of a scop do not need to be modeled to derive valid transformations or to generate valid sequential code, but information about them is useful when we considering memory footprint analysis and/or kernel offloading. llvm-svn: 243981
2015-08-02Use the branch instruction to define the location of a PHI-node writeTobias Grosser
We use the branch instruction as the location at which a PHI-node write takes place, instead of the PHI-node itself. This allows us to identify the basic-block in a region statement which is on the incoming edge of the PHI-node and for which the write access was originally introduced. As a result we can, during code generation, avoid generating PHI-node write accesses for basic blocks that do not preceed the PHI node without having to look at the IR again. This change fixes a bug which was introduced in r243420, when we started to explicitly model PHI-node reads and writes, but dropped some additional checks that where still necessary during code generation to not emit PHI-node writes for basic-blocks that are not on incoming edges of the original PHI node. Compared to the code before r243420 the new code does not need to inspect the IR any more and we also do not generate multiple redundant writes. llvm-svn: 243852
2015-08-01Only use instructions as insert locations for SCEVExpanderTobias Grosser
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 <cs14mtech11017@iith.ac.in> for his help with test case reduction. llvm-svn: 243830
2015-08-01Fix typoTobias Grosser
llvm-svn: 243829
2015-07-28Keep track of ScopArrayInfo objects that model PHI node storageTobias Grosser
Summary: When translating PHI nodes into memory dependences during code generation we require two kinds of memory. 'Normal memory' as for all scalar dependences and 'PHI node memory' to store the incoming values of the PHI node. With this patch we now mark and track these two kinds of memories, which we previously incorrectly marked as a single memory object. Being aware of PHI node storage makes code generation easier, as we do not need to guess what kind of storage a scalar reference requires. This simplifies the code nicely. Reviewers: jdoerfert Subscribers: pollydev, llvm-commits Differential Revision: http://reviews.llvm.org/D11554 llvm-svn: 243420
2015-07-27Simplify code in BlockGenerator::generateScalarLoads [NFC]Tobias Grosser
We hoist statements that are used on both branches of an if-condition, shorten and unify some variable names and fold some variable declarations into their only uses. We also drop a comment which just describes the elements the loop iterates over. No functional change intended. llvm-svn: 243291
2015-05-22Add scalar and phi code generationJohannes Doerfert
To reduce compile time and to allow more and better quality SCoPs in the long run we introduced scalar dependences and PHI-modeling. This patch will now allow us to generate code if one or both of those options are set. While the principle of demoting scalars as well as PHIs to memory in order to communicate their value stays the same, this allows to delay the demotion till the very end (the actual code generation). Consequently: - We __almost__ do not modify the code if we do not generate code for an optimized SCoP in the end. Thus, the early exit as well as the unprofitable option will now actually preven us from introducing regressions in case we will probably not get better code. - Polly can be used as a "pure" analyzer tool as long as the code generator is set to none. - The original SCoP is almost not touched when the optimized version is placed next to it. Runtime regressions if the runtime checks chooses the original are not to be expected and later optimizations do not need to revert the demotion for that part. - We will generate direct accesses to the demoted values, thus there are no "trivial GEPs" that select the first element of a scalar we demoted and treated as an array. Differential Revision: http://reviews.llvm.org/D7513 llvm-svn: 238070
2015-05-09Sort include directivesTobias Grosser
Upcoming revisions of isl require us to include header files explicitly, which have previously been already transitively included. Before we add them, we sort the existing includes. Thanks to Chandler for sort_includes.py. A simple, but very convenient script. llvm-svn: 236930
2015-03-23Drop -polly-vectorizer-unroll-only optionTobias Grosser
This options was earlier used for experiments with the vectorizer, but to my knowledge is not really used anymore. If anybody needs this, we can always reintroduce this feature. llvm-svn: 232934
2015-03-12Drop option to prepare code for the BB vectorizerTobias Grosser
The BB vectorizer is deprecated and there is no point in generating code for it any more. This option was introduced when there was not yet any loop vectorizer in sight. Now being matured, Polly should target the loop vectorizer. llvm-svn: 232099
2015-03-10Fix compilation after DataLayout was added to ScevExpanderTobias Grosser
The corresponding LLVM commit is 231740. llvm-svn: 231793
2015-03-01[Refactor] Include explicitly what is usedJohannes Doerfert
llvm-svn: 230901
2015-02-27[FIX] Teach RegionGenerator to respect and update dominanceJohannes Doerfert
When we generate code for a whole region we have to respect dominance and update it too. The first is achieved with multiple "BBMap"s. Each copied block in the region gets its own map. It is initialized only with values mapped in the immediate dominator block, if this block is in the region and was therefor already copied. This way no values defined in a block that doesn't dominate the current one will be used. To update dominance information we check if the immediate dominator of the original block we want to copy is in the region. If so we set the immediate dominator of the current block to the copy of the immediate dominator of the original block. llvm-svn: 230774
2015-02-24Allow non-affine control flow -- Code GenerationJohannes Doerfert
This is the code generation for region statements that are created when non-affine control flow was present in the input. A new generator, similar to the block or vector generator, for regions is used to traverse and copy the region statement and to adjust the control flow inside the new region in the end. llvm-svn: 230340
2015-02-23[REFACTOR] Replace Pass* from BlockGen by the DomTreeJohannes Doerfert
llvm-svn: 230220
2015-02-08[Refactor] Use the LoopInfo object already presentJohannes Doerfert
llvm-svn: 228540
2015-02-06[Refactor] Use only one BlockGenerator for a SCoPJohannes Doerfert
This change has two main purposes: 1) We do not use a static interface to hide an object we create and destroy for every basic block we copy. 2) We allow the BlockGenerator to store information between calls to the copyBB method. This will ease scalar/phi code generation later on. While a lot of method signatures were changed this should not cause any real behaviour change. Differential Revision: http://reviews.llvm.org/D7467 llvm-svn: 228443
2015-01-26[FIX] Debug build + instrinsic handlingJohannes Doerfert
The ignored intrinsics needed to be ignored in three other places as well. Tests and lnt pass now. llvm-svn: 227092
2015-01-25Support for math/misc intrinsicsJohannes Doerfert
The support is currently limited as we only allow them in the input but do not emit them in the transformed SCoP due to the possible semantic changes. Differential Revision: http://reviews.llvm.org/D5225 llvm-svn: 227054
2015-01-18Remove redundant semicolon clang-format complained aboutTobias Grosser
llvm-svn: 226402
2015-01-18[PM] Update Polly for LLVM r226394 and r226396 which changed some of theChandler Carruth
block splitting interfaces to accept specific analyses rather than a pass. llvm-svn: 226398
2015-01-17[PM] Update Polly following LLVM r226373 which refactors LoopInfo inChandler Carruth
preparation for the new pass manager. llvm-svn: 226374
2014-11-30Remove -polly-codegen-scev option and related codeTobias Grosser
SCEV based code generation has been the default for two weeks after having been tested for a long time. We now drop the support the non-scev-based code generation. llvm-svn: 222978
2014-11-16Enable SCEV based code generation by defaultTobias Grosser
SCEV based code generation allows Polly to detect and generate code for loops that do not have an explicit induction variable, but only virtual induction variables given by SCEV. Being able to do so has two main benefits: - We can detect more scops by default - We require less canonicalization before Polly, which means we get closer to our goal of not touching the IR before analyzing its properties. Specifically, we do not need to run -polly-indvars to introduce explicit canonical induction variables. This switch became possible as both the isl code generation and -polly-parallel are LNT error free with SCEV based code generation and the isl ast generator. llvm-svn: 222113
2014-11-05BlockGenerator: Recompute values from SCEV before handing back the original ↵Tobias Grosser
values This patch moves the SCEV based (re)generation of values before the checking for scop-constant terms. It enables us to provide SCEV based replacements, which are necessary to correctly generate OpenMP subfunctions when using the SCEV based code generation. When recomputing a new value for a value used in the code of the original scop, we previously directly returned the same original value for all scop-constant expressions without even trying to regenerate these values using our SCEV expression. This is correct when the newly generated code remains fully in the same function, however in case we want to outline parts of the newly generated scop into subfunctions, this approach means we do not have any opportunity to update these values in the SCEV based code generation. (In the non-SCEV based code generation, we can provide such updates through the GlobalMap). To ensure we have this opportunity, we first try to regenerate scalar terms with our SCEV builder and will only return scop-constant expressions if SCEV based code generation was not possible. This change should not affect the results of the existing code generation passes. It only impacts the upcoming OpenMP based code generation. This commit also adds a test case. This test case passes before and after this commit. It was added to ensure test coverage for the changed code. llvm-svn: 221393
2014-11-05BlockGenerator: inline lookupAvailableValue into getValue [NFC]Tobias Grosser
There was no good reason why this code was split accross two functions. In subsequent changes we will change the order in which values are looked up. Doing so would make the split into two functions even more arbitrary. We also slightly improve the documentation. llvm-svn: 221388
2014-10-22Remove incorrect value description for -enable-polly-alignedTobias Grosser
The description of the parameter value passed to -enable-polly-aligned did not make any sense at all, but was just a leftover coming from when this option was copied form -enable-polly-openmp. We just drop it as the option description gives sufficient information already. llvm-svn: 220445
2014-10-13[Refactor][NfC] Simplify and clean the handling of (new) access relationsJohannes Doerfert
This patch does not change the semantic on it's own. However, the dependence analysis as well as dce will now use the newest available access relation for each memory access, thus if at some point the json importer or any other pass will run before those two and set a new access relation the behaviour will be different. In general it is unclear if the dependence analysis and dce should be run on the old or new access functions anyway. If we need to access the original access function from the outside later, we can expose the getter again. Differential Revision: http://reviews.llvm.org/D5707 llvm-svn: 219612
2014-10-08[Refactor][NFC] Simplify (Vector)BlockGeneratorJohannes Doerfert
This removes an unnecessary cast and a unnecessary local variable. Differential Revision: http://reviews.llvm.org/D5662 llvm-svn: 219338
2014-10-08Allow the VectorBlockGenerator to use the IslExprBuilder.Johannes Doerfert
This also enables the VectorBlockGenerator to build load store accesses according to the newAccessRelation of a MemoryAccess. llvm-svn: 219321
2014-10-02Align copied load/store instructions as the original.Johannes Doerfert
This also forbids the json importer to access other memory locations than the original instruction as we to reuse the alignment of the original load/store. Differential Revision: http://reviews.llvm.org/D5560 llvm-svn: 218883
2014-09-18Allow the IslExprBuilder to build address of expressionsJohannes Doerfert
llvm-svn: 218045
2014-08-07Make used analysis passes explicitJohannes Doerfert
Use the explicit analysis if possible, only for splitBlock we will continue to use the Pass * argument. This change allows us to remove the getAnalysis calls from the code generation. llvm-svn: 215121
2014-08-03Fix the modifiable access creationJohannes Doerfert
+ Remove the class IslGenerator which duplicates the functionality of IslExprBuilder. + Use the IslExprBuilder to create code for memory access relations. + Also handle array types during access creation. + Enable scev codegen for one of the transformed memory access tests, thus access creation without canonical induction variables available. + Update one test case to the new output. llvm-svn: 214659
2014-07-29[Refactor] Use non-const MemoryAccess base addressesJohannes Doerfert
llvm-svn: 214168
2014-07-09clang-format polly to avoid buildbot noiseTobias Grosser
llvm-svn: 212609
2014-06-04Use range-based for loopsTobias Grosser
llvm-svn: 210170