summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
Commit message (Collapse)AuthorAgeFilesLines
* Factor the code for collecting IV users out of LSR into an IVUsers class,Dan Gohman2009-05-122-920/+584
| | | | | | | | | | | | | | | | | | | | | | | | 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
* Rename PaddedSize to AllocSize, in the hope that thisDuncan Sands2009-05-097-47/+47
| | | | | | | will make it more obvious what it represents, and stop it being confused with the StoreSize. llvm-svn: 71349
* Factor out code that optimize loop terminating condition.Evan Cheng2009-05-091-0/+9
| | | | llvm-svn: 71305
* fix RewriteStoreUserOfWholeAlloca to use the correct type sizeChris Lattner2009-05-081-4/+6
| | | | | | | | | method, fixing a crash on PR4146. While the store will ultimately overwrite the "padded size" number of bits in memory, the stored value may be a subset of this size. This function only wants to handle the case where all bits are stored. llvm-svn: 71224
* This transform requires valid TargetData info. Wrap it in 'if (TD)' inNick Lewycky2009-05-081-25/+27
| | | | | | preparation for the day we use null TargetData when no target is specified. llvm-svn: 71210
* PR4123: don't crash when inlining a call which uses its own result.Eli Friedman2009-05-081-3/+10
| | | | llvm-svn: 71199
* Perform constant folding on operands of instructions with non-voidDan Gohman2009-05-071-1/+3
| | | | | | types, such as loads and calls. llvm-svn: 71175
* 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
* Simplify code by using SmallVector's pop_back_val() instead ofDan Gohman2009-05-064-12/+6
| | | | | | separate back() and pop_back() calls. llvm-svn: 71089
* Fix PR3754: don't mark functions that wrap MallocInst withDuncan Sands2009-05-061-0/+5
| | | | | | | | the readnone. Since MallocInst is scheduled for deletion it doesn't seem worth doing anything more subtle, such as having mayWriteToMemory return true for MallocInst. llvm-svn: 71077
* Allow readonly functions to unwind exceptions. TeachDuncan Sands2009-05-069-21/+16
| | | | | | | | the optimizers about this. For example, a readonly function with no uses cannot be removed unless it is also marked nounwind. llvm-svn: 71071
* 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-045-52/+10
| | | | | | | | | | | | 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
* fix some problems spotted by Duncan and Nicolas GeoffrayChris Lattner2009-05-041-2/+2
| | | | llvm-svn: 70872
* * Sink 4 duplicates of edge threading validity checks and DOUT prints intoChris Lattner2009-05-041-71/+84
| | | | | | | | | | ThreadEdge directly. This shares the code, but is just a refactoring. * Make JumpThreading compute the set of loop headers and avoid threading across them. This prevents jump threading from forming irreducible loops (goodness) but also prevents it from threading in other cases that are beneficial (see the comment above FindFunctionBackedges). llvm-svn: 70820
* Factor loop backedge finding out of CodeGenPrepare into a new Chris Lattner2009-05-042-42/+59
| | | | | | FindFunctionBackedges function. llvm-svn: 70819
* Revert r70645 for now; it's causing a variety of regressions.Dan Gohman2009-05-035-9/+51
| | | | llvm-svn: 70661
* Revert r70630. Go back to appending ".b" to internal globals when shrinkingNick Lewycky2009-05-031-4/+2
| | | | | | them to bool. llvm-svn: 70653
* Convert ScalarEvolution to use CallbackVH for its internal map. ThisDan Gohman2009-05-025-51/+9
| | | | | | | | | makes ScalarEvolution::deleteValueFromRecords, and it's code that subtly needed to be called before ReplaceAllUsesWith, unnecessary. It also makes ValueDeletionListener unnecessary. llvm-svn: 70645
* The second argument to RecursivelyDeleteTriviallyDeadInstructions hasDan Gohman2009-05-021-2/+2
| | | | | | a default value, and will hopefully be going away soon. llvm-svn: 70642
* Previously, RecursivelyDeleteDeadInstructions provided an optionDan Gohman2009-05-023-41/+77
| | | | | | | | | | | | | | | | | | 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
* Tell ScalarEvolution that the loop is being deleted before actuallyDan Gohman2009-05-021-3/+5
| | | | | | | deleting it. This will let ScalarEvolution be more complete about updating its records. llvm-svn: 70632
* Don't append ".b" to the names of globals that are being shrunk to booleans.Nick Lewycky2009-05-021-2/+4
| | | | llvm-svn: 70630
* 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
* Reword and tidy up some comments.Dan Gohman2009-04-291-10/+21
| | | | llvm-svn: 70416
* 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
* 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
* Return null instead of false, as appropriate.Dan Gohman2009-04-251-3/+3
| | | | llvm-svn: 70054
* Add several more icmp simplifications. Transform signed comparisonsDan Gohman2009-04-251-82/+159
| | | | | | | into unsigned ones when the operands are known to have the same sign bit value. llvm-svn: 70053
* Allow i16 type indices to gep.Sanjiv Gupta2009-04-241-6/+1
| | | | llvm-svn: 69946
* 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
* Real fix for PR3549, by using caching for predecessor counts in addition to ↵Owen Anderson2009-04-221-11/+13
| | | | | | | | the predecessors themselves. This halves the time to optimize the testcase, beyond what my previous patch did. llvm-svn: 69792
* Use PredIteratorCache in LCSSA, which gives a 37% overall speedup on the ↵Owen Anderson2009-04-221-2/+5
| | | | | | testcase from PR3549. More improvements to come. llvm-svn: 69788
* use predicate instead of hand-rolled loopChris Lattner2009-04-211-11/+4
| | | | llvm-svn: 69752
* fix a crash on a pointless but valid zero-length memset, rdar://6808691Chris Lattner2009-04-211-13/+15
| | | | llvm-svn: 69680
OpenPOWER on IntegriCloud