summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert the ConstantInt constructors back to their 2.5 forms where possible, ↵Owen Anderson2009-07-241-3/+3
| | | | | | thanks to contexts-on-types. More to come. llvm-svn: 77011
* Get rid of the Pass+Context magic.Owen Anderson2009-07-221-5/+7
| | | | llvm-svn: 76702
* Switch invars away from using isTrapping when it really shouldn't be Eli Friedman2009-07-151-1/+7
| | | | | | using it. llvm-svn: 75852
* Fix indentation.Dan Gohman2009-07-151-18/+18
| | | | llvm-svn: 75723
* Require IVUsers after LCSSA, since LCSSA does not preserve IVUsers.Dan Gohman2009-07-141-3/+3
| | | | | | | This results in the pass manager running IVUsers only once for indvars, instead of twice. llvm-svn: 75633
* Fix indvars to not assume that a loop with a single unique exitDan Gohman2009-07-141-7/+5
| | | | | | block has a single unique exiting block. llvm-svn: 75579
* This started as a small change, I swear. Unfortunately, lots of things call ↵Owen Anderson2009-07-091-4/+4
| | | | | | the [I|F]CmpInst constructors. Who knew!? llvm-svn: 75200
* Change all SCEV* to SCEV *.Dan Gohman2009-07-071-12/+12
| | | | llvm-svn: 74918
* Convert the first batch of passes to use LLVMContext.Owen Anderson2009-07-031-4/+5
| | | | llvm-svn: 74748
* Request LCSSA after LoopSimplify. This fixes a problem in which theDan Gohman2009-07-011-1/+1
| | | | | | | PassManager was scheduling LCSSA before LoopSimplify, which does not preserve LCSSA. llvm-svn: 74661
* When a value is used multiple times within a single PHI, instructionsDan Gohman2009-06-271-3/+15
| | | | | | | | inserted to replace that value must dominate all of of the basic blocks associated with the uses of the value in the PHI, not just one of them. llvm-svn: 74376
* Incorporate the insertion point into the key of SCEVExpander's CSE map.Dan Gohman2009-06-261-121/+43
| | | | | | | | | | | | | | This helps it avoid reusing an instruction that doesn't dominate all of the users, in cases where the original instruction was inserted before all of the users were known. This may result in redundant expansions of sub-expressions that depend on loop-unpredictable values in some cases, however this isn't very common, and it primarily impacts IndVarSimplify, so GVN can be expected to clean these up. This eliminates the need for IndVarSimplify's FixUsesBeforeDefs, which fixes several bugs. llvm-svn: 74352
* When inserting code into a loop preheader, insert it before theDan Gohman2009-06-241-3/+6
| | | | | | | | terminator, instead of after the last phi. This fixes a bug exposed by ScalarEvolution analyzing more kinds of loops. This fixes PR4436. llvm-svn: 74072
* Extend ScalarEvolution's multiple-exit support to compute exactDan Gohman2009-06-241-27/+19
| | | | | | | | | | | | | | | trip counts in more cases. Generalize ScalarEvolution's isLoopGuardedByCond code to recognize And and Or conditions, splitting the code out into an isNecessaryCond helper function so that it can evaluate Ands and Ors recursively, and make SCEVExpander be much more aggressive about hoisting instructions out of loops. test/CodeGen/X86/pr3495.ll has an additional instruction now, but it appears to be due to an arbitrary register allocation difference. llvm-svn: 74048
* Fix a few minor issues that were exposed by the removal of SCEVHandle.Dan Gohman2009-06-221-1/+0
| | | | llvm-svn: 73910
* SCEVHandle is no more!Owen Anderson2009-06-221-13/+13
| | | | llvm-svn: 73906
* Fix this code to correctly handle loops with multiple exits. UntilDan Gohman2009-06-221-4/+4
| | | | | | | | now, this hasn't mattered, because ScalarEvolution hasn't been able to compute trip counts for loops with multiple exits. But it will soon. llvm-svn: 73864
* Add another item to the list of things that indvars does.Dan Gohman2009-06-141-1/+4
| | | | llvm-svn: 73355
* Teach SCEVExpander's visitAddRecExpr to reuse an existing canonicalDan Gohman2009-06-131-71/+24
| | | | | | | | | | | | | | | | | induction variable when the addrec to be expanded does not require a wider type. This eliminates the need for IndVarSimplify to micro-manage SCEV expansions, because SCEVExpander now automatically expands them in the form that IndVarSimplify considers to be canonical. (LSR still micro-manages its SCEV expansions, because it's optimizing for the target, rather than for other optimizations.) Also, this uses the new getAnyExtendExpr, which has more clever expression simplification logic than the IndVarSimplify code it replaces, and this cleans up some ugly expansions in code such as the included masked-iv.ll testcase. llvm-svn: 73294
* Split the Add, Sub, and Mul instruction opcodes into separateDan Gohman2009-06-041-1/+1
| | | | | | | | | | | | | | | integer and floating-point opcodes, introducing FAdd, FSub, and FMul. For now, the AsmParser, BitcodeReader, and IRBuilder all preserve backwards compatability, and the Core LLVM APIs preserve backwards compatibility for IR producers. Most front-ends won't need to change immediately. This implements the first step of the plan outlined here: http://nondot.org/sabre/LLVMNotes/IntegerOverflow.txt llvm-svn: 72897
* Don't attempt to simplify an non-affine IV expression if it can'tDan Gohman2009-06-031-12/+10
| | | | | | be simplified to a loop-invariant value. This fixes PR4315. llvm-svn: 72798
* Change ScalarEvolution::getSCEVAtScope to always return the original valueDan Gohman2009-05-241-4/+2
| | | | | | | | in the case where a loop exit value cannot be computed, instead of only in some cases while using SCEVCouldNotCompute in others. This simplifies getSCEVAtScope's callers. llvm-svn: 72375
* Move Rewriter.clear() earlier, to avoid triggerring the AssertingVH byTorok Edwin2009-05-241-2/+8
| | | | | | | one of the RecursivelyDeleteTriviallyDeadInstructions. Add a comment explaining why the cache needs to be cleared. llvm-svn: 72372
* Instead of clearing the rewriter, don't attempt to rewrite dead phi nodes.Torok Edwin2009-05-241-2/+2
| | | | | | Also fix 80 column violation. llvm-svn: 72371
* When rewriting the loop exit test with the canonical induction variable,Dan Gohman2009-05-241-1/+6
| | | | | | | leave the original comparison in place if it has other uses, since the other uses won't be dominated by the new comparison instruction. llvm-svn: 72369
* When replacing a floating-point comparison with an integerDan Gohman2009-05-241-0/+1
| | | | | | comparison, use takeName to give the integer comparison a name. llvm-svn: 72367
* The rewriter may hold references to instructions that are deleted because ↵Torok Edwin2009-05-241-0/+2
| | | | | | | | | | | they are trivially dead. Fix by clearing the rewriter cache before deleting the trivially dead instructions. Also make InsertedExpressions use an AssertingVH to catch these bugs easier. llvm-svn: 72364
* Teach IndVarSimplify's FixUsesBeforeDefs to handle InvokeInsts byDan Gohman2009-05-221-1/+5
| | | | | | | | | | | | | | | assuming that the use of the value is in a block dominated by the "normal" destination. LangRef.html and other documentation sources don't explicitly guarantee this, but it seems to be assumed in other places in LLVM at least. This fixes an assertion failure on the included testcase, which is derived from the Ada testsuite. FixUsesBeforeDefs is a temporary measure which I'm looking to replace with a more capable solution. llvm-svn: 72266
* Remove an irrelevant comment.Dan Gohman2009-05-191-3/+1
| | | | llvm-svn: 72132
* Trim unneeded #includes.Dan Gohman2009-05-191-2/+0
| | | | llvm-svn: 72130
* Teach SCEVExpander to expand arithmetic involving pointers into GEPDan Gohman2009-05-191-6/+6
| | | | | | | | | | | | | | | | instructions. It attempts to create high-level multi-operand GEPs, though in cases where this isn't possible it falls back to casting the pointer to i8* and emitting a GEP with that. Using GEP instructions instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that don't use ScalarEvolution, such as BasicAliasAnalysis. Also, make the AddrModeMatcher more aggressive in handling GEPs. Previously it assumed that operand 0 of a GEP would require a register in almost all cases. It now does extra checking and can do more matching if operand 0 of the GEP is foldable. This fixes a problem that was exposed by SCEVExpander using GEPs. llvm-svn: 72093
* Use abs64 in one more place.Dale Johannesen2009-05-141-1/+1
| | | | llvm-svn: 71775
* Factor the code for collecting IV users out of LSR into an IVUsers class,Dan Gohman2009-05-121-566/+369
| | | | | | | | | | | | | | | | | | | | | | | | and generalize it so that it can be used by IndVarSimplify. Implement the base IndVarSimplify transformation code using IVUsers. This removes TestOrigIVForWrap and associated code, as ScalarEvolution now has enough builtin overflow detection and folding logic to handle all the same cases, and more. Run "opt -iv-users -analyze -disable-output" on your favorite loop for an example of what IVUsers does. This lets IndVarSimplify eliminate IV casts and compute trip counts in more cases. Also, this happens to finally fix the remaining testcases in PR1301. Now that IndVarSimplify is being more aggressive, it occasionally runs into the problem where ScalarEvolutionExpander's code for avoiding duplicate expansions makes it difficult to ensure that all expanded instructions dominate all the instructions that will use them. As a temporary measure, IndVarSimplify now uses a FixUsesBeforeDefs function to fix up instructions inserted by SCEVExpander. Fortunately, this code is contained, and can be easily removed once a more comprehensive solution is available. llvm-svn: 71535
* Re-apply 70645, converting ScalarEvolution to useDan Gohman2009-05-041-2/+0
| | | | | | | | | | | | CallbackVH, with fixes. allUsesReplacedWith need to walk the def-use chains and invalidate all users of a value that is replaced. SCEVs of users need to be recalcualted even if the new value is equivalent. Also, make forgetLoopPHIs walk def-use chains, since any SCEV that depends on a PHI should be recalculated when more information about that PHI becomes available. llvm-svn: 70927
* Revert r70645 for now; it's causing a variety of regressions.Dan Gohman2009-05-031-0/+2
| | | | llvm-svn: 70661
* Convert ScalarEvolution to use CallbackVH for its internal map. ThisDan Gohman2009-05-021-2/+0
| | | | | | | | | makes ScalarEvolution::deleteValueFromRecords, and it's code that subtly needed to be called before ReplaceAllUsesWith, unnecessary. It also makes ValueDeletionListener unnecessary. llvm-svn: 70645
* Remove an obsolete comment.Dan Gohman2009-04-271-5/+3
| | | | llvm-svn: 70262
* Fix PR 4086, a bug in FP IV elimination.Dale Johannesen2009-04-271-2/+4
| | | | llvm-svn: 70247
* Change SCEVExpander's expandCodeFor to provide more flexibilityDan Gohman2009-04-231-15/+12
| | | | | | | | | | | with the persistent insertion point, and change IndVars to make use of it. This fixes a bug where IndVars was holding on to a stale insertion point and forcing the SCEVExpander to continue to use it. This fixes PR4038. llvm-svn: 69892
* Make sure both operands have binary instructions have the same type.Evan Cheng2009-04-221-11/+23
| | | | llvm-svn: 69844
* A few more places where the check of use_empty is needed.Evan Cheng2009-04-221-0/+3
| | | | llvm-svn: 69842
* Avoid deferencing use_begin() if value does not have a use.Evan Cheng2009-04-221-0/+1
| | | | llvm-svn: 69836
* Introduce encapsulation for ScalarEvolution's TargetData object, and refactorDan Gohman2009-04-211-20/+20
| | | | | | the code to minimize dependencies on TargetData. llvm-svn: 69644
* Use more const qualifiers with SCEV interfaces.Dan Gohman2009-04-181-4/+5
| | | | llvm-svn: 69450
* Expand GEPs in ScalarEvolution expressions. SCEV expressions can nowDan Gohman2009-04-161-122/+35
| | | | | | | | | | | | | | | | | | | | | have pointer types, though in contrast to C pointer types, SCEV addition is never implicitly scaled. This not only eliminates the need for special code like IndVars' EliminatePointerRecurrence and LSR's own GEP expansion code, it also does a better job because it lets the normal optimizations handle pointer expressions just like integer expressions. Also, since LLVM IR GEPs can't directly index into multi-dimensional VLAs, moving the GEP analysis out of client code and into the SCEV framework makes it easier for clients to handle multi-dimensional VLAs the same way as other arrays. Some existing regression tests show improved optimization. test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to the point where if-conversion started kicking in; I turned it off for this test to preserve the intent of the test. llvm-svn: 69258
* Eliminate zext over (iv | const) or (signed iv),Dale Johannesen2009-04-151-22/+77
| | | | | | | | and sext over (iv | const), if a longer iv is available. Allow expressions to have more than one zext/sext parent. All from OpenSSL. llvm-svn: 69241
* Eliminate zext over (iv & const) or ((iv+const)&const)Dale Johannesen2009-04-151-31/+89
| | | | | | | if a longer iv is available. These subscript forms are not common; they're a bottleneck in OpenSSL. llvm-svn: 69215
* Enhance induction variable code to remove theDale Johannesen2009-04-151-40/+121
| | | | | | | | | sext around sext(shorter IV + constant), using a longer IV instead, when it can figure out the add can't overflow. This comes up a lot in subscripting; mainly affects 64 bit. llvm-svn: 69123
* Rename ScalarEvolution's getIterationCount to getBackedgeTakenCount,Dan Gohman2009-02-241-36/+35
| | | | | | | | | to more accurately describe what it does. Expand its doxygen comment to describe what the backedge-taken count is and how it differs from the actual iteration count of the loop. Adjust names and comments in associated code accordingly. llvm-svn: 65382
* Back out the change in 64918 that used sign-extensions when promotingDan Gohman2009-02-231-34/+12
| | | | | | | | | trip counts that use signed comparisons. It's not obviously the best approach for preserving trip count information, and at any rate there isn't anything in the tree right now that makes use of that, so for now always using zero-extensions is preferable. llvm-svn: 65347
OpenPOWER on IntegriCloud