summaryrefslogtreecommitdiffstats
path: root/polly/test/Simplify
Commit message (Collapse)AuthorAgeFilesLines
* Migrate function attribute "no-frame-pointer-elim"="false" to ↵Fangrui Song2019-12-241-1/+1
| | | | "frame-pointer"="none" as cleanups after D56351
* [test] Remove non-JSPON comments in JSCOP file. NFC.Michael Kruse2018-07-281-17/+0
| | | | llvm-svn: 338185
* [Polly] Fix a testcase after LLVM commit r334318Krzysztof Parzyszek2018-06-081-3/+3
| | | | | | | ScalarEvolution has become slightly more intelligent, so obfuscate the exit condition in the testcase some more to keep it working. llvm-svn: 334327
* [ScopBuilder] Make -polly-stmt-granularity=scalar-indep the default.Michael Kruse2018-02-0316-16/+16
| | | | | | | | | | | | | | | | | | | | Splitting basic blocks into multiple statements if there are now additional scalar dependencies gives more freedom to the scheduler, but more statements also means higher compile-time complexity. Switch to finer statement granularity, the additional compile time should be limited by the number of operations quota. The regression tests are written for the -polly-stmt-granularity=bb setting, therefore we add that flag to those tests that break with the new default. Some of the tests only fail because the statements are named differently due to a basic block resulting in multiple statements, but which are removed during simplification of statements without side-effects. Previous commits tried to reduce this effect, but it is not completely avoidable. Differential Revision: https://reviews.llvm.org/D42151 llvm-svn: 324169
* [Simplify] Mark (and sweep) based on latest access relation.Michael Kruse2017-10-266-0/+332
| | | | | | | | | Previously we marked scalars based on the original access function. However, when a scalar read access is redirected, the original definition (or incoming values of a PHI) is not used anymore, and can be deleted (unless referenced by use that has not been redirected). llvm-svn: 316660
* [ScopInfo] Use map for value def/PHI read accesses.Michael Kruse2017-09-211-0/+65
| | | | | | | | | | | | | | | | | | | | | | | Before this patch, ScopInfo::getValueDef(SAI) used getStmtFor(Instruction*) to find the MemoryAccess that writes a MemoryKind::Value. In cases where the value is synthesizable within the statement that defines, the instruction is not added to the statement's instruction list, which means getStmtFor() won't return anything. If the synthesiable instruction is not synthesiable in a different statement (due to being defined in a loop that and ScalarEvolution cannot derive its escape value), we still need a MemoryKind::Value and a write to it that makes it available in the other statements. Introduce a separate map for this purpose. This fixes MultiSource/Benchmarks/MallocBench/cfrac where -polly-simplify could not find the writing MemoryAccess for a use. The write was not marked as required and consequently was removed. Because this could in principle happen as well for PHI scalars, add such a map for PHI reads as well. llvm-svn: 313881
* [Simplify] Actually remove unsed instruction from region header.Michael Kruse2017-09-051-0/+62
| | | | | | | | | | | | | | | | | Since r312249 instructions of a entry block of region statements are not marked as root anymore and hence can theoretically be removed if unused. Theoretically, because the instruction list was not changed. Still, MemoryAccesses for unused instructions were removed. This lead to a failed assertion in the code generator when the MemoryAccess for the still listed instruction was not found. This hould fix the Assertion failed: ArrayAccess && "No array access found for instruction!", file ScopInfo.h, line 1494 compiler crashes. llvm-svn: 312566
* [JSON] Make the failure to parse a jscop file a hard errorPhilip Pfaffe2017-08-101-1/+1
| | | | | | | | | | | | | | | | | | Summary: Before, if we fail to parse a jscop file, this will be reported as an error and importing is aborted. However, this isn't actually strong enough, since although the import is aborted, the scop has already been modified and is very likely broken. Instead, make this a hard failure and throw an LLVM error. This new behaviour requires small changes to the tests for the legacy pass, namely using `not` to verify the error. Further, fixed the jscop file for the base_pointer_load_is_inst_inside_invariant_1 testcase. Reviewed By: Meinersbur Split out of D36578. llvm-svn: 310599
* [Simplify] Rewrite redundant write detection algorithm.Michael Kruse2017-08-0115-7/+594
| | | | | | | | | | | | | | | | | | | | | | The previous algorithm was to search a writes and the sours of its value operand, and see whether the write just stores the same read value back, which includes a search whether there is another write access between them. This is O(n^2) in the max number of accesses in a statement (+ the complexity of isl comparing the access functions). The new algorithm is more similar to the one used for searching for overwrites and coalescable writes. It scans over all accesses in order of execution while tracking which array elements still have the same value since it was read. This is O(n), not counting the complexity within isl. It should be more reliable than trying to catch all non-conforming cases in the previous approach. It is also less code. We now also support if the write is a partial write of the read's domain, and to some extent non-affine subregions. Differential Revision: https://reviews.llvm.org/D36137 llvm-svn: 309734
* [Simplify] Improve scalability.Michael Kruse2017-08-012-0/+292
| | | | | | | | | | | | | | | | | | | | | | With a lot of reads and writes to the same array in a statement, some isl sets that capture the state between access can become complex such that isl takes more considerable time and memory for operations on them. The problems identified were: - is_subset() takes considerable time with many disjoints in the arguments. We limit the number of disjoints to 4, any additional information is thrown away. - subtract() can lead to many disjoints. We instead assume that any array element is possibly accessed, which removes all disjoints. - subtract_domain() may lead to considerable processing, even if all elements are are to be removed. Instead, we remove determine and remove the affected spaces manually. No behaviour is changed. llvm-svn: 309728
* [Simplify] Remove all kinds of redundant scalar writes.Michael Kruse2017-07-314-7/+136
| | | | | | | | In addition to array and PHI writes, also allow scalar value writes. The only kind of write not allowed are writes by functions (including memcpy/memmove/memset). llvm-svn: 309582
* [Simplify] Implement write accesses coalescing.Michael Kruse2017-07-2925-10/+855
| | | | | | | | | | | | | | | | | Write coalescing combines write accesses that - Write the same llvm::Value. - Write to the same array. - Unless they do not write anything in a statement instance (partial writes), write to the same element. - There is no other access between them that accesses the same element. This is particularly useful after DeLICM, which leaves partial writes to disjoint domains. Differential Revision: https://reviews.llvm.org/D36010 llvm-svn: 309489
* [test] Add test case for -polly-simplify. NFC.Michael Kruse2017-07-291-0/+44
| | | | llvm-svn: 309458
* [Simplify] Do not remove dependencies of phis within region stmts.Michael Kruse2017-07-281-0/+50
| | | | | | | These were wrongly assumed to be phi nodes that require MemoryKind::PHI accesses. llvm-svn: 309454
* [Simplify] Fix typo in statistics output. NFC.Michael Kruse2017-07-281-1/+1
| | | | llvm-svn: 309402
* [Simplify] Remove empty partial accesses first. NFC.Michael Kruse2017-07-281-1/+1
| | | | | | So follow-up cleanup do not need special handling for such accesses. llvm-svn: 309401
* [Simplify] Count PHINodes in simplifiable exit nodes as escaping use.Michael Kruse2017-07-271-0/+37
| | | | | | | | | After region exit simplification, the incoming block of a phi node in the SCoP region's exit block lands outside of the region. Since we treat SCoPs as if this already happened, we need to account for that when looking for outside uses of scalars (i.e. escaping scalars). llvm-svn: 309271
* [Simplify] Fix invalid removal write for escaping values.Michael Kruse2017-07-261-0/+44
| | | | | | | | | A PHI node's incoming block is the user of its operand, not the PHI's parent. Assuming the PHINode's parent being the user lead to the removal of a MemoryAccesses because its use was assumed to be inside of the SCoP. llvm-svn: 309164
* [ScopInfo] Fix assertion for PHIs not in a region stmts entry.Michael Kruse2017-07-251-0/+63
| | | | | | | A PHI node within a region statement is legal, but does not have a MemoryKind::PHI access. llvm-svn: 308973
* [Simplify] Remove partial write accesses with empty domain.Michael Kruse2017-07-223-0/+86
| | | | | | | | | | | If the access relation's domain is empty, the access will never be executed. We can just remove it. We only remove write accesses. Partial read accesses are not yet supported and instructions in the statement might require the llvm::Value holding the read's result to be defined. llvm-svn: 308830
* [Simplify] Remove unused instructions and accesses.Michael Kruse2017-07-204-0/+193
| | | | | | | | | | | | | | | | | | | | | | | | | | Use a mark-and-sweep algorithm to find and remove unused instructions and MemoryAccesses. This is useful in particular to remove scalar writes that are never used anywhere. A scalar write in a loop induces a write-after-write dependency that stops the loop iterations to be rescheduled. Such writes can be a result of previous transformations such as DeLICM and operand tree forwarding. It adds a new class VirtualInstruction that represents an instruction in a particular statement. At the moment an instruction can only belong to the statement that represents a BasicBlock. In the future, instructions can be in one of multiple statements representing a BasicBlock (Nandini's work), in different statements than its BasicBlock would indicate, and even multiple statements at once (by forwarding operand trees). It also integrates nicely with the VirtualUse class. ScopStmt::contains(Instruction*) currently uses the instruction's parent BasicBlock to check whether it contains the instruction. It will need to check the actual statement list when one of the aforementioned features become possible. Differential Revision: https://reviews.llvm.org/D35656 llvm-svn: 308626
* [Simplify] Also remove redundant writes which originally came from PHI nodesTobias Grosser2017-07-111-6/+0
| | | | llvm-svn: 307660
* [tests] Set -polly-import-jscop-dir=%S alwaysTobias Grosser2017-07-115-5/+5
| | | | | | This simplifies the test cases. llvm-svn: 307645
* [Simplify] Add test case which we currently missTobias Grosser2017-07-113-0/+356
| | | | llvm-svn: 307643
* [Simplify] Use execution order of memory accesses.Michael Kruse2017-06-063-0/+126
| | | | | | | | | | | | Iterate through memory accesses in execution order (first all implicit reads, then explicit accesses, then implicit writes). In the test case this caused an implicit load to be handled as if it was loaded after the write. That is, the value being written before it is available. This fixes llvm.org/PR33323 llvm-svn: 304810
* [Simplify] Remove identical write removal. NFC.Michael Kruse2017-05-136-6/+6
| | | | | | | | | | | | | Removal of overwritten writes currently encompasses all the cases of the identical write removal. There is an observable behavioral change in that the last, instead of the first, MemoryAccess is kept. This should not affect the generated code, however. Differential Revision: https://reviews.llvm.org/D33143 llvm-svn: 302987
* [Simplify] Remove writes that are overwritten.Michael Kruse2017-05-136-0/+286
| | | | | | | | | | | | | | | | | | | | Remove memory writes that are overwritten by later writes. This works for StoreInsts: store double 21.0, double* %A store double 42.0, double* %A scalar writes at the end of a statement and mixes of these. Multiple writes can be the result of DeLICM, which might map multiple writes to the same location when it knows that these do no conflict (for instance because they write the same value). Such writes interfere with pattern-matched optimization such as gemm and may not get removed by other LLVM passes after code generation. Differential Revision: https://reviews.llvm.org/D33142 llvm-svn: 302986
* [Simplify] Remove identical scalar writes.Michael Kruse2017-05-116-0/+321
| | | | | | | | | | | | | | | | | | | | | | After DeLICM, it is possible to have two writes of the same value to the same location in the same statement when it determined that those writes do not conflict (write the same value). Teach -polly-simplify to remove one of the writes. It interferes with the pattern matching of matrix-multiplication kernels and also seem to not be optimized away by LLVM. The algorthm is simple, has O(n^2) behaviour (n = max number of MemoryAccesses in a statement) and only matches the most obvious cases, but seem to be enough to pattern-match Boost ublas gemm. Not handled cases include: - StoreInst instructions (a.k.a. explicit writes), since the value might be loaded or overwritten between the two stores. - PHINode, especially LCSSA, when the PHI value matches with on other's. - Partial writes (in preparation) llvm-svn: 302805
* [Simplify] Add -polly-simplify pass.Michael Kruse2017-03-104-0/+155
This new pass removes unnecessary accesses and writes. It currently supports 2 simplifications, but more are planned. It removes write accesses that write a loaded value back to the location it was loaded from. It is a typical artifact from DeLICM. Removing it will get rid of bogus dependencies later in dependency analysis. It also removes statements without side-effects. ScopInfo already removes these, but the removal of unnecessary writes can result in more side-effect free statements. Differential Revision: https://reviews.llvm.org/D30820 llvm-svn: 297473
OpenPOWER on IntegriCloud