summaryrefslogtreecommitdiff
path: root/lib/CodeGen/IfConversion.cpp
Commit message (Collapse)AuthorAge
...
* Part one of switching to using a more sane heuristic for determining ↵Owen Anderson2010-09-28
| | | | | | | | | | | | if-conversion profitability. Rather than having arbitrary cutoffs, actually try to cost model the conversion. For now, the constants are tuned to more or less match our existing behavior, but these will be changed to reflect realistic values as this work proceeds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114973 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach if-converter to be more careful with predicating instructions that wouldEvan Cheng2010-09-10
| | | | | | | | | | | | take multiple cycles to decode. For the current if-converter clients (actually only ARM), the instructions that are predicated on false are not nops. They would still take machine cycles to decode. Micro-coded instructions such as LDM / STM can potentially take multiple cycles to decode. If-converter should take treat them as non-micro-coded simple instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113570 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply r110396, with fixes to appease the Linux buildbot gods.Owen Anderson2010-08-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110460 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r110396 to fix buildbots.Owen Anderson2010-08-06
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110410 91177308-0d34-0410-b5e6-96231b3b80d8
* Don't use PassInfo* as a type identifier for passes. Instead, use the ↵Owen Anderson2010-08-05
| | | | | | | | | address of the static ID member as the sole unique type identifier. Clean up APIs related to this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110396 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix batch of converting RegisterPass<> to INTIALIZE_PASS().Owen Anderson2010-07-21
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109045 91177308-0d34-0410-b5e6-96231b3b80d8
* Reapply my if-conversion cleanup from svn r106939 with fixes.Bob Wilson2010-06-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are 2 changes relative to the previous version of the patch: 1) For the "simple" if-conversion case, there's no need to worry about RemoveExtraEdges not handling an unanalyzable branch. Predicated terminators are ignored in this context, so RemoveExtraEdges does the right thing. This might break someday if we ever treat indirect branches (BRIND) as predicable, but for now, I just removed this part of the patch, because in the case where we do not add an unconditional branch, we rely on keeping the fall-through edge to CvtBBI (which is empty after this transformation). The change relative to the previous patch is: @@ -1036,10 +1036,6 @@ IterIfcvt = false; } - // RemoveExtraEdges won't work if the block has an unanalyzable branch, - // which is typically the case for IfConvertSimple, so explicitly remove - // CvtBBI as a successor. - BBI.BB->removeSuccessor(CvtBBI->BB); RemoveExtraEdges(BBI); // Update block info. BB can be iteratively if-converted. 2) My patch exposed a bug in the code for merging the tail of a "diamond", which had previously never been exercised. The code was simply checking that the tail had a single predecessor, but there was a case in MultiSource/Benchmarks/VersaBench/dbms where that single predecessor was neither edge of the diamond. I added the following change to check for that: @@ -1276,7 +1276,18 @@ // tail, add a unconditional branch to it. if (TailBB) { BBInfo TailBBI = BBAnalysis[TailBB->getNumber()]; - if (TailBB->pred_size() == 1 && !TailBBI.HasFallThrough) { + bool CanMergeTail = !TailBBI.HasFallThrough; + // There may still be a fall-through edge from BBI1 or BBI2 to TailBB; + // check if there are any other predecessors besides those. + unsigned NumPreds = TailBB->pred_size(); + if (NumPreds > 1) + CanMergeTail = false; + else if (NumPreds == 1 && CanMergeTail) { + MachineBasicBlock::pred_iterator PI = TailBB->pred_begin(); + if (*PI != BBI1->BB && *PI != BBI2->BB) + CanMergeTail = false; + } + if (CanMergeTail) { MergeBlocks(BBI, TailBBI); TailBBI.IsDone = true; } else { With these fixes, I was able to run all the SingleSource and MultiSource tests successfully. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107110 91177308-0d34-0410-b5e6-96231b3b80d8
* new, no longer brain-dead, r106907Jim Grosbach2010-06-28
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107060 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r106907, "make sure to handle dbg_value instructions in the middle of theDaniel Dunbar2010-06-28
| | | | | | block, not...", it caused a bunch of nightly test regressions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107009 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert my if-conversion cleanup since it caused a bunch of nightly testBob Wilson2010-06-26
| | | | | | | | | | | regressions. --- Reverse-merging r106939 into '.': U test/CodeGen/Thumb2/thumb2-ifcvt3.ll U lib/CodeGen/IfConversion.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106951 91177308-0d34-0410-b5e6-96231b3b80d8
* Clean up some problems with extra CFG edges being introduced duringBob Wilson2010-06-26
| | | | | | | | | | | | | | | | if-conversion. The RemoveExtraEdges function doesn't work for blocks that end with unanalyzable branches, so in those cases, the "extra" edges must be explicitly removed. The CopyAndPredicateBlock and MergeBlocks methods can also avoid copying successor edges due to branches that have already been removed. The latter case is especially helpful when MergeBlocks is called for handling "diamond" if-conversions, where otherwise you can end up with some weird intermediate states in the CFG. Unfortunately I've been unable to find cases where this cleanup actually makes a significant difference in the code. There is one test where we manage to remove an empty block at the end of a function. Radar 6911268. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106939 91177308-0d34-0410-b5e6-96231b3b80d8
* make sure to handle dbg_value instructions in the middle of the block, notJim Grosbach2010-06-25
| | | | | | just at the head, when doing diamond if-conversion. rdar://7797940 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106907 91177308-0d34-0410-b5e6-96231b3b80d8
* Change if-conversion block size limit checks to add some flexibility.Evan Cheng2010-06-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106901 91177308-0d34-0410-b5e6-96231b3b80d8
* 80 column and typo fixJim Grosbach2010-06-25
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106894 91177308-0d34-0410-b5e6-96231b3b80d8
* Use pre-increment instead of post-increment when the result is not used.Dan Gohman2010-06-22
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106542 91177308-0d34-0410-b5e6-96231b3b80d8
* Tidy.Bob Wilson2010-06-19
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106383 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow ARM if-converter to be run after post allocation scheduling.Evan Cheng2010-06-18
| | | | | | | | | | | | | | | | | - This fixed a number of bugs in if-converter, tail merging, and post-allocation scheduler. If-converter now runs branch folding / tail merging first to maximize if-conversion opportunities. - Also changed the t2IT instruction slightly. It now defines the ITSTATE register which is read by instructions in the IT block. - Added Thumb2 specific hazard recognizer to ensure the scheduler doesn't change the instruction ordering in the IT block (since IT mask has been finalized). It also ensures no other instructions can be scheduled between instructions in the IT block. This is not yet enabled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106344 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix an inverted condition.Evan Cheng2010-06-18
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106330 91177308-0d34-0410-b5e6-96231b3b80d8
* Teach iff-converter to properly count # of dups. It was not skipping over ↵Evan Cheng2010-06-18
| | | | | | dbg_value's which resulted in non-duplicated instructions being deleted. rdar://8104384. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106323 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix PR7372: Conditional branches (at least on ARM) are treated as predicated,Bob Wilson2010-06-18
| | | | | | | | | | | | | | | | | | | | | | | | | | so when IfConverter::CopyAndPredicateBlock checks to see if it should ignore an instruction because it is a branch, it should not check if the branch is predicated. This case (when IgnoreBr is true) is only relevant from IfConvertTriangle, where new branches are inserted after the block has been copied and predicated. If the original branch is not removed, we end up with multiple conditional branches (possibly conflicting) at the end of the block. Aside from any immediate errors resulting from that, this confuses the AnalyzeBranch functions so that the branches are not analyzable. That in turn causes the IfConverter to think that the "Simple" pattern can be applied, and things go downhill fast because the "Simple" pattern does _not_ apply if the block can fall through. This is pretty fragile. If there are other degenerate cases where AnalyzeBranch fails, but where the block may still fall through, the IfConverter should not perform its "Simple" if-conversion. But, I don't know how to do that with the current AnalyzeBranch interface, so for now, the best thing seems to be to avoid creating branches that AnalyzeBranch cannot handle. Evan, please review! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106291 91177308-0d34-0410-b5e6-96231b3b80d8
* Add a DebugLoc parameter to TargetInstrInfo::InsertBranch(). ThisStuart Hastings2010-06-17
| | | | | | | | | | | | | addresses a longstanding deficiency noted in many FIXMEs scattered across all the targets. This effectively moves the problem up one level, replacing eleven FIXMEs in the targets with eight FIXMEs in CodeGen, plus one path through FastISel where we actually supply a DebugLoc, fixing Radar 7421831. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106243 91177308-0d34-0410-b5e6-96231b3b80d8
* Make post-ra scheduling, anti-dep breaking, and register scavenger ↵Evan Cheng2010-06-16
| | | | | | (conservatively) aware of predicated instructions. This enables ARM to move if-conversion before post-ra scheduler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106091 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix 80col violations, remove trailing whitespace, and clarify a comment.Bob Wilson2010-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106057 91177308-0d34-0410-b5e6-96231b3b80d8
* IfConversion's AnalyzeBlocks method always returns false; clean it up.Bob Wilson2010-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106027 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix a comment typo.Bob Wilson2010-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106015 91177308-0d34-0410-b5e6-96231b3b80d8
* More dbg_value cleanup so the presence of debug info doesn't affect code-gen.Jim Grosbach2010-06-14
| | | | | | | Make sure to skip the dbg_value instructions when moving dups out of the diamond. rdar://7797940 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105965 91177308-0d34-0410-b5e6-96231b3b80d8
* Cleanup. Process the dbg_values separatelyJim Grosbach2010-06-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105554 91177308-0d34-0410-b5e6-96231b3b80d8
* Move exit check where it really belongs.Jim Grosbach2010-06-07
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105541 91177308-0d34-0410-b5e6-96231b3b80d8
* Make if-conversion ignore dbg_value instructions in its analysis. rdar://7797940Jim Grosbach2010-06-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105498 91177308-0d34-0410-b5e6-96231b3b80d8
* Change errs() to dbgs().David Greene2010-01-04
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92520 91177308-0d34-0410-b5e6-96231b3b80d8
* Allow target to disable if-converting predicable instructions. e.g. NEON ↵Evan Cheng2009-11-21
| | | | | | instructions under ARM mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89541 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
* Remove VISIBILITY_HIDDEN from class/struct found inside anonymous namespaces.Nick Lewycky2009-10-25
| | | | | | | | Chris claims we should never have visibility_hidden inside any .cpp file but that's still not true even after this commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85042 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
* remove various std::ostream version of printing methods fromChris Lattner2009-08-23
| | | | | | | | | MachineInstr and MachineOperand. This required eliminating a bunch of stuff that was using DOUT, I hope that bill doesn't mind me stealing his fun. ;-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79813 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@79751 91177308-0d34-0410-b5e6-96231b3b80d8
* More migration to raw_ostream, the water has dried up around the iostream hole.Daniel Dunbar2009-07-25
| | | | | | | | | | | - Some clients which used DOUT have moved to DEBUG. We are deprecating the "magic" DOUT behavior which avoided calling printing functions when the statement was disabled. In addition to being unnecessary magic, it had the downside of leaving code in -Asserts builds, and of hiding potentially unnecessary computations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77019 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
* Fix assert(0) conversion, as suggested by Chris.Torok Edwin2009-07-12
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75423 91177308-0d34-0410-b5e6-96231b3b80d8
* Convert more assert(0)+abort() -> LLVM_UNREACHABLE,Torok Edwin2009-07-11
| | | | | | | and abort()/exit() -> llvm_report_error(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75363 91177308-0d34-0410-b5e6-96231b3b80d8
* Fewer static variables, part 3 of many.Owen Anderson2009-06-24
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74140 91177308-0d34-0410-b5e6-96231b3b80d8
* ifcvt should ignore cfg where true and false successors are the same.Evan Cheng2009-06-15
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73423 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert r71744. I must not have understood this correctly, because theBob Wilson2009-05-14
| | | | | | | assertion is failing for some tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71779 91177308-0d34-0410-b5e6-96231b3b80d8
* The IfConverter::MergeBlocks method appears to be used only to merge a basicBob Wilson2009-05-13
| | | | | | | | | block with its unique predecessor. Change the code to assert if that is not the case, instead of trying to handle situations where the block has multiple predecessors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71744 91177308-0d34-0410-b5e6-96231b3b80d8
* Revert a portion of Dan's change r71018 that I'm convinced is wrong.Bob Wilson2009-05-13
| | | | | | | | | | | | | | | | | | | | Dan was trying to catch the case where a basic block ends with a conditional branch to the fall-through block. In this case, all the instructions have been moved out of FromBBI, leaving it empty. It cannot end with a conditional branch. As the existing comment indicates, it will always fall through to the next block. If the block already had the next block (NBB) listed as a successor, the preceding loop has a check for that and does not remove it. Thus, we need to check and add the successor only when it is not already listed. With Dan's change, the empty block often ends up with the fall-through successor listed twice. This exposed the problem in pr4195, where CodePlacementOpt did not handle the same predecessor listed more than once. It is also at least partially responsible for pr4202 and probably a similar issue with Thumb branches being out of range. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71742 91177308-0d34-0410-b5e6-96231b3b80d8
* Merge adjacent conditional.Bob Wilson2009-05-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71741 91177308-0d34-0410-b5e6-96231b3b80d8
* Remove an unused variable.Bob Wilson2009-05-13
| | | | git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71740 91177308-0d34-0410-b5e6-96231b3b80d8
* Fix some typos and spelling and grammar, mostly in comments, but also oneBob Wilson2009-05-13
| | | | | | | field name. No functional changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71739 91177308-0d34-0410-b5e6-96231b3b80d8
* If a MachineBasicBlock has multiple ways of reaching another block,Dan Gohman2009-05-05
| | | | | | | | | allow it to have multiple CFG edges to that block. This is needed to allow MachineBasicBlock::isOnlyReachableByFallthrough to work correctly. This fixes PR4126. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71018 91177308-0d34-0410-b5e6-96231b3b80d8