forked from OSchip/llvm-project
Add an option to disable codegen prepare critical edge splitting. In theory, PHI elimination is already doing all (most?) of the splitting needed. But machine-licm and machine-sink seem to miss some important optimizations when splitting is disabled.
llvm-svn: 111224
This commit is contained in:
parent
541f8012d9
commit
8b637b177c
|
@ -33,6 +33,7 @@
|
|||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/Support/CallSite.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/Support/PatternMatch.h"
|
||||
|
@ -41,6 +42,11 @@
|
|||
using namespace llvm;
|
||||
using namespace llvm::PatternMatch;
|
||||
|
||||
static cl::opt<bool>
|
||||
CriticalEdgeSplit("cgp-critical-edge-splitting",
|
||||
cl::desc("Split critical edges during codegen prepare"),
|
||||
cl::init(true), cl::Hidden);
|
||||
|
||||
namespace {
|
||||
class CodeGenPrepare : public FunctionPass {
|
||||
/// TLI - Keep a pointer of a TargetLowering to consult for determining
|
||||
|
@ -891,12 +897,14 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
|
|||
bool MadeChange = false;
|
||||
|
||||
// Split all critical edges where the dest block has a PHI.
|
||||
TerminatorInst *BBTI = BB.getTerminator();
|
||||
if (BBTI->getNumSuccessors() > 1 && !isa<IndirectBrInst>(BBTI)) {
|
||||
for (unsigned i = 0, e = BBTI->getNumSuccessors(); i != e; ++i) {
|
||||
BasicBlock *SuccBB = BBTI->getSuccessor(i);
|
||||
if (isa<PHINode>(SuccBB->begin()) && isCriticalEdge(BBTI, i, true))
|
||||
SplitEdgeNicely(BBTI, i, BackEdges, this);
|
||||
if (CriticalEdgeSplit) {
|
||||
TerminatorInst *BBTI = BB.getTerminator();
|
||||
if (BBTI->getNumSuccessors() > 1 && !isa<IndirectBrInst>(BBTI)) {
|
||||
for (unsigned i = 0, e = BBTI->getNumSuccessors(); i != e; ++i) {
|
||||
BasicBlock *SuccBB = BBTI->getSuccessor(i);
|
||||
if (isa<PHINode>(SuccBB->begin()) && isCriticalEdge(BBTI, i, true))
|
||||
SplitEdgeNicely(BBTI, i, BackEdges, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue