summaryrefslogtreecommitdiff
path: root/lib/CodeGen/BranchFolding.cpp
Commit message (Collapse)AuthorAge
...
* Set MadeChange instead of MadeChangeThisIteration.Dan Gohman2009-11-17
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89114 91177308-0d34-0410-b5e6-96231b3b80d8
* Update a comment, now that tail duplication happens after other branchBob Wilson2009-11-17
| | | | | | | folding optimizations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89109 91177308-0d34-0410-b5e6-96231b3b80d8
* Perform tail duplication only once, after tail merging is complete.Bob Wilson2009-11-17
| | | | | | | | It was too difficult to keep the heuristics for merging and duplication consistent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89105 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a comment.Bob Wilson2009-11-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88940 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some comments.Bob Wilson2009-11-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88932 91177308-0d34-0410-b5e6-96231b3b80d8
* Whitespace: be consistent with pointer syntax.Bob Wilson2009-11-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88929 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up whitespace.Bob Wilson2009-11-16
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88927 91177308-0d34-0410-b5e6-96231b3b80d8
* When optimizing for size, don't tail-merge unless it's likely to be aDan Gohman2009-11-13
| | | | | | | | | | | code-size win, and not when it's only likely to be code-size neutral, such as when only a single instruction would be eliminated and a new branch would be required. This fixes rdar://7392894. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88692 91177308-0d34-0410-b5e6-96231b3b80d8
* Make the BranchFolderPass class local to BranchFolding.cpp.Dan Gohman2009-11-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86928 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code cleanups.Dan Gohman2009-11-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86926 91177308-0d34-0410-b5e6-96231b3b80d8
* Tail merge at any size when there are two potentials blocks and oneDan Gohman2009-11-12
| | | | | | | can be made to fall through into the other. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86909 91177308-0d34-0410-b5e6-96231b3b80d8
* Promote MergePotentialsElt and SameTailElt to be regular classesDan Gohman2009-11-11
| | | | | | | | instead of typedefs for std::pair. This simplifies the type of SameTails, which previously was std::vector<std::pair<std::vector<std::pair<unsigned, MachineBasicBlock *> >::iterator, MachineBasicBlock::iterator> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86885 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert this line of 86871.Dan Gohman2009-11-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86875 91177308-0d34-0410-b5e6-96231b3b80d8
* Add support for tail duplication to BranchFolding, and extendDan Gohman2009-11-11
| | | | | | | | | | | | tail merging support to handle more cases. - Recognize several cases where tail merging is beneficial even when the tail size is smaller than the generic threshold. - Make use of MachineInstrDesc::isBarrier to help detect non-fallthrough blocks. - Check for and avoid disrupting fall-through edges in more cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86871 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix indentation level.Dan Gohman2009-11-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86856 91177308-0d34-0410-b5e6-96231b3b80d8
* Whitespace cleanups.Dan Gohman2009-11-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86855 91177308-0d34-0410-b5e6-96231b3b80d8
* Prefix MBB numbers with "BB#" in debug output to make it clear whatDan Gohman2009-11-11
| | | | | | | the numbers mean. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86854 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code simplification.Dan Gohman2009-11-11
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86853 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an unused variable.Dan Gohman2009-11-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86642 91177308-0d34-0410-b5e6-96231b3b80d8
* Minor code simplification.Dan Gohman2009-11-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86641 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix branch folding bug for indirect branches: for a block containing onlyBob Wilson2009-11-03
| | | | | | | | | | | | | | | | an unconditional branch (possibly from tail merging), this code is trying to redirect all of its predecessors to go directly to the branch target, but that isn't feasible for indirect branches. The other predecessors (that don't end with indirect branches) could theoretically still be handled, but that is not easily done right now. The AnalyzeBranch interface doesn't currently let us distinguish jump table branches from indirect branches, and this code is currently handling jump tables. To avoid punting on address-taken blocks, we would have to give up handling jump tables. That seems like a bad tradeoff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85975 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't delete blocks which have their address taken.Dan Gohman2009-10-30
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85572 91177308-0d34-0410-b5e6-96231b3b80d8
* Refactor complicated predicate into a separate function.Bob Wilson2009-10-29
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85519 91177308-0d34-0410-b5e6-96231b3b80d8
* Reimplement BranchFolding change to avoid tail merging for a 1 instructionBob Wilson2009-10-28
| | | | | | | | common tail, except when the OptimizeForSize function attribute is present. Radar 7338114. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85441 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r85346 change to control tail merging by CodeGenOpt::Level.Bob Wilson2009-10-28
| | | | | | | I'm going to redo this using the OptimizeForSize function attribute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85426 91177308-0d34-0410-b5e6-96231b3b80d8
* Record CodeGen optimization level in the BranchFolding pass so that we canBob Wilson2009-10-27
| | | | | | | | | | | | | | | | | use it to control tail merging when there is a tradeoff between performance and code size. When there is only 1 instruction in the common tail, we have been merging. That can be good for code size but is a definite loss for performance. Now we will avoid tail merging in that case when the optimization level is "Aggressive", i.e., "-O3". Radar 7338114. Since the IfConversion pass invokes BranchFolding, it too needs to know the optimization level. Note that I removed the RegisterPass instantiation for IfConversion because it required a default constructor. If someone wants to keep that for some reason, we can add a default constructor with a hard-wired optimization level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85346 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert the main portion of r31856. It was causing BranchFoldingDan Gohman2009-10-22
| | | | | | | | | | | | | to break up CFG diamonds by banishing one of the blocks to the end of the function, which is bad for code density and branch size. This does pessimize MultiSource/Benchmarks/Ptrdist/yacr2, the benchmark cited as the reason for the change, however I've examined the code and it looks more like a case of gaming a particular branch than of being generally applicable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84803 91177308-0d34-0410-b5e6-96231b3b80d8
* Run branch folding if if-converter make some transformations.Evan Cheng2009-09-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80994 91177308-0d34-0410-b5e6-96231b3b80d8
* Funky indentation.Evan Cheng2009-09-03
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80971 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert DOUT to DEBUG(errs()...).Bill Wendling2009-08-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79747 91177308-0d34-0410-b5e6-96231b3b80d8
* Make tail merging handle blocks with repeated predecessors correctly, andDan Gohman2009-08-18
| | | | | | | | | | | | | | | | | | | | | remove RemoveDuplicateSuccessor, as it is no longer necessary, and because it breaks assumptions made in MachineBasicBlock::isOnlyReachableByFallthrough. Convert test/CodeGen/X86/omit-label.ll to FileCheck and add a testcase for PR4732. test/CodeGen/Thumb2/thumb2-ifcvt2.ll sees a diff with this commit due to it being bugpoint-reduced to the point where it doesn't matter what the condition for the branch is. Add some more interesting code to test/CodeGen/X86/2009-08-06-branchfolder-crash.ll, which is the testcase that originally motivated the RemoveDuplicateSuccessor code, to help verify that the original problem isn't being re-broken. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79338 91177308-0d34-0410-b5e6-96231b3b80d8
* Rewrite previous patch to follow Chris' stylisticDale Johannesen2009-08-07
| | | | | | | | preference; no functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78391 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR 4626, a crash in branch folding after OptimizeBlockDale Johannesen2009-08-06
| | | | | | | | produced a CFG it wasn't prepared for. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78351 91177308-0d34-0410-b5e6-96231b3b80d8
* llvm_unreachable->llvm_unreachable(0), LLVM_UNREACHABLE->llvm_unreachable.Torok Edwin2009-07-14
| | | | | | | | | | This adds location info for all llvm_unreachable calls (which is a macro now) in !NDEBUG builds. In NDEBUG builds location info and the message is off (it only prints "UREACHABLE executed"). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75640 91177308-0d34-0410-b5e6-96231b3b80d8
* assert(0) -> LLVM_UNREACHABLE.Torok Edwin2009-07-11
| | | | | | | | | | Make llvm_unreachable take an optional string, thus moving the cerr<< out of line. LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for NDEBUG builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR4188. TailMerging can't tolerate inexactDale Johannesen2009-05-11
| | | | | | | | sucessor info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71478 91177308-0d34-0410-b5e6-96231b3b80d8
* Turns out AnalyzeBranch can modify the mbb being analyzed. This is a nastyEvan Cheng2009-02-09
| | | | | | | | | suprise to some callers, e.g. register coalescer. For now, add an parameter that tells AnalyzeBranch whether it's safe to modify the mbb. A better solution is out there, but I don't have time to deal with it right now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64124 91177308-0d34-0410-b5e6-96231b3b80d8
* Rename getAnalysisToUpdate to getAnalysisIfAvailable.Duncan Sands2009-01-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63198 91177308-0d34-0410-b5e6-96231b3b80d8
* Delete unnecessary parens around return values.Dan Gohman2009-01-08
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61950 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a newline after this debug output.Bill Wendling2008-12-10
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60861 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a sanity-check to tablegen to catch the case where isSimpleLoadDan Gohman2008-12-03
| | | | | | | | | | is set but mayLoad is not set. Fix all the problems this turned up. Change code to not use isSimpleLoad instead of mayLoad unless it really wants isSimpleLoad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60459 91177308-0d34-0410-b5e6-96231b3b80d8
* Increase default setting of tail-merge-threshold toDale Johannesen2008-10-27
| | | | | | | | 150, based on llvm-test measurements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58225 91177308-0d34-0410-b5e6-96231b3b80d8
* Switch the MachineOperand accessors back to the short names likeDan Gohman2008-10-03
| | | | | | | isReg, etc., from isRegister, etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57006 91177308-0d34-0410-b5e6-96231b3b80d8
* Mark several codegen passes as preserving all analysis.Evan Cheng2008-09-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56469 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove isImm(), isReg(), and friends, in favor of Dan Gohman2008-09-13
| | | | | | | | | | isImmediate(), isRegister(), and friends, to avoid confusion about having two different names with the same meaning. I'm not attached to the longer names, and would be ok with changing to the shorter names if others prefer it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56189 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy up several unbeseeming casts from pointer to intptr_t.Dan Gohman2008-09-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55779 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix SmallVector's size calculation so that a size of 0 isDan Gohman2008-08-22
| | | | | | | | handled correctly, and change a few SmallVector uses to use size 0 to more clearly reflect their intent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55181 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert uses of std::vector in TargetInstrInfo to SmallVector. This change ↵Owen Anderson2008-08-14
| | | | | | had to be propoagated down into all the targets and up into all clients of this API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54802 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR2609. If a label is deleted, then it needsDuncan Sands2008-07-29
| | | | | | | | | to be marked invalid regardless of whether it is a debug, an exception handling or (hopefully) a GC label. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54172 91177308-0d34-0410-b5e6-96231b3b80d8
* Pool-allocation for MachineInstrs, MachineBasicBlocks, andDan Gohman2008-07-07
| | | | | | | | | | | | MachineMemOperands. The pools are owned by MachineFunctions. This drastically reduces the number of calls to malloc/free made during the "Emit" phase of scheduling, as well as later phases in CodeGen. Combined with other changes, this speeds up the "instruction selection" phase of CodeGen by 10% in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53212 91177308-0d34-0410-b5e6-96231b3b80d8