summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-21 05:54:00 +0000
committerChris Lattner <sabre@nondot.org>2006-10-21 05:54:00 +0000
commit28f17f45beb2285ccc32a74771e5debf94e360ec (patch)
tree8a8240f9cd1cd02179a001b7817be01449ebc94b /llvm
parent3a897f31faeb16b754bc63e458bd4c4e51fb8b8f (diff)
downloadbcm5719-llvm-28f17f45beb2285ccc32a74771e5debf94e360ec.tar.gz
bcm5719-llvm-28f17f45beb2285ccc32a74771e5debf94e360ec.zip
Use branch reversal to do stuff like this:
call L_strcmp$stub testl %eax, %eax - jne LBB26_208 #cond_true6020 - jmp LBB26_227 #bb7119 + je LBB26_227 #bb7119 LBB26_208: #cond_true6020 movl $l31_str14, 4(%esp) testl %eax, %eax - jne LBB26_704 #cond_true13042 - jmp LBB26_713 #bb13151 + je LBB26_713 #bb13151 LBB26_704: #cond_true13042 movl $_str52, 4(%esp) cmpl 76(%ecx), %eax - jge LBB26_1628 #cond_false63.i.i - jmp LBB26_1769 #_Z8makeGridP13mrSurfaceListidiidd.exit.i + jl LBB26_1769 #_Z8makeGridP13mrSurfaceListidiidd.exit.i LBB26_1628: #cond_false63.i.i movl $0, 48964(%esp) llvm-svn: 31100
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/BranchFolding.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 5be6baf64c2..befcd002219 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -472,6 +472,20 @@ void BranchFolder::OptimizeBlock(MachineFunction::iterator MBB) {
++NumBranchOpts;
return OptimizeBlock(MBB);
}
+
+ // If the prior block branches here on true and somewhere else on false, and
+ // if the branch condition is reversible, reverse the branch to create a
+ // fall-through.
+ if (PriorTBB == &*MBB) {
+ std::vector<MachineOperand> NewPriorCond(PriorCond);
+ if (!TII->ReverseBranchCondition(NewPriorCond)) {
+ TII->RemoveBranch(PrevBB);
+ TII->InsertBranch(PrevBB, PriorFBB, 0, NewPriorCond);
+ MadeChange = true;
+ ++NumBranchOpts;
+ return OptimizeBlock(MBB);
+ }
+ }
}
// Analyze the branch in the current block.
OpenPOWER on IntegriCloud