summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/IndVarSimplify
Commit message (Collapse)AuthorAgeFilesLines
...
* Generalize isLoopGuardedByCond's checking to consider twoDan Gohman2009-06-201-0/+107
| | | | | | | | | | SCEVUnknowns with identical Instructions to be equal. This allows it to analze cases such as the attached testcase, where the front-end has cloned the loop controlling expression. Along with r73805, this lets IndVarSimplify eliminate all the sign-extend casts in the loop in the attached testcase. llvm-svn: 73807
* Remove the code from IVUsers that attempted to handleDan Gohman2009-06-182-2/+5
| | | | | | | | | | | casted induction variables in cases where the cast isn't foldable. It ended up being a pessimization in many cases. This could be fixed, but it would require a bunch of complicated code in IVUsers' clients. The advantages of this approach aren't visible enough to justify it at this time. llvm-svn: 73706
* Add -disable-output to a bunch of tests that don't care about the output.Dan Gohman2009-06-171-1/+1
| | | | llvm-svn: 73633
* Instcombine's ShrinkDemandedConstant may strip bits out of constants,Dan Gohman2009-06-161-0/+14
| | | | | | | | obscuring what would otherwise be a low-bits mask. Use ComputeMaskedBits to compute what ShrinkDemandedConstant knew about to reconstruct a low-bits mask value. llvm-svn: 73540
* Implement more aggressive folding of add operand lists whenDan Gohman2009-06-141-0/+38
| | | | | | | | | | they contain multiplications of constants with add operations. This helps simplify several kinds of things; in particular it helps simplify expressions like ((-1 * (%a + %b)) + %a) to %b, as expressions like this often come up in loop trip count computations. llvm-svn: 73361
* Teach SCEVExpander's visitAddRecExpr to reuse an existing canonicalDan Gohman2009-06-132-1/+25
| | | | | | | | | | | | | | | | | 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-046-12/+12
| | | | | | | | | | | | | | | 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-032-0/+43
| | | | | | be simplified to a loop-invariant value. This fixes PR4315. llvm-svn: 72798
* Teach SCEVExpander to avoid creating over-indexed GEP indices whenDan Gohman2009-05-271-0/+19
| | | | | | | | | | | | possible. For example, it now emits %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 2, i64 %tmp, i64 1 instead of the equivalent but less obvious %p.2.ip.1 = getelementptr [3 x [3 x double]]* %p, i64 0, i64 %tmp, i64 19 llvm-svn: 72452
* In cases where a pointer value is an operand of a multiplication orDan Gohman2009-05-261-0/+95
| | | | | | | division operation, don't attempt to use the operation's value as the base of a getelementptr. This fixes PR4271. llvm-svn: 72422
* When rewriting the loop exit test with the canonical induction variable,Dan Gohman2009-05-241-0/+36
| | | | | | | 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
* Generalize SCEVExpander::visitAddRecExpr's GEP persuit, and avoidDan Gohman2009-05-242-1/+79
| | | | | | | | | | | | | | | sending SCEVUnknowns to expandAddToGEP. This avoids the need for expandAddToGEP to bend the rules and peek into SCEVUnknown expressions. Factor out the code for testing whether a SCEV can be factored by a constant for use in a GEP index. This allows it to handle SCEVAddRecExprs, by recursing. As a result, SCEVExpander can now put more things in GEP indices, so it emits fewer explicit mul instructions. llvm-svn: 72366
* The rewriter may hold references to instructions that are deleted because ↵Torok Edwin2009-05-241-0/+41
| | | | | | | | | | | 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-0/+57
| | | | | | | | | | | | | | | 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
* Fix a thinko in the code that adapted SCEVMulExpr operands forDan Gohman2009-05-221-0/+58
| | | | | | | use in expanding SCEVAddExprs with GEPs. The operands of a SCEVMulExpr need to be multiplied together, not added. llvm-svn: 72250
* Teach SCEVExpander to expand arithmetic involving pointers into GEPDan Gohman2009-05-191-0/+39
| | | | | | | | | | | | | | | | 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
* Add nounwind to a few tests.Dan Gohman2009-05-181-1/+1
| | | | llvm-svn: 72002
* Factor the code for collecting IV users out of LSR into an IVUsers class,Dan Gohman2009-05-124-2/+153
| | | | | | | | | | | | | | | | | | | | | | | | 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
* When forgetting SCEVs for loop PHIs, don't forget SCEVUnknown values.Dan Gohman2009-05-121-0/+32
| | | | | | | | | These values aren't analyzable, so they don't care if more information about the loop trip count can be had. Also, SCEVUnknown is used for a PHI while the PHI itself is being analyzed, so it needs to be left in the Scalars map. This fixes a variety of subtle issues. llvm-svn: 71533
* Make this testcase slightly less trivial, so that it doesn't failDan Gohman2009-04-281-1/+2
| | | | | | | if indvars happens to optimize away the unused primary induction variable. llvm-svn: 70333
* Fix PR 4086, a bug in FP IV elimination.Dale Johannesen2009-04-271-0/+18
| | | | llvm-svn: 70247
* Handle ands with ~0 correctly too. This fixes PR4052.Dan Gohman2009-04-271-0/+103
| | | | llvm-svn: 70176
* Handle ands with 0 and shifts by 0 correctly. These aren'tDan Gohman2009-04-251-0/+23
| | | | | | common, but indvars shouldn't crash on them. This fixes PR4054. llvm-svn: 70051
* Fix an error in this test.Dan Gohman2009-04-231-1/+3
| | | | llvm-svn: 69893
* Change SCEVExpander's expandCodeFor to provide more flexibilityDan Gohman2009-04-231-0/+24
| | | | | | | | | | | 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-1/+19
| | | | llvm-svn: 69844
* Avoid deferencing use_begin() if value does not have a use.Evan Cheng2009-04-221-0/+17
| | | | llvm-svn: 69836
* SCEVExpander's InsertCastOfTo knows how to move existing castDan Gohman2009-04-221-0/+24
| | | | | | | | | | | instructions in order to avoid inserting new ones. However, if the cast instruction is the SCEVExpander's InsertPt, this causes subsequently emitted instructions to be inserted near the cast, and not at the location of the original insert point. Fix this by adjusting the insert point in such cases. This fixes PR4009. llvm-svn: 69808
* Another testcase for IV shortening.Dale Johannesen2009-04-161-0/+161
| | | | llvm-svn: 69247
* Enhance induction variable code to remove theDale Johannesen2009-04-151-0/+114
| | | | | | | | | 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
* Back out the change in 64918 that used sign-extensions when promotingDan Gohman2009-02-233-7/+3
| | | | | | | | | 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
* Use a sign-extend instead of a zero-extend when promoting aDan Gohman2009-02-183-4/+37
| | | | | | | | | | | | trip count value when the original loop iteration condition is signed and the canonical induction variable won't undergo signed overflow. This isn't required for correctness; it just preserves more information about original loop iteration values. Add a getTruncateOrSignExtend method to ScalarEvolution, following getTruncateOrZeroExtend. llvm-svn: 64918
* Fix a corner case in the new indvars promotion logic: if thereDan Gohman2009-02-181-0/+38
| | | | | | | | | | are multiple IV's in a loop, some of them may under go signed or unsigned wrapping even if the IV that's used in the loop exit condition doesn't. Restrict sign-extension-elimination and zero-extension-elimination to only those that operate on the original loop-controlling IV. llvm-svn: 64866
* Rename IndVarsSimplify to IndVarSimplify, to be consistent withDan Gohman2009-02-1645-0/+1767
the name used in the code that these tests are for. llvm-svn: 64624
OpenPOWER on IntegriCloud