summaryrefslogtreecommitdiff
path: root/lib/Analysis/ScalarEvolutionExpander.cpp
Commit message (Collapse)AuthorAge
* Fix SCEVExpander: don't try to expand quadratic recurrences outside a loop.Andrew Trick2013-10-25
| | | | | | | | | | | | Partial fix for PR17459: wrong code at -O3 on x86_64-linux-gnu (affecting trunk and 3.3) When SCEV expands a recurrence outside of a loop it attempts to scale by the stride of the recurrence. Chained recurrences don't work that way. We could compute binomial coefficients, but would hve to guarantee that the chained AddRec's are in a perfectly reduced form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193438 91177308-0d34-0410-b5e6-96231b3b80d8
* SCEVExpander: Fix a regression I introduced by to eagerly adding RAII objects.Benjamin Kramer2013-10-01
| | | | | | PR17425. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191741 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert manual insert point restores to the new RAII object.Benjamin Kramer2013-09-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191675 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach ScalarEvolution about pointer address spacesMatt Arsenault2013-09-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190425 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix SCEVExpander creating distinct duplicate PHI entriesHal Finkel2013-08-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes SCEVExpander so that it does not create multiple distinct induction variables for duplicate PHI entries. Specifically, given some code like this: do.body6: ; preds = %do.body6, %do.body6, %if.then5 %end.0 = phi i8* [ undef, %if.then5 ], [ %incdec.ptr, %do.body6 ], [ %incdec.ptr, %do.body6 ] ... Note that it is legal to have multiple entries for a basic block so long as the associated value is the same. So the above input is okay, but expanding an AddRec in this loop could produce code like this: do.body6: ; preds = %do.body6, %do.body6, %if.then5 %indvar = phi i64 [ %indvar.next, %do.body6 ], [ %indvar.next1, %do.body6 ], [ 0, %if.then5 ] %end.0 = phi i8* [ undef, %if.then5 ], [ %incdec.ptr, %do.body6 ], [ %incdec.ptr, %do.body6 ] ... %indvar.next = add i64 %indvar, 1 %indvar.next1 = add i64 %indvar, 1 And this is not legal because there are two PHI entries for %do.body6 each with a distinct value. Unfortunately, I don't have an in-tree test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188614 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove a bunch of old SCEVExpander FIXME's for preserving NoWrap.Andrew Trick2013-07-14
| | | | | | | | | | | | | | | The great thing about the SCEVAddRec No-Wrap flag (unlike nsw/nuw) is that is can be preserved while normalizing (reassociating and factoring). The bad thing is that is can't be tranfered back to IR, which is one of the reasons I don't like the concept of SCEVExpander. Sorry, I can't think of a direct way to test this, which is why these were FIXMEs for so long. I just think it's a good time to finally clean it up. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186273 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach indvars to generate nsw/nuw flags when widening an induction variable.Andrew Trick2013-07-14
| | | | | | Fixes PR16600. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186272 91177308-0d34-0410-b5e6-96231b3b80d8
* SCEVExpander fix. RAUW needs to update the InsertedExpressions cache.Andrew Trick2013-01-14
| | | | | | | | Note that this bug is only exposed because LTO fails to use TTI. Fixes self-LTO of clang. rdar://13007381. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172462 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the SCEV expander and LoopStrengthReduce to useChandler Carruth2013-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171735 91177308-0d34-0410-b5e6-96231b3b80d8
* Move all of the header files which are involved in modelling the LLVM IRChandler Carruth2013-01-02
| | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171366 91177308-0d34-0410-b5e6-96231b3b80d8
* Use the new script to sort the includes of every file under lib.Chandler Carruth2012-12-03
| | | | | | | | | | | | | | | | | 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. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert the series of commits starting with r166578 which introduced theChandler Carruth2012-11-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167221 91177308-0d34-0410-b5e6-96231b3b80d8
* Add in support for getIntPtrType to get the pointer type based on the ↵Micah Villmow2012-10-24
| | | | | | | | | | address space. This checkin also adds in some tests that utilize these paths and updates some of the clients. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166578 91177308-0d34-0410-b5e6-96231b3b80d8
* revert r166264 because the LTO build is still failingNadav Rotem2012-10-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166340 91177308-0d34-0410-b5e6-96231b3b80d8
* SCEVExpander: Don't crash when trying to merge two constant phis.Benjamin Kramer2012-10-19
| | | | | | Just constant fold them so they can't cause any trouble. Fixes PR12627. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166286 91177308-0d34-0410-b5e6-96231b3b80d8
* recommit the patch that makes LSR and LowerInvoke use the TargetTransform ↵Nadav Rotem2012-10-19
| | | | | | interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166264 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily revert the TargetTransform changes.Bob Wilson2012-10-18
| | | | | | | | | | | 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166168 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a new interface to allow IR-level passes to access codegen-specific ↵Nadav Rotem2012-10-10
| | | | | | information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165665 91177308-0d34-0410-b5e6-96231b3b80d8
* Move TargetData to DataLayout.Micah Villmow2012-10-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165402 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a typo (the the => the)Sylvestre Ledru2012-07-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160621 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR Fix: check SCEV expression safety before expansion.Andrew Trick2012-07-13
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160205 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR fix: add a missing phi check during IV hoisting.Andrew Trick2012-05-22
| | | | | | Fixes PR12898: SCEVExpander crash. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157263 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix this assert. IP can point to an instruction with strange dominanceRafael Espindola2012-02-27
| | | | | | | properties (invoke). Just assert that the instruction we return dominates the insertion point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151511 91177308-0d34-0410-b5e6-96231b3b80d8
* And update the comment...Rafael Espindola2012-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151472 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable the assert that got all this dominator work started.Rafael Espindola2012-02-26
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151471 91177308-0d34-0410-b5e6-96231b3b80d8
* Change the implementation of dominates(inst, inst) to one based on what theRafael Espindola2012-02-26
| | | | | | | | verifier does. This correctly handles invoke. Thanks to Duncan, Andrew and Chris for the comments. Thanks to Joerg for the early testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151469 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix typo.Rafael Espindola2012-02-23
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151238 91177308-0d34-0410-b5e6-96231b3b80d8
* Improve comment. Thanks for Andrew for the suggestion.Rafael Espindola2012-02-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151127 91177308-0d34-0410-b5e6-96231b3b80d8
* Semantically revert 151015. Add a comment on why we should be able to assertRafael Espindola2012-02-22
| | | | | | | | the dominance once the dominates method is fixed and why we can use the builder's insertion point. Fixes pr12048. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151125 91177308-0d34-0410-b5e6-96231b3b80d8
* s/the the/the/Rafael Espindola2012-02-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151079 91177308-0d34-0410-b5e6-96231b3b80d8
* Use more idiomatic assert.Rafael Espindola2012-02-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151026 91177308-0d34-0410-b5e6-96231b3b80d8
* Avoid warning on non assert builds.Rafael Espindola2012-02-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151025 91177308-0d34-0410-b5e6-96231b3b80d8
* It turns out that with the current scev organization ReuseOrCreateCast cannotRafael Espindola2012-02-21
| | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151015 91177308-0d34-0410-b5e6-96231b3b80d8
* Temporarily disable this assert. Looks like it found a similar issue whenRafael Espindola2012-02-18
| | | | | | building bullet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150885 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't skip debug instructions when looking for the insertion point ofRafael Espindola2012-02-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150884 91177308-0d34-0410-b5e6-96231b3b80d8
* More dead code removal (using -Wunreachable-code)David Blaikie2012-01-20
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148578 91177308-0d34-0410-b5e6-96231b3b80d8
* SCEVExpander fixes. Affects LSR and indvars.Andrew Trick2012-01-20
| | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148535 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a corner case hit by redundant phi elimination running after LSR.Andrew Trick2012-01-14
| | | | | | | Fixes PR11761: bad IR w/ redundant Phi elim git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@148177 91177308-0d34-0410-b5e6-96231b3b80d8
* Enable LSR IV Chains with sufficient heuristics.Andrew Trick2012-01-10
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147826 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup comments and argument types related to my previous ↵Andrew Trick2012-01-07
| | | | | | replaceCongruentPhis checkin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147709 91177308-0d34-0410-b5e6-96231b3b80d8
* Extended replaceCongruentPhis to handle mixed phi types.Andrew Trick2012-01-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147707 91177308-0d34-0410-b5e6-96231b3b80d8
* Expose isNonConstantNegative to users of ScalarEvolution.Andrew Trick2012-01-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147700 91177308-0d34-0410-b5e6-96231b3b80d8
* SCEVExpander: hoistStep should check strict dominance.Andrew Trick2012-01-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147683 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix SCEVExpander to handle loops with no preheader when LSR gives it aAndrew Trick2012-01-02
| | | | | | | | | "phony" insertion point. Fixes rdar://10619599: "SelectionDAGBuilder shouldn't visit PHI nodes!" assert git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147439 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR: Fix another corner case in expansion of postinc users.Andrew Trick2011-12-20
| | | | | | | Fixes PR11571: Instruction does not dominate all uses git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146950 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR: Fold redundant bitcasts on-the-fly.Andrew Trick2011-12-14
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146597 91177308-0d34-0410-b5e6-96231b3b80d8
* LSR: handle the expansion of phi operands that use postinc forms of the IV.Andrew Trick2011-11-30
| | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145482 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix SCEVExpander assert during LSR: "argument of incompatible type".Andrew Trick2011-10-15
| | | | | | | | | | 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142058 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r141870, SCEV expansion of post-inc.Andrew Trick2011-10-13
| | | | | | | | Speculatively reapply to see if this test case still crashes on linux. I may have fixed it in my last checkin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141895 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r141870. The test case crashes on linux with data corruption. A ↵Andrew Trick2011-10-13
| | | | | | deeper issue was exposed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141873 91177308-0d34-0410-b5e6-96231b3b80d8