summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/GlobalISel
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2019-10-16 23:53:35 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2019-10-16 23:53:35 +0000
commitec5208fd65668ec6415eb274294d284835f3d5dd (patch)
tree2fac90b4e440d37d71538370a3f585e3ea5476ff /llvm/lib/CodeGen/GlobalISel
parent168ef8a8d695eb374e8997e9d163c96c51f38624 (diff)
downloadbcm5719-llvm-ec5208fd65668ec6415eb274294d284835f3d5dd.tar.gz
bcm5719-llvm-ec5208fd65668ec6415eb274294d284835f3d5dd.zip
[gicombiner] Hoist pure C++ combine into the tablegen definition
Summary: This is just moving the existing C++ code around and will be NFC w.r.t AArch64. Renamed 'CombineBr' to something more descriptive ('ElideByByInvertingCond') at the same time. The remaining combines in AArch64PreLegalizeCombiner require features that aren't implemented at this point and will be hoisted as they are added. Depends on D68424 Reviewers: bogner, volkan Subscribers: kristof.beyls, hiraditya, Petar.Avramovic, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68426 llvm-svn: 375057
Diffstat (limited to 'llvm/lib/CodeGen/GlobalISel')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
index e9de6c2c98d..da78327ebdb 100644
--- a/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -561,8 +561,10 @@ bool CombinerHelper::tryCombineIndexedLoadStore(MachineInstr &MI) {
return true;
}
-bool CombinerHelper::matchCombineBr(MachineInstr &MI) {
- assert(MI.getOpcode() == TargetOpcode::G_BR && "Expected a G_BR");
+bool CombinerHelper::matchElideBrByInvertingCond(MachineInstr &MI) {
+ if (MI.getOpcode() != TargetOpcode::G_BR)
+ return false;
+
// Try to match the following:
// bb1:
// %c(s32) = G_ICMP pred, %a, %b
@@ -599,9 +601,14 @@ bool CombinerHelper::matchCombineBr(MachineInstr &MI) {
return true;
}
-bool CombinerHelper::tryCombineBr(MachineInstr &MI) {
- if (!matchCombineBr(MI))
+bool CombinerHelper::tryElideBrByInvertingCond(MachineInstr &MI) {
+ if (!matchElideBrByInvertingCond(MI))
return false;
+ applyElideBrByInvertingCond(MI);
+ return true;
+}
+
+void CombinerHelper::applyElideBrByInvertingCond(MachineInstr &MI) {
MachineBasicBlock *BrTarget = MI.getOperand(0).getMBB();
MachineBasicBlock::iterator BrIt(MI);
MachineInstr *BrCond = &*std::prev(BrIt);
@@ -620,7 +627,6 @@ bool CombinerHelper::tryCombineBr(MachineInstr &MI) {
BrCond->getOperand(1).setMBB(BrTarget);
Observer.changedInstr(*BrCond);
MI.eraseFromParent();
- return true;
}
static bool shouldLowerMemFuncForSize(const MachineFunction &MF) {
OpenPOWER on IntegriCloud