summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Revert the ConstantInt constructors back to their 2.5 forms where possible, ↵Owen Anderson2009-07-241-5/+3
| | | | | | thanks to contexts-on-types. More to come. llvm-svn: 77011
* Get rid of the Pass+Context magic.Owen Anderson2009-07-221-9/+19
| | | | llvm-svn: 76702
* Make Loop and MachineLoop be subclasses of LoopBase, rather than typedefs,Dan Gohman2009-07-131-1/+1
| | | | | | | | | | using the Curiously Recurring Template Pattern with LoopBase. This will help further refactoring, and future functionality for Loop. Also, Headers can now foward-declare Loop, instead of pulling in LoopInfo.h or doing tricks. llvm-svn: 75519
* This started as a small change, I swear. Unfortunately, lots of things call ↵Owen Anderson2009-07-091-5/+4
| | | | | | the [I|F]CmpInst constructors. Who knew!? llvm-svn: 75200
* Change all SCEV* to SCEV *.Dan Gohman2009-07-071-103/+103
| | | | llvm-svn: 74918
* Second batch of passes using LLVMContext.Owen Anderson2009-07-031-8/+9
| | | | llvm-svn: 74753
* Extend ScalarEvolution's multiple-exit support to compute exactDan Gohman2009-06-241-10/+2
| | | | | | | | | | | | | | | 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
* Don't emit a redundant BitCastInst if the value to be defined in theDan Gohman2009-06-241-1/+2
| | | | | | preheader is already an instruction. llvm-svn: 74031
* SCEVHandle is no more!Owen Anderson2009-06-221-103/+103
| | | | llvm-svn: 73906
* Rename a variable for consistency with the ExitBlock vs ExitingBlockDan Gohman2009-06-211-6/+6
| | | | | | terminology that LoopInfo uses. llvm-svn: 73863
* Fix a typo in a comment that Frits von Bommel noticed.Dan Gohman2009-06-191-1/+1
| | | | llvm-svn: 73796
* Re-apply r73718, now that the fix in r73787 is in, and add aDan Gohman2009-06-191-30/+36
| | | | | | | hand-crafted testcase which demonstrates the bug that was exposed in 254.gap. llvm-svn: 73793
* Fix LSR's OptimizeSMax to ignore max operators with more than 2 operands,Dan Gohman2009-06-191-0/+5
| | | | | | which it isn't prepared to handle. llvm-svn: 73787
* Revert 73718. It's breaking 254.gap.Evan Cheng2009-06-191-35/+29
| | | | llvm-svn: 73783
* Generalize LSR's OptimizeSMax to handle unsigned max tests as wellDan Gohman2009-06-181-29/+35
| | | | | | | as signed max tests. Along with r73717, this helps CodeGen avoid emitting code for a maximum operation for this class of loop. llvm-svn: 73718
* Remove the code from IVUsers that attempted to handleDan Gohman2009-06-181-16/+2
| | | | | | | | | | | 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
* Update comments to use doxygen syntax.Dan Gohman2009-06-171-11/+11
| | | | llvm-svn: 73621
* Support vector casts in more places, fixing a variety of assertionDan Gohman2009-06-151-7/+7
| | | | | | | | | | | | | | | failures. To support this, add some utility functions to Type to help support vector/scalar-independent code. Change ConstantInt::get and ConstantFP::get to support vector types, and add an overload to ConstantInt::get that uses a static IntegerType type, for convenience. Introduce a new getConstant method for ScalarEvolution, to simplify common use cases. llvm-svn: 73431
* Convert several parts of the ScalarEvolution framework to useDan Gohman2009-06-141-8/+8
| | | | | | SmallVector instead of std::vector. llvm-svn: 73357
* Simplify.Devang Patel2009-06-051-15/+5
| | | | llvm-svn: 72965
* Split the Add, Sub, and Mul instruction opcodes into separateDan Gohman2009-06-041-1/+2
| | | | | | | | | | | | | | | 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
* Revert 72493 and replace it with a more conservative fix, for now: don'tDan Gohman2009-05-271-7/+8
| | | | | | | | rewrite the comparison if there is any implicit extension or truncation on the induction variable. I'm planning for IVUsers to eventually take over some of the work of this code, and for it to be generalized. llvm-svn: 72496
* In ChangeCompareStride, when the stride to be reused is truncated toDan Gohman2009-05-271-2/+7
| | | | | | | a smaller type, promoted its offset back up to the type of the new comparison. This fixes PR4222. llvm-svn: 72493
* Suppress the IV reversal transformation in the case that the RHSDan Gohman2009-05-201-0/+5
| | | | | | | | of the comparison is defined inside the loop. This fixes a use-before-def problem, because the transformation puts a use of the RHS outside the loop. llvm-svn: 72149
* Add some more comments to the top of this file.Dan Gohman2009-05-191-1/+8
| | | | llvm-svn: 72131
* Trim unneeded #includes.Dan Gohman2009-05-191-1/+0
| | | | llvm-svn: 72130
* Teach SCEVExpander to expand arithmetic involving pointers into GEPDan Gohman2009-05-191-12/+13
| | | | | | | | | | | | | | | | 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
* Rename UseTy to AccessTy, for consistency with getAccessType, and toDan Gohman2009-05-181-24/+25
| | | | | | avoid ambiguity with the word "use" in IVStrideUse. llvm-svn: 72012
* Add an int64_t variant of abs, for host environmentsDale Johannesen2009-05-131-3/+3
| | | | | | | | | | | without one. Use it where we were using abs on int64_t objects. (I strongly suspect the casts to unsigned in the fragments in LoopStrengthReduce are not doing whatever the original intent was, but the obvious change to uint64_t doesn't work. Maybe later.) llvm-svn: 71612
* Factor the code for collecting IV users out of LSR into an IVUsers class,Dan Gohman2009-05-121-354/+215
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Teach LSR to optimize more loop exit compares, i.e. change them to use ↵Evan Cheng2009-05-111-43/+139
| | | | | | | | postinc iv value. Previously LSR would only optimize those which are in the loop latch block. However, if LSR can prove it is safe (and profitable), it's now possible to change those not in the latch blocks to use postinc values. Also, if the compare is the only use, LSR would place the iv increment instruction before the compare instead in the latch. llvm-svn: 71485
* Reverse a loop that is counting up to a maximum toDale Johannesen2009-05-111-6/+118
| | | | | | | | count down to 0 instead, under very restricted circumstances. Adjust 4 testcases in which this optimization fires. llvm-svn: 71439
* Factor out code that optimize loop terminating condition.Evan Cheng2009-05-091-0/+9
| | | | llvm-svn: 71305
* Unbreak the build.Evan Cheng2009-05-061-1/+1
| | | | llvm-svn: 71091
* Make sure to use signed arithmetic in APInt to fix a regression.David Greene2009-05-061-2/+3
| | | | llvm-svn: 71090
* Fix a copy+pasto in a comment.Dan Gohman2009-05-051-1/+1
| | | | llvm-svn: 71035
* Delete a FIXME which is no longer relevant, and add a FIXME that is.Dan Gohman2009-05-051-2/+3
| | | | llvm-svn: 71033
* Temporarily reverting r71008. It was causing this failure:Bill Wendling2009-05-051-3/+2
| | | | | | | | | | | | Running /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/ CodeGen/X86/dg.exp ... FAIL: /Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/test/ CodeGen/X86/change-compare-stride-1.ll Failed with exit(1) at line 2 while running: grep {cmpq $-478,} change-compare-stride-1.ll.tmp child process exited abnormally llvm-svn: 71013
* Handle overflow of 64-bit loop conditions.David Greene2009-05-051-2/+3
| | | | llvm-svn: 71008
* Re-apply 70645, converting ScalarEvolution to useDan Gohman2009-05-041-21/+4
| | | | | | | | | | | | 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
* Constify a bunch of SCEV-using code.Dan Gohman2009-05-041-4/+4
| | | | llvm-svn: 70919
* Revert r70645 for now; it's causing a variety of regressions.Dan Gohman2009-05-031-3/+20
| | | | llvm-svn: 70661
* Convert ScalarEvolution to use CallbackVH for its internal map. ThisDan Gohman2009-05-021-20/+3
| | | | | | | | | makes ScalarEvolution::deleteValueFromRecords, and it's code that subtly needed to be called before ReplaceAllUsesWith, unnecessary. It also makes ValueDeletionListener unnecessary. llvm-svn: 70645
* Previously, RecursivelyDeleteDeadInstructions provided an optionDan Gohman2009-05-021-36/+15
| | | | | | | | | | | | | | | | | | of returning a list of pointers to Values that are deleted. This was unsafe, because the pointers in the list are, by nature of what RecursivelyDeleteDeadInstructions does, always dangling. Replace this with a simple callback mechanism. This may eventually be removed if all clients can reasonably be expected to use CallbackVH. Use this to factor out the dead-phi-cycle-elimination code from LSR utility function, and generalize it to use the RecursivelyDeleteTriviallyDeadInstructions utility function. This makes LSR more aggressive about eliminating dead PHI cycles; adjust tests to either be less trivial or to simply expect fewer instructions. llvm-svn: 70636
* Don't split critical edges during the AddUsersIfInteresting phaseDan Gohman2009-05-021-14/+1
| | | | | | | | | | | | | of LSR. This makes the AddUsersIfInteresting phase of LSR a pure analysis instead of a phase that potentially does CFG modifications. The conditions where this code would actually perform a split are rare, and in the cases where it actually would do a split the split is usually undone by CodeGenPrepare, and in cases where splits actually survive into codegen, they appear to hurt more often than they help. llvm-svn: 70625
* Make RequiresTypeConversion canonicalize the types before calling theDan Gohman2009-05-011-1/+3
| | | | | | | | target hooks canLosslesslyBitCastTo and isTruncateFree. This allows targets to avoid worrying about handling all combinations of integer and pointer types. llvm-svn: 70555
* Minor whitespace fix.Dan Gohman2009-05-011-1/+1
| | | | llvm-svn: 70551
* Fix some code to work if TargetLowering is not available.Dan Gohman2009-05-011-4/+8
| | | | llvm-svn: 70546
* Print correct instruction in dump.Dale Johannesen2009-04-291-1/+1
| | | | llvm-svn: 70427
* Permit ChangeCompareStride to rewrite a comparison when the factorDan Gohman2009-04-271-1/+3
| | | | | | | between the comparison's iv stride and the candidate stride is exactly -1. llvm-svn: 70244
OpenPOWER on IntegriCloud