mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
[FastISel][X86] - Add branch weights
Add branch weights to branch instructions, so that the following passes can optimize based on it (i.e. basic block ordering). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210863 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "X86RegisterInfo.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "X86TargetMachine.h"
|
||||
#include "llvm/Analysis/BranchProbabilityInfo.h"
|
||||
#include "llvm/CodeGen/Analysis.h"
|
||||
#include "llvm/CodeGen/FastISel.h"
|
||||
#include "llvm/CodeGen/FunctionLoweringInfo.h"
|
||||
@@ -1206,7 +1207,11 @@ bool X86FastISel::X86SelectBranch(const Instruction *I) {
|
||||
}
|
||||
|
||||
FastEmitBranch(FalseMBB, DbgLoc);
|
||||
FuncInfo.MBB->addSuccessor(TrueMBB);
|
||||
uint32_t BranchWeight = 0;
|
||||
if (FuncInfo.BPI)
|
||||
BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(),
|
||||
TrueMBB->getBasicBlock());
|
||||
FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight);
|
||||
return true;
|
||||
}
|
||||
} else if (TruncInst *TI = dyn_cast<TruncInst>(BI->getCondition())) {
|
||||
@@ -1238,7 +1243,11 @@ bool X86FastISel::X86SelectBranch(const Instruction *I) {
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(JmpOpc))
|
||||
.addMBB(TrueMBB);
|
||||
FastEmitBranch(FalseMBB, DbgLoc);
|
||||
FuncInfo.MBB->addSuccessor(TrueMBB);
|
||||
uint32_t BranchWeight = 0;
|
||||
if (FuncInfo.BPI)
|
||||
BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(),
|
||||
TrueMBB->getBasicBlock());
|
||||
FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1255,7 +1264,11 @@ bool X86FastISel::X86SelectBranch(const Instruction *I) {
|
||||
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(X86::JNE_4))
|
||||
.addMBB(TrueMBB);
|
||||
FastEmitBranch(FalseMBB, DbgLoc);
|
||||
FuncInfo.MBB->addSuccessor(TrueMBB);
|
||||
uint32_t BranchWeight = 0;
|
||||
if (FuncInfo.BPI)
|
||||
BranchWeight = FuncInfo.BPI->getEdgeWeight(BI->getParent(),
|
||||
TrueMBB->getBasicBlock());
|
||||
FuncInfo.MBB->addSuccessor(TrueMBB, BranchWeight);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user