summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* For now, avoid generating FP select instructions in order to speculatively ↵Evan Cheng2008-06-111-4/+9
| | | | | | | | execute integer arithmetic instructions. FP selects are more likely to be expensive (even compared to branch on fcmp). This is not a wonderful solution but I rather err on the side of conservative. This fixes the heapsort performance regressions. llvm-svn: 52224
* op_iterator-ify loopsGabor Greif2008-06-101-13/+16
| | | | llvm-svn: 52191
* Speculatively execute a block when the the block is the then part of a ↵Evan Cheng2008-06-071-0/+121
| | | | | | | | | | | | | | | | | | | | triangle shape and it contains a single, side effect free, cheap instruction. The branch is eliminated by adding a select instruction. i.e. Turn BB: %t1 = icmp br i1 %t1, label %BB1, label %BB2 BB1: %t3 = add %t2, c br label BB2 BB2: => BB: %t1 = icmp %t4 = add %t2, c %t3 = select i1 %t1, %t2, %t3 llvm-svn: 52073
* Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places toDan Gohman2008-05-231-2/+1
| | | | | | use it instead of duplicating its functionality. llvm-svn: 51499
* Restucture a part of the SimplifyCFG pass and include a testcase.Matthijs Kooijman2008-05-231-65/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The SimplifyCFG pass looks at basic blocks that contain only phi nodes, followed by an unconditional branch. In a lot of cases, such a block (BB) can be merged into their successor (Succ). This merging is performed by TryToSimplifyUncondBranchFromEmptyBlock. It does this by taking all phi nodes in the succesor block Succ and expanding them to include the predecessors of BB. Furthermore, any phi nodes in BB are moved to Succ and expanded to include the predecessors of Succ as well. Before attempting this merge, CanPropagatePredecessorsForPHIs checks to see if all phi nodes can be properly merged. All functional changes are made to this function, only comments were updated in TryToSimplifyUncondBranchFromEmptyBlock. In the original code, CanPropagatePredecessorsForPHIs looks quite convoluted and more like stack of checks added to handle different kinds of situations than a comprehensive check. In particular the first check in the function did some value checking for the case that BB and Succ have a common predecessor, while the last check in the function simply rejected all cases where BB and Succ have a common predecessor. The first check was still useful in the case that BB did not contain any phi nodes at all, though, so it was not completely useless. Now, CanPropagatePredecessorsForPHIs is restructured to to look a lot more similar to the code that actually performs the merge. Both functions now look at the same phi nodes in about the same order. Any conflicts (phi nodes with different values for the same source) that could arise from merging or moving phi nodes are detected. If no conflicts are found, the merge can happen. Apart from only restructuring the checks, two main changes in functionality happened. Firstly, the old code rejected blocks with common predecessors in most cases. The new code performs some extra checks so common predecessors can be handled in a lot of cases. Wherever common predecessors still pose problems, the blocks are left untouched. Secondly, the old code rejected the merge when values (phi nodes) from BB were used in any other place than Succ. However, it does not seem that there is any situation that would require this check. Even more, this can be proven. Consider that BB is a block containing of a single phi node "%a" and a branch to Succ. Now, since the definition of %a will dominate all of its uses, BB will dominate all blocks that use %a. Furthermore, since the branch from BB to Succ is unconditional, Succ will also dominate all uses of %a. Now, assume that one predecessor of Succ is not dominated by BB (and thus not dominated by Succ). Since at least one use of %a (but in reality all of them) is reachable from Succ, you could end up at a use of %a without passing through it's definition in BB (by coming from X through Succ). This is a contradiction, meaning that our original assumption is wrong. Thus, all predecessors of Succ must also be dominated by BB (and thus also by Succ). This means that moving the phi node %a from BB to Succ does not pose any problems when the two blocks are merged, and any use checks are not needed. llvm-svn: 51478
* API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. ↵Gabor Greif2008-05-161-5/+5
| | | | | | Legacy interfaces will be in place for some time. (Merge from use-diet branch.) llvm-svn: 51200
* Fix a bunch of 80col violations that arose from the Create API change. Tweak ↵Gabor Greif2008-05-151-2/+4
| | | | | | makefile targets to find these better. llvm-svn: 51143
* Fix PR2256, yet another miscompilation in simplifycfg of iChris Lattner2008-04-281-3/+4
| | | | | | | | multiple return values. Bill, please pull this into Tak. llvm-svn: 50332
* Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989Nick Lewycky2008-04-251-16/+2
| | | | | | r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123. llvm-svn: 50265
* Split some code out of the main SimplifyCFG loop into its own function.Chris Lattner2008-04-241-65/+103
| | | | | | | Fix said code to handle merging return instructions together correctly when handling multiple return values. llvm-svn: 50199
* API changes for class Use size reduction, wave 1.Gabor Greif2008-04-061-30/+30
| | | | | | | | Specifically, introduction of XXX::Create methods for Users that have a potentially variable number of Uses. llvm-svn: 49277
* Check to see if a two-entry PHI block can be simplifiedDan Gohman2008-03-111-6/+6
| | | | | | | | before trying to merge the block into its predecessors. This allows two-entry-phi-return.ll to be simplified into a single basic block. llvm-svn: 48252
* Turn unwind_to into "unwinds to".Nick Lewycky2008-03-101-1/+1
| | | | llvm-svn: 48123
* Firstly, having a BranchInst isn't exclusive with having an unwind_to.Nick Lewycky2008-03-091-5/+8
| | | | | | | Secondly, we have to check whether the branch is actually pointing to the block with the unwind in it. We could have gotten here because of the unwind_to alone. llvm-svn: 48099
* A BB that unwind_to an "unwind" inst is that same as one that doesn't unwind_toNick Lewycky2008-03-091-1/+4
| | | | | | at all. llvm-svn: 48096
* Update the inliner and simplifycfg to handle unwind_to.Nick Lewycky2008-03-091-1/+9
| | | | llvm-svn: 48086
* Make Transforms to be 4.3 warnings-cleanAnton Korobeynikov2008-02-201-6/+10
| | | | llvm-svn: 47371
* switch simplifycfg from using vectors for most things to smallvectors,Chris Lattner2008-02-181-14/+12
| | | | | | this speeds it up 2.3% on eon. llvm-svn: 47261
* don't hoist FP additions into unconditional adds + selects. This Chris Lattner2008-01-031-0/+2
| | | | | | | could theoretically introduce a trap, but is also a performance issue. This speeds up ptrdist/ks by 8%. llvm-svn: 45533
* Remove attribution from file headers, per discussion on llvmdev.Chris Lattner2007-12-291-2/+2
| | | | llvm-svn: 45418
* If succ has succ itself as one of the predecessors then doDevang Patel2007-12-221-2/+2
| | | | | | | not merge current bb and succ even if bb's terminator is unconditional branch to succ. llvm-svn: 45305
* Fix PR1146: parameter attributes are longer part ofDuncan Sands2007-11-271-0/+2
| | | | | | | | | | | | the function type, instead they belong to functions and function calls. This is an updated and slightly corrected version of Reid Spencer's original patch. The only known problem is that auto-upgrading of bitcode files doesn't seem to work properly (see test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully a bitcode guru (who might that be? :) ) will fix it. llvm-svn: 44359
* New CallInst interface to address GLIBCXX_DEBUG errors caused byDavid Greene2007-08-011-2/+2
| | | | | | | | indexing an empty std::vector. Updates to all clients. llvm-svn: 40660
* Minor comment cleanups.Dan Gohman2007-05-241-1/+1
| | | | llvm-svn: 37321
* remove use of Instruction::getNextChris Lattner2007-04-171-3/+5
| | | | llvm-svn: 36199
* reduce use of std::setChris Lattner2007-04-021-6/+7
| | | | llvm-svn: 35576
* Change uses of Function::front to Function::getEntryBlock for readability.Dan Gohman2007-03-221-1/+2
| | | | llvm-svn: 35265
* Make sorting of ConstantInt be APInt clean through use of ult function.Reid Spencer2007-03-021-1/+1
| | | | llvm-svn: 34853
* Eliminate use of ctors that take vectors.Chris Lattner2007-02-131-5/+7
| | | | llvm-svn: 34219
* simplify code by using Value::takeNameChris Lattner2007-02-111-21/+17
| | | | llvm-svn: 34177
* Adjust #includes to match movement of constant folding code from ↵Chris Lattner2007-01-301-0/+1
| | | | | | transformutils to libanalysis. llvm-svn: 33680
* For PR1043:Reid Spencer2007-01-191-0/+1
| | | | | | | | | | | | | | This is the final patch for this PR. It implements some minor cleanup in the use of IntegerType, to wit: 1. Type::getIntegerTypeMask -> IntegerType::getBitMask 2. Type::Int*Ty changed to IntegerType* from Type* 3. ConstantInt::getType() returns IntegerType* now, not Type* This also fixes PR1120. Patch by Sheng Zhou. llvm-svn: 33370
* rename Type::isIntegral to Type::isInteger, eliminating the old Type::isInteger.Chris Lattner2007-01-151-1/+1
| | | | | | | | | rename Type::getIntegralTypeMask to Type::getIntegerTypeMask. This makes naming much more consistent. For example, there are now no longer any instances of IntegerType that are not considered isInteger! :) llvm-svn: 33225
* Eliminate calls to isInteger, generalizing code and tightening checks as needed.Chris Lattner2007-01-151-1/+1
| | | | llvm-svn: 33218
* Implement review feedback for the ConstantBool->ConstantInt merge. ChrisReid Spencer2007-01-121-9/+10
| | | | | | | | recommended that getBoolValue be replaced with getZExtValue and that get(bool) be replaced by get(const Type*, uint64_t). This implements those changes. llvm-svn: 33110
* Rename BoolTy as Int1Ty. Patch by Sheng Zhou.Reid Spencer2007-01-111-2/+2
| | | | llvm-svn: 33076
* For PR1043:Zhou Sheng2007-01-111-5/+8
| | | | | | | Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. llvm-svn: 33073
* For PR950:Reid Spencer2006-12-231-25/+24
| | | | | | | | This patch removes the SetCC instructions and replaces them with the ICmp and FCmp instructions. The SetCondInst instruction has been removed and been replaced with ICmpInst and FCmpInst. llvm-svn: 32751
* For PR950:Reid Spencer2006-11-271-5/+0
| | | | | | | | | | The long awaited CAST patch. This introduces 12 new instructions into LLVM to replace the cast instruction. Corresponding changes throughout LLVM are provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the exception of 175.vpr which fails only on a slight floating point output difference. llvm-svn: 31931
* Remove #include <iostream> and use llvm_* streams instead.Bill Wendling2006-11-261-21/+20
| | | | llvm-svn: 31925
* Do not convert massive blocks on phi nodes into select statements. InsteadChris Lattner2006-11-181-0/+27
| | | | | | | only do these transformations if there are a small number of phi's. This speeds up Ptrdist/ks from 2.35s to 2.19s on my mac pro. llvm-svn: 31853
* For PR950:Reid Spencer2006-11-081-1/+2
| | | | | | | | This patch converts the old SHR instruction into two instructions, AShr (Arithmetic) and LShr (Logical). The Shr instructions now are not dependent on the sign of their operands. llvm-svn: 31542
* For PR786:Reid Spencer2006-11-021-3/+2
| | | | | | | | | | Turn on -Wunused and -Wno-unused-parameter. Clean up most of the resulting fall out by removing unused variables. Remaining warnings have to do with unused functions (I didn't want to delete code without review) and unused variables in generated code. Maintainers should clean up the remaining issues when they see them. All changes pass DejaGnu tests and Olden. llvm-svn: 31380
* Fix SimplifyCFG/2006-10-29-InvokeCrash.ll, a crash compiling QT.Chris Lattner2006-10-291-1/+1
| | | | llvm-svn: 31284
* For PR950:Reid Spencer2006-10-201-1/+1
| | | | | | | | This patch implements the first increment for the Signless Types feature. All changes pertain to removing the ConstantSInt and ConstantUInt classes in favor of just using ConstantInt. llvm-svn: 31063
* Fix SimplifyCFG/2006-10-19-UncondDiv.ll by disabling a bad xform.Chris Lattner2006-10-201-23/+40
| | | | llvm-svn: 31061
* Fix PR867 (and maybe 868) and testcsae:Chris Lattner2006-08-031-6/+25
| | | | | | Transforms/SimplifyCFG/2006-08-03-Crash.ll llvm-svn: 29515
* Fix an infinite loop on Transforms/SimplifyCFG/2006-06-12-InfLoop.llChris Lattner2006-06-121-1/+10
| | | | llvm-svn: 28758
* remove some dead code identified by coverityChris Lattner2006-05-141-1/+1
| | | | llvm-svn: 28289
* remove dead variablesChris Lattner2006-05-141-2/+0
| | | | llvm-svn: 28286
OpenPOWER on IntegriCloud