Index: src/IceTargetLoweringX8632.cpp |
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp |
index 464a2e88a91260686a086eb91a6016eb1cf92dcc..31c11d4efdd65782cd576ca4c95963af34295435 100644 |
--- a/src/IceTargetLoweringX8632.cpp |
+++ b/src/IceTargetLoweringX8632.cpp |
@@ -395,6 +395,14 @@ void TargetX8632::translateO2() { |
T_genFrame.printElapsedUs(Context, "genFrame()"); |
Func->dump("After stack frame mapping"); |
+ // Branch optimization. This needs to be done just before code |
+ // emission. In particular, no transformations that insert or |
+ // reorder CfgNodes should be done after branch optimization. We go |
+ // ahead and do it before nop insertion to reduce the amount of work |
+ // needed for searching for opportunities. |
+ Func->doBranchOpt(); |
+ Func->dump("After branch optimization"); |
+ |
// Nop insertion |
if (shouldDoNopInsertion()) { |
Func->doNopInsertion(); |
@@ -444,6 +452,13 @@ void TargetX8632::translateOm1() { |
} |
} |
+bool TargetX8632::doBranchOpt(Inst *I, const CfgNode *NextNode) { |
+ if (InstX8632Br *Br = llvm::dyn_cast<InstX8632Br>(I)) { |
+ return Br->optimizeBranch(NextNode); |
+ } |
+ return false; |
+} |
+ |
IceString TargetX8632::RegNames[] = { |
#define X(val, init, name, name16, name8, scratch, preserved, stackptr, \ |
frameptr, isI8, isInt, isFP) \ |