summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolutionExpander.cpp
Commit message (Collapse)AuthorAgeFilesLines
* SCEVExpander fix. RAUW needs to update the InsertedExpressions cache.Andrew Trick2013-01-141-3/+2
| | | | | | | | Note that this bug is only exposed because LTO fails to use TTI. Fixes self-LTO of clang. rdar://13007381. llvm-svn: 172462
* Switch the SCEV expander and LoopStrengthReduce to useChandler Carruth2013-01-071-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | TargetTransformInfo rather than TargetLowering, removing one of the primary instances of the layering violation of Transforms depending directly on Target. This is a really big deal because LSR used to be a "special" pass that could only be tested fully using llc and by looking at the full output of it. It also couldn't run with any other loop passes because it had to be created by the backend. No longer is this true. LSR is now just a normal pass and we should probably lift the creation of LSR out of lib/CodeGen/Passes.cpp and into the PassManagerBuilder. =] I've not done this, or updated all of the tests to use opt and a triple, because I suspect someone more familiar with LSR would do a better job. This change should be essentially without functional impact for normal compilations, and only change behvaior of targetless compilations. The conversion required changing all of the LSR code to refer to the TTI interfaces, which fortunately are very similar to TargetLowering's interfaces. However, it also allowed us to *always* expect to have some implementation around. I've pushed that simplification through the pass, and leveraged it to simplify code somewhat. It required some test updates for one of two things: either we used to skip some checks altogether but now we get the default "no" answer for them, or we used to have no information about the target and now we do have some. I've also started the process of removing AddrMode, as the TTI interface doesn't use it any longer. In some cases this simplifies code, and in others it adds some complexity, but I think it's not a bad tradeoff even there. Subsequent patches will try to clean this up even further and use other (more appropriate) abstractions. Yet again, almost all of the formatting changes brought to you by clang-format. =] llvm-svn: 171735
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-021-3/+3
| | | | | | | | | | | | | | | | | | | | | into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-031-2/+2
| | | | | | | | | | | | | | | | | Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] llvm-svn: 169131
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-011-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getIntPtrType support for multiple address spaces via a pointer type, and also introduced a crasher bug in the constant folder reported in PR14233. These commits also contained several problems that should really be addressed before they are re-committed. I have avoided reverting various cleanups to the DataLayout APIs that are reasonable to have moving forward in order to reduce the amount of churn, and minimize the number of commits that were reverted. I've also manually updated merge conflicts and manually arranged for the getIntPtrType function to stay in DataLayout and to be defined in a plausible way after this revert. Thanks to Duncan for working through this exact strategy with me, and Nick Lewycky for tracking down the really annoying crasher this triggered. (Test case to follow in its own commit.) After discussing with Duncan extensively, and based on a note from Micah, I'm going to continue to back out some more of the more problematic patches in this series in order to ensure we go into the LLVM 3.2 branch with a reasonable story here. I'll send a note to llvmdev explaining what's going on and why. Summary of reverted revisions: r166634: Fix a compiler warning with an unused variable. r166607: Add some cleanup to the DataLayout changes requested by Chandler. r166596: Revert "Back out r166591, not sure why this made it through since I cancelled the command. Bleh, sorry about this! r166591: Delete a directory that wasn't supposed to be checked in yet. r166578: Add in support for getIntPtrType to get the pointer type based on the address space. llvm-svn: 167221
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-241-1/+3
| | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. llvm-svn: 166578
* revert r166264 because the LTO build is still failingNadav Rotem2012-10-191-6/+6
| | | | llvm-svn: 166340
* SCEVExpander: Don't crash when trying to merge two constant phis.Benjamin Kramer2012-10-191-0/+11
| | | | | | Just constant fold them so they can't cause any trouble. Fixes PR12627. llvm-svn: 166286
* recommit the patch that makes LSR and LowerInvoke use the TargetTransform ↵Nadav Rotem2012-10-191-6/+6
| | | | | | interface. llvm-svn: 166264
* Temporarily revert the TargetTransform changes.Bob Wilson2012-10-181-6/+6
| | | | | | | | | | | The TargetTransform changes are breaking LTO bootstraps of clang. I am working with Nadav to figure out the problem, but I am reverting it for now to get our buildbots working. This reverts svn commits: 165665 165669 165670 165786 165787 165997 and I have also reverted clang svn 165741 llvm-svn: 166168
* Add a new interface to allow IR-level passes to access codegen-specific ↵Nadav Rotem2012-10-101-6/+6
| | | | | | information. llvm-svn: 165665
* Move TargetData to DataLayout.Micah Villmow2012-10-081-6/+6
| | | | llvm-svn: 165402
* Fix a typo (the the => the)Sylvestre Ledru2012-07-231-1/+1
| | | | llvm-svn: 160621
* LSR Fix: check SCEV expression safety before expansion.Andrew Trick2012-07-131-0/+41
| | | | | | | | | | All SCEV expressions used by LSR formulae must be safe to expand. i.e. they may not contain UDiv unless we can prove nonzero denominator. Fixes PR11356: LSR hoists UDiv. llvm-svn: 160205
* LSR fix: add a missing phi check during IV hoisting.Andrew Trick2012-05-221-1/+2
| | | | | | Fixes PR12898: SCEVExpander crash. llvm-svn: 157263
* Fix this assert. IP can point to an instruction with strange dominanceRafael Espindola2012-02-271-15/+20
| | | | | | | properties (invoke). Just assert that the instruction we return dominates the insertion point. llvm-svn: 151511
* And update the comment...Rafael Espindola2012-02-261-1/+0
| | | | llvm-svn: 151472
* Enable the assert that got all this dominator work started.Rafael Espindola2012-02-261-1/+1
| | | | llvm-svn: 151471
* Change the implementation of dominates(inst, inst) to one based on what theRafael Espindola2012-02-261-6/+5
| | | | | | | | verifier does. This correctly handles invoke. Thanks to Duncan, Andrew and Chris for the comments. Thanks to Joerg for the early testing. llvm-svn: 151469
* Fix typo.Rafael Espindola2012-02-231-1/+1
| | | | llvm-svn: 151238
* Improve comment. Thanks for Andrew for the suggestion.Rafael Espindola2012-02-221-2/+3
| | | | llvm-svn: 151127
* Semantically revert 151015. Add a comment on why we should be able to assertRafael Espindola2012-02-221-7/+17
| | | | | | | | the dominance once the dominates method is fixed and why we can use the builder's insertion point. Fixes pr12048. llvm-svn: 151125
* s/the the/the/Rafael Espindola2012-02-211-1/+1
| | | | llvm-svn: 151079
* Use more idiomatic assert.Rafael Espindola2012-02-211-2/+2
| | | | llvm-svn: 151026
* Avoid warning on non assert builds.Rafael Espindola2012-02-211-2/+3
| | | | llvm-svn: 151025
* It turns out that with the current scev organization ReuseOrCreateCast cannotRafael Espindola2012-02-211-9/+9
| | | | | | | | | | | | | | know where users will be added. Because of this, it cannot use Builder.GetInsertPoint at all. This patch * removes the FIXME about adding the assert. * adds a comment explaining hy we don't have one. * removes a broken logic that only works for some callers and is not needed since r150884. * adds an assert to caller that would have caught the bug fixed by r150884. llvm-svn: 151015
* Temporarily disable this assert. Looks like it found a similar issue whenRafael Espindola2012-02-181-1/+3
| | | | | | building bullet. llvm-svn: 150885
* Don't skip debug instructions when looking for the insertion point ofRafael Espindola2012-02-181-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | the cast. If we do, we can end up with inst1 --------------- < Insertion point dbg inst new inst instead of the desired inst1 new inst --------------- < Insertion point dbg inst Another option would be for InsertNoopCastOfTo (or its callers) to move the insertion point and we would end up with inst1 dbg inst new inst --------------- < Insertion point but that complicates the callers. This fixes PR12018 (and firefox's build). llvm-svn: 150884
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-201-1/+0
| | | | llvm-svn: 148578
* SCEVExpander fixes. Affects LSR and indvars.Andrew Trick2012-01-201-115/+114
| | | | | | | | | | | | | | | | LSR has gradually been improved to more aggressively reuse existing code, particularly existing phi cycles. This exposed problems with the SCEVExpander's sloppy treatment of its insertion point. I applied some rigor to the insertion point problem that will hopefully avoid an endless bug cycle in this area. Changes: - Always used properlyDominates to check safe code hoisting. - The insertion point provided to SCEV is now considered a lower bound. This is usually a block terminator or the use itself. Under no cirumstance may SCEVExpander insert below this point. - LSR is reponsible for finding a "canonical" insertion point across expansion of different expressions. - Robust logic to determine whether IV increments are in "expanded" form and/or can be safely hoisted above some insertion point. Fixes PR11783: SCEVExpander assert. llvm-svn: 148535
* Fix a corner case hit by redundant phi elimination running after LSR.Andrew Trick2012-01-141-1/+11
| | | | | | Fixes PR11761: bad IR w/ redundant Phi elim llvm-svn: 148177
* Enable LSR IV Chains with sufficient heuristics.Andrew Trick2012-01-101-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | These heuristics are sufficient for enabling IV chains by default. Performance analysis has been done for i386, x86_64, and thumbv7. The optimization is rarely important, but can significantly speed up certain cases by eliminating spill code within the loop. Unrolled loops are prime candidates for IV chains. In many cases, the final code could still be improved with more target specific optimization following LSR. The goal of this feature is for LSR to make the best choice of induction variables. Instruction selection may not completely take advantage of this feature yet. As a result, there could be cases of slight code size increase. Code size can be worse on x86 because it doesn't support postincrement addressing. In fact, when chains are formed, you may see redundant address plus stride addition in the addressing mode. GenerateIVChains tries to compensate for the common cases. On ARM, code size increase can be mitigated by using postincrement addressing, but downstream codegen currently misses some opportunities. llvm-svn: 147826
* Cleanup comments and argument types related to my previous ↵Andrew Trick2012-01-071-4/+5
| | | | | | replaceCongruentPhis checkin. llvm-svn: 147709
* Extended replaceCongruentPhis to handle mixed phi types.Andrew Trick2012-01-071-13/+61
| | | | llvm-svn: 147707
* Expose isNonConstantNegative to users of ScalarEvolution.Andrew Trick2012-01-071-20/+6
| | | | llvm-svn: 147700
* SCEVExpander: hoistStep should check strict dominance.Andrew Trick2012-01-061-1/+1
| | | | llvm-svn: 147683
* Fix SCEVExpander to handle loops with no preheader when LSR gives it aAndrew Trick2012-01-021-0/+6
| | | | | | | | "phony" insertion point. Fixes rdar://10619599: "SelectionDAGBuilder shouldn't visit PHI nodes!" assert llvm-svn: 147439
* LSR: Fix another corner case in expansion of postinc users.Andrew Trick2011-12-201-0/+14
| | | | | | Fixes PR11571: Instruction does not dominate all uses llvm-svn: 146950
* LSR: Fold redundant bitcasts on-the-fly.Andrew Trick2011-12-141-3/+8
| | | | llvm-svn: 146597
* LSR: handle the expansion of phi operands that use postinc forms of the IV.Andrew Trick2011-11-301-36/+68
| | | | | | Fixes PR11431: SCEVExpander::expandAddRecExprLiterally(const llvm::SCEVAddRecExpr*): Assertion `(!isa<Instruction>(Result) || SE.DT->dominates(cast<Instruction>(Result), Builder.GetInsertPoint())) && "postinc expansion does not dominate use"' failed. llvm-svn: 145482
* Fix SCEVExpander assert during LSR: "argument of incompatible type".Andrew Trick2011-10-151-6/+5
| | | | | | | | | Just because we're dealing with a GEP doesn't mean we can assert the SCEV has a pointer type. The fix is simply to ignore the SCEV pointer type, which we really didn't need. Fixes PR11138 webkit crash. llvm-svn: 142058
* Reapply r141870, SCEV expansion of post-inc.Andrew Trick2011-10-131-2/+14
| | | | | | | Speculatively reapply to see if this test case still crashes on linux. I may have fixed it in my last checkin. llvm-svn: 141895
* Revert r141870. The test case crashes on linux with data corruption. A ↵Andrew Trick2011-10-131-14/+2
| | | | | | deeper issue was exposed. llvm-svn: 141873
* LSR: Reuse the post-inc expansion of expressions.Andrew Trick2011-10-131-2/+14
| | | | | | | | This avoids unnecessary expansion of expressions and allows the SCEV expander to work on expression DAGs, not just trees. Fixes PR11090. llvm-svn: 141870
* Move replaceCongruentIVs into SCEVExapander and bias toward "expanded"Andrew Trick2011-10-111-0/+100
| | | | | | | | | | | IVs. Indvars previously chose randomly between congruent IVs. Now it will bias the decision toward IVs that SCEVExpander likes to create. This was not done to fix any problem, it's just a welcome side effect of factoring code. llvm-svn: 141633
* Add an extra safety check in front of the optimization in r141442.Andrew Trick2011-10-081-0/+9
| | | | llvm-svn: 141470
* LSR should only reuse phis that match its formula.Andrew Trick2011-10-071-61/+113
| | | | | | Fixes rdar://problem/5064068 llvm-svn: 141442
* Stop emitting instructions with the name "tmp" they eat up memory and have ↵Benjamin Kramer2011-09-271-7/+7
| | | | | | | | to be uniqued, without any benefit. If someone prefers %tmp42 to %42, run instnamer. llvm-svn: 140634
* Skip the landingpad instruction when determining the insertion point.Bill Wendling2011-08-241-3/+7
| | | | llvm-svn: 138481
* Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'Bill Wendling2011-08-161-5/+2
| | | | | | check for a LandingPadInst. llvm-svn: 137745
OpenPOWER on IntegriCloud