summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
Commit message (Collapse)AuthorAgeFilesLines
* [opaque pointer type] Start migrating GEP creation to explicitly specify the ↵David Blaikie2015-03-141-4/+6
| | | | | | | | | | | | | | | pointee type I'm just going to migrate these in a pretty ad-hoc & incremental way - providing the backwards compatible API for now, then locally removing it, fixing a few callers, adding it back in and commiting those callers. Rinse, repeat. The assertions should ensure that if I get this wrong we'll find out about it and not just have one giant patch to revert, recommit, revert, recommit, etc. llvm-svn: 232240
* Reapply "[Reassociate] Add initial support for vector instructions."Robert Lougher2015-03-131-19/+15
| | | | | | | | | This reapplies the patch previously committed at revision 232190. This was reverted at revision 232196 as it caused test failures in tests that did not expect operands to be commuted. I have made the tests more resilient to reassociation in revision 232206. llvm-svn: 232209
* Revert: "[Reassociate] Add initial support for vector instructions."Robert Lougher2015-03-131-15/+19
| | | | | | | This reverts revision 232190 due to buildbot failure reported on clang-hexagon-elf for test arm64_vtst.c. To be investigated. llvm-svn: 232196
* [Reassociate] Add initial support for vector instructions.Robert Lougher2015-03-131-19/+15
| | | | | | | | | | | | | | This patch adds initial support for vector instructions to the reassociation pass. It enables most parts of the pass to work with vectors but to keep the size of the patch small, optimization of Xor trees, canonicalization of negative constants and converting shifts to muls, etc., have been left out. This will be handled in later patches. The patch is based on an initial patch by Chad Rosier. Differential Revision: http://reviews.llvm.org/D7566 llvm-svn: 232190
* DataLayout is mandatory, update the API to reflect it with references.Mehdi Amini2015-03-1028-485/+450
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Now that the DataLayout is a mandatory part of the module, let's start cleaning the codebase. This patch is a first attempt at doing that. This patch is not exactly NFC as for instance some places were passing a nullptr instead of the DataLayout, possibly just because there was a default value on the DataLayout argument to many functions in the API. Even though it is not purely NFC, there is no change in the validation. I turned as many pointer to DataLayout to references, this helped figuring out all the places where a nullptr could come up. I had initially a local version of this patch broken into over 30 independant, commits but some later commit were cleaning the API and touching part of the code modified in the previous commits, so it seemed cleaner without the intermediate state. Test Plan: Reviewers: echristo Subscribers: llvm-commits From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 231740
* Remove the remaining uses of abs64 and nuke it.Benjamin Kramer2015-03-092-3/+3
| | | | | | std::abs works just fine and we're already using it in many places. NFC intended. llvm-svn: 231696
* Make helper functions static.Benjamin Kramer2015-03-092-7/+8
| | | | | | Found by -Wmissing-prototypes. NFC. llvm-svn: 231664
* Introduce runtime unrolling disable matadata and use it to mark the scalar ↵Kevin Qin2015-03-091-0/+8
| | | | | | | | | | | loop from vectorization. Runtime unrolling is an expensive optimization which can bring benefit only if the loop is hot and iteration number is relatively large enough. For some loops, we know they are not worth to be runtime unrolled. The scalar loop from vectorization is one of the cases. llvm-svn: 231631
* LoopInterchange: Remove empty method.Benjamin Kramer2015-03-061-6/+1
| | | | llvm-svn: 231503
* LoopInterchange: Rephrase instruction moving using ilist's splice and factor ↵Benjamin Kramer2015-03-061-56/+19
| | | | | | | | it into a function + Random cleanups. No functional change. llvm-svn: 231501
* Change the way in which error case is being handled.Daniel Jasper2015-03-061-2/+4
| | | | | | | | | Specifically this: * Prevents an "unused" warning in non-assert builds. * In that error case return with out removing a child loop instead of looping forever. llvm-svn: 231459
* Add a new pass "Loop Interchange"Karthik Bhat2015-03-063-0/+1195
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pass interchanges loops to provide a more cache-friendly memory access. For e.g. given a loop like - for(int i=0;i<N;i++) for(int j=0;j<N;j++) A[j][i] = A[j][i]+B[j][i]; is interchanged to - for(int j=0;j<N;j++) for(int i=0;i<N;i++) A[j][i] = A[j][i]+B[j][i]; This pass is currently disabled by default. To give a brief introduction it consists of 3 stages- LoopInterchangeLegality : Checks the legality of loop interchange based on Dependency matrix. LoopInterchangeProfitability: A very basic heuristic has been added to check for profitibility. This will evolve over time. LoopInterchangeTransform : Which does the actual transform. LNT Performance tests shows improvement in Polybench/linear-algebra/kernels/mvt and Polybench/linear-algebra/kernels/gemver becnmarks. TODO: 1) Add support for reductions and lcssa phi. 2) Improve profitability model. 3) Improve loop selection algorithm to select best loop for interchange. Currently the innermost loop is selected for interchange. 4) Improve compile time regression found in llvm lnt due to this pass. 5) Fix issues in Dependency Analysis module. A special thanks to Hal for reviewing this code. Review: http://reviews.llvm.org/D7499 llvm-svn: 231458
* Make DataLayout Non-Optional in the ModuleMehdi Amini2015-03-0421-81/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: DataLayout keeps the string used for its creation. As a side effect it is no longer needed in the Module. This is "almost" NFC, the string is no longer canonicalized, you can't rely on two "equals" DataLayout having the same string returned by getStringRepresentation(). Get rid of DataLayoutPass: the DataLayout is in the Module The DataLayout is "per-module", let's enforce this by not duplicating it more than necessary. One more step toward non-optionality of the DataLayout in the module. Make DataLayout Non-Optional in the Module Module->getDataLayout() will never returns nullptr anymore. Reviewers: echristo Subscribers: resistor, llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D7992 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 231270
* [RewriteStatepointsForGC] Fix a relocation bug w.r.t values defined by ↵Philip Reames2015-03-041-2/+12
| | | | | | | | | | | | | | | invoke instructions RewriteStatepointsForGC pass emits an alloca for each GC pointer which will be relocated. It then inserts stores after def and all relocations, and inserts loads before each use as well. In the end, mem2reg is used to update IR with relocations in SSA form. However, there is a problem with inserting stores for values defined by invoke instructions. The code didn't expect a def was a terminator instruction, and inserting instructions after these terminators resulted in malformed IR. This patch fixes this problem by handling invoke instructions as a special case. If the def is an invoke instruction, the store will be inserted at the beginning of the normal destination block. Since return value from invoke instruction does not dominate the unwind destination block, no action is needed there. Patch by: Chen Li Differential Revision: http://reviews.llvm.org/D7923 llvm-svn: 231183
* RewriteStatepointsForGC::PhiState: Remove explicit copy ctor in favor of the ↵David Blaikie2015-03-031-3/+0
| | | | | | | | | | | | Rule of Zero The assertion was just checking a class invariant that's pretty easy to verify by inspection (no mutating operations, and the two non-copy ctors already ensure the state is maintained) so remove the explicit copy ctor in favor of the default, thus allowing the use of the default copy assignment operator without hitting the C++11 deprecation here. llvm-svn: 231143
* Revert "Remove the explicit SDNodeIterator::operator= in favor of the ↵David Blaikie2015-03-031-1/+0
| | | | | | | | | | | implicit default" Accidentally committed a few more of these cleanup changes than intended. Still breaking these out & tidying them up. This reverts commit r231135. llvm-svn: 231136
* Remove the explicit SDNodeIterator::operator= in favor of the implicit defaultDavid Blaikie2015-03-031-0/+1
| | | | | | | | | | There doesn't seem to be any need to assert that iterator assignment is between iterators over the same node - if you want to reuse an iterator variable to iterate another node, that's perfectly acceptable. Just don't mix comparisons between iterators into disjoint sequences, as usual. llvm-svn: 231135
* LoopIdiom: Give globals for memset_pattern16 private linkage.Benjamin Kramer2015-03-031-1/+1
| | | | | | | | There's really no reason to have them have entries in the symbol table anymore. Old versions of ld64 had some bugs in this area but those have been fixed long ago. llvm-svn: 231041
* Revert some changes that were made to fix PR20680.Sanjoy Das2015-03-021-42/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | This re-lands change r230921. r230921 was reverted because it broke a clang test; a checkin fixing the clang test will be commited shortly. Summary: As far as I can tell, the real bug causing the issue was fixed in r230533. SCEVExpander should mark an increment operation as nuw or nsw only if it can *prove* that the operation does not overflow. There shouldn't be any situation where we have to do something different because of no-wrap flags generated by SCEVExpander. Revert "IndVarSimplify: Allow LFTR to fire more often" This reverts commit 1ade0f0faa98877b688e0b9da58e876052c1e04e (SVN: 222213). Revert "IndVarSimplify: Don't let LFTR compare against a poison value" This reverts commit c0f2b8b528d8a37b0a1522aae90af649d6357eb5 (SVN: 217102). Reviewers: majnemer, atrick, spatel Differential Revision: http://reviews.llvm.org/D7979 llvm-svn: 231018
* Revert r230921, "Revert some changes that were made to fix PR20680.", for now.NAKAMURA Takumi2015-03-021-6/+42
| | | | | | It caused a failure on clang/test/Misc/backend-optimization-failure.cpp . llvm-svn: 230929
* Revert some changes that were made to fix PR20680.Sanjoy Das2015-03-011-42/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: As far as I can tell, the real bug causing the issue was fixed in r230533. SCEVExpander should mark an increment operation as nuw or nsw only if it can *prove* that the operation does not overflow. There shouldn't be any situation where we have to do something different because of no-wrap flags generated by SCEVExpander. Revert "IndVarSimplify: Allow LFTR to fire more often" This reverts commit 1ade0f0faa98877b688e0b9da58e876052c1e04e (SVN: 222213). Revert "IndVarSimplify: Don't let LFTR compare against a poison value" This reverts commit c0f2b8b528d8a37b0a1522aae90af649d6357eb5 (SVN: 217102). Reviewers: majnemer, atrick, spatel Differential Revision: http://reviews.llvm.org/D7979 llvm-svn: 230921
* TRE: Just erase dead BBs and tweak the iteration loop not to increment the ↵Benjamin Kramer2015-02-281-19/+7
| | | | | | | | | | | deleted BB iterator. Leaving empty blocks around just opens up a can of bugs like PR22704. Deleting them early also slightly simplifies code. Thanks to Sanjay for the IR test case. llvm-svn: 230856
* Silence variable set but not used warning, NFC.Yaron Keren2015-02-281-2/+3
| | | | llvm-svn: 230848
* Replace std::copy with a back inserter with vector append where feasibleBenjamin Kramer2015-02-281-1/+1
| | | | | | | | | All of the cases were just appending from random access iterators to a vector. Using insert/append can grow the vector to the perfect size directly and moves the growing out of the loop. No intended functionalty change. llvm-svn: 230845
* [RewriteStatepointsForGC] Reduce indentation via early continue [NFC]Philip Reames2015-02-281-81/+82
| | | | llvm-svn: 230836
* [RewriteStatepointsForGC] Fix another order of iteration bugPhilip Reames2015-02-281-4/+20
| | | | | | | | | | | | It turns out the naming of inserted phis and selects is sensative to the order in which two sets are iterated. We need to nail this down to avoid non-deterministic output and possible test failures. The modified test is the one I first noticed something odd in. The change is making it more strict to report the error. With the test change, but without the code change, the test fails roughly 1 in 5. With the code change, I've run ~30 runs without error. Long term, the right fix here is to adjust the naming scheme. I'm checking in this hack to avoid any possible non-determinism in the tests over the weekend. HJust because I only noticed one case doesn't mean it's actually the only case. I hope to get to the right change Monday. std->llvm data structure changes bugfix change #3 llvm-svn: 230835
* [RewriteStatepointsForGC] Reduce indentation via early continue [NFC]Philip Reames2015-02-281-35/+36
| | | | llvm-svn: 230829
* [RewriteStatepointsForGC] Fix iterator invalidation bugPhilip Reames2015-02-281-2/+11
| | | | | | | | Inserting into a DenseMap you're iterating over is not well defined. This is unfortunate since this is well defined on a std::map. "cleanup per llvm code style standards" bug #2 llvm-svn: 230827
* [RewriteStatepointsForGC] Add tests for the base pointer identification ↵Philip Reames2015-02-281-2/+11
| | | | | | | | | | | | algorithm These tests cover the 'base object' identification and rewritting portion of RewriteStatepointsForGC. These aren't completely exhaustive, but they've proven to be reasonable effective over time at finding regressions. In the process of porting these tests over, I found my first "cleanup per llvm code style standards" bug. We were relying on the order of iteration when testing the base pointers found for a derived pointer. When we switched from std::set to DenseSet, this stopped being a safe assumption. I'm suspecting I'm going to find more of those. In particular, I'm now really wondering about the main iteration loop for this algorithm. I need to go take a closer look at the assumptions there. I'm not really happy with the fact these are testing what is essentially debug output (i.e. enabled via command line flags). Suggestions for how to structure this better are very welcome. llvm-svn: 230818
* remove function names from comments; NFCSanjay Patel2015-02-271-20/+15
| | | | llvm-svn: 230766
* IRCE: only touch loops that have been shown to have a highSanjoy Das2015-02-261-4/+17
| | | | | | backedge-taken count in profiliing data. llvm-svn: 230619
* IRCE: generalize to handle loops with decreasing induction variables.Sanjoy Das2015-02-261-207/+358
| | | | | | | | | IRCE can now split the iteration space for loops like: for (i = n; i >= 0; i--) a[i + k] = 42; // bounds check on access llvm-svn: 230618
* IRCE: print newline after printing an InductiveRangeCheck.Sanjoy Das2015-02-261-0/+1
| | | | llvm-svn: 230607
* PlaceSafepoints: use IRBuilder helpersRamkumar Ramachandra2015-02-261-44/+39
| | | | | | | | | | Use the IRBuilder helpers for gc.statepoint and gc.result, instead of coding the construction by hand. Note that the gc.statepoint IRBuilder handles only CallInst, not InvokeInst; retain that part of hand-coding. Differential Revision: http://reviews.llvm.org/D7518 llvm-svn: 230591
* only propagate equality comparisons of FP values that we are certain are ↵Sanjay Patel2015-02-251-3/+7
| | | | | | | | | | | | non-zero This is a follow-on to r227491 which tightens the check for propagating FP values. If a non-constant value happens to be a zero, we would hit the same bug as before. Bug noted and patch suggested by Eli Friedman. llvm-svn: 230564
* remove function names from comments; NFCSanjay Patel2015-02-241-42/+38
| | | | llvm-svn: 230391
* add newline for easier reading; NFCSanjay Patel2015-02-231-1/+1
| | | | llvm-svn: 230265
* Roll condition into an assert then wrap it 'ifndef NDEBUG' to protect from ↵David Blaikie2015-02-221-8/+7
| | | | | | the inevitable "unused variable" warning in a non-asserts build. llvm-svn: 230181
* [LICM] Refactor to expose functionality as utility functionsHal Finkel2015-02-221-173/+199
| | | | | | | | | | | This refactors the core functionality of LICM: HoistRegion, SinkRegion and PromoteAliasSet (renamed to promoteLoopAccessesToScalars) as utility functions in LoopUtils. This will enable other transformations to make use of them directly. Patch by Ashutosh Nema. llvm-svn: 230178
* RewriteStatepointsForGC.cpp: Fix for -Asserts to mark isNullConstant() as ↵NAKAMURA Takumi2015-02-221-1/+1
| | | | | | LLVM_ATTRIBUTE_UNUSED. [-Wunused-function] llvm-svn: 230169
* RewriteStatepointsForGC.cpp: Fix for -Asserts. [-Wunused-variable]NAKAMURA Takumi2015-02-221-2/+1
| | | | llvm-svn: 230168
* IRCE: generalize InductiveRangeCheck::computeSafeIterationSpace toSanjoy Das2015-02-211-32/+57
| | | | | | | | | | work with a non-canonical induction variable. This is currently a non-functional change because we only ever call computeSafeIterationSpace on a canonical induction variable; but the generalization will be useful in a later commit. llvm-svn: 230151
* IRCE: use SCEVs instead of llvm::Value's for intermediateSanjoy Das2015-02-211-46/+30
| | | | | | | | | calculations. Semantically non-functional change. This gets rid of some of the SCEV -> Value -> SCEV round tripping and the Construct(SMin|SMax)Of and MaybeSimplify helper routines. llvm-svn: 230150
* [PlaceSafepoints] Adjust enablement logic to default to off and be GC ↵Philip Reames2015-02-211-11/+26
| | | | | | | | configurable per GC Previously, this pass ran over every function in the Module if added to the pass order. With this change, it runs only over those with a GC attribute where the GC explicitly opts in. A GC can also choose which of entry safepoint polls, backedge safepoint polls, and call safepoints it wants. I hope to get these exposed as checks on the GCStrategy at some point, but for now, the checks are manual string comparisons. llvm-svn: 230097
* Remove some unnecessary unreachables in favor of (sometimes implicit) assertionsDavid Blaikie2015-02-201-53/+34
| | | | | | | Also simplify some else-after-return cases including some standard algorithm convenience/use. llvm-svn: 230094
* Hide a bunch of advanced testing options in default opt --help outputPhilip Reames2015-02-201-7/+9
| | | | | | These are internal options. I need to go through, evaluate which are worth keeping and which not. Many of them should probably be renamed as well. Until I have time to do that, we can at least stop poluting the standard opt -help output. llvm-svn: 230088
* [RewriteStatepointsForGC] Use DenseSet in place of std::set [NFC]Philip Reames2015-02-201-8/+8
| | | | | | This should be the last cleanup on non-llvm preferred data structures. I left one use of std::set in an assertion; DenseSet didn't seem to have a tombstone for CallSite defined. That might be worth fixing, but wasn't worth it for a debug only use. llvm-svn: 230084
* [RewriteStatepointsForGC] Replace std::map with DenseMapPhilip Reames2015-02-201-2/+2
| | | | | | I'd done the work of extracting the typedef in a previous commit, but didn't actually change it. Hopefully this will make any subtle changes easier to isolate. llvm-svn: 230081
* [RewriteStatepointsForGC] Cleanup - replace std::vector usage [NFC]Philip Reames2015-02-201-40/+38
| | | | | | Migrate std::vector usage to a combination of SmallVector and ArrayRef. llvm-svn: 230079
* [RewriteStatepointsForGC] More style cleanup [NFC]Philip Reames2015-02-201-15/+14
| | | | | | Use llvm_unreachable where appropriate, use SmallVector where easy to do so, introduce typedefs for planned type migrations. llvm-svn: 230068
OpenPOWER on IntegriCloud