mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-20 11:08:27 +00:00
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111224 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
44a2c3476b
commit
e1bcb440dc
@ -33,6 +33,7 @@
|
|||||||
#include "llvm/ADT/SmallSet.h"
|
#include "llvm/ADT/SmallSet.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/Support/CallSite.h"
|
#include "llvm/Support/CallSite.h"
|
||||||
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||||
#include "llvm/Support/PatternMatch.h"
|
#include "llvm/Support/PatternMatch.h"
|
||||||
@ -41,6 +42,11 @@
|
|||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
using namespace llvm::PatternMatch;
|
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 {
|
namespace {
|
||||||
class CodeGenPrepare : public FunctionPass {
|
class CodeGenPrepare : public FunctionPass {
|
||||||
/// TLI - Keep a pointer of a TargetLowering to consult for determining
|
/// TLI - Keep a pointer of a TargetLowering to consult for determining
|
||||||
@ -891,12 +897,14 @@ bool CodeGenPrepare::OptimizeBlock(BasicBlock &BB) {
|
|||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
// Split all critical edges where the dest block has a PHI.
|
// Split all critical edges where the dest block has a PHI.
|
||||||
TerminatorInst *BBTI = BB.getTerminator();
|
if (CriticalEdgeSplit) {
|
||||||
if (BBTI->getNumSuccessors() > 1 && !isa<IndirectBrInst>(BBTI)) {
|
TerminatorInst *BBTI = BB.getTerminator();
|
||||||
for (unsigned i = 0, e = BBTI->getNumSuccessors(); i != e; ++i) {
|
if (BBTI->getNumSuccessors() > 1 && !isa<IndirectBrInst>(BBTI)) {
|
||||||
BasicBlock *SuccBB = BBTI->getSuccessor(i);
|
for (unsigned i = 0, e = BBTI->getNumSuccessors(); i != e; ++i) {
|
||||||
if (isa<PHINode>(SuccBB->begin()) && isCriticalEdge(BBTI, i, true))
|
BasicBlock *SuccBB = BBTI->getSuccessor(i);
|
||||||
SplitEdgeNicely(BBTI, i, BackEdges, this);
|
if (isa<PHINode>(SuccBB->begin()) && isCriticalEdge(BBTI, i, true))
|
||||||
|
SplitEdgeNicely(BBTI, i, BackEdges, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user