mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-22 19:38:40 +00:00
refactor critical edge breaking out into the SplitCritEdgesForPHIConstants method.
This is a baby step towards fixing PR925. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30643 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f308ea01d5
commit
57f9a43c64
@ -124,6 +124,7 @@ protected:
|
|||||||
SelectionDAG &DAG);
|
SelectionDAG &DAG);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void SplitCritEdgesForPHIConstants(BasicBlock *BB);
|
||||||
SDOperand CopyValueToVirtualRegister(SelectionDAGLowering &SDL,
|
SDOperand CopyValueToVirtualRegister(SelectionDAGLowering &SDL,
|
||||||
Value *V, unsigned Reg);
|
Value *V, unsigned Reg);
|
||||||
void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF,
|
void SelectBasicBlock(BasicBlock *BB, MachineFunction &MF,
|
||||||
|
@ -845,8 +845,6 @@ void SelectionDAGLowering::visitSwitchCase(SelectionDAGISel::CaseBlock &CB) {
|
|||||||
CurMBB->addSuccessor(CB.RHSBB);
|
CurMBB->addSuccessor(CB.RHSBB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// visitSwitchCase - Emits the necessary code to represent a single node in
|
|
||||||
/// the binary search tree resulting from lowering a switch instruction.
|
|
||||||
void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable &JT) {
|
void SelectionDAGLowering::visitJumpTable(SelectionDAGISel::JumpTable &JT) {
|
||||||
// FIXME: Need to emit different code for PIC vs. Non-PIC, specifically,
|
// FIXME: Need to emit different code for PIC vs. Non-PIC, specifically,
|
||||||
// we need to add the address of the jump table to the value loaded, since
|
// we need to add the address of the jump table to the value loaded, since
|
||||||
@ -3207,6 +3205,21 @@ static bool OptimizeGEPExpression(GetElementPtrInst *GEPI,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// SplitCritEdgesForPHIConstants - If this block has any PHI nodes with
|
||||||
|
/// constant operands, and if any of the edges feeding the PHI node are
|
||||||
|
/// critical, split them so that the assignments of a constant to a register
|
||||||
|
/// will not be executed on a path that isn't relevant.
|
||||||
|
void SelectionDAGISel::SplitCritEdgesForPHIConstants(BasicBlock *BB) {
|
||||||
|
PHINode *PN;
|
||||||
|
BasicBlock::iterator BBI = BB->begin();
|
||||||
|
while ((PN = dyn_cast<PHINode>(BBI++))) {
|
||||||
|
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
||||||
|
if (isa<Constant>(PN->getIncomingValue(i)))
|
||||||
|
SplitCriticalEdge(PN->getIncomingBlock(i), BB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SelectionDAGISel::runOnFunction(Function &Fn) {
|
bool SelectionDAGISel::runOnFunction(Function &Fn) {
|
||||||
MachineFunction &MF = MachineFunction::construct(&Fn, TLI.getTargetMachine());
|
MachineFunction &MF = MachineFunction::construct(&Fn, TLI.getTargetMachine());
|
||||||
RegMap = MF.getSSARegMap();
|
RegMap = MF.getSSARegMap();
|
||||||
@ -3225,14 +3238,12 @@ bool SelectionDAGISel::runOnFunction(Function &Fn) {
|
|||||||
while (MadeChange) {
|
while (MadeChange) {
|
||||||
MadeChange = false;
|
MadeChange = false;
|
||||||
for (Function::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
|
for (Function::iterator BB = Fn.begin(), E = Fn.end(); BB != E; ++BB) {
|
||||||
PHINode *PN;
|
// If this block has any PHI nodes with constant operands, and if any of the
|
||||||
BasicBlock::iterator BBI;
|
// edges feeding the PHI node are critical, split them.
|
||||||
for (BBI = BB->begin(); (PN = dyn_cast<PHINode>(BBI)); ++BBI)
|
if (isa<PHINode>(BB->begin()))
|
||||||
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
|
SplitCritEdgesForPHIConstants(BB);
|
||||||
if (isa<Constant>(PN->getIncomingValue(i)))
|
|
||||||
SplitCriticalEdge(PN->getIncomingBlock(i), BB);
|
|
||||||
|
|
||||||
for (BasicBlock::iterator E = BB->end(); BBI != E; ) {
|
for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E; ) {
|
||||||
Instruction *I = BBI++;
|
Instruction *I = BBI++;
|
||||||
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
|
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(I)) {
|
||||||
MadeChange |= OptimizeGEPExpression(GEPI, TLI.getTargetData());
|
MadeChange |= OptimizeGEPExpression(GEPI, TLI.getTargetData());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user