summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineSink.cpp
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2020-04-16 15:23:49 +0100
committerTom Stellard <tstellar@redhat.com>2020-05-07 07:27:37 -0700
commitbab8d1790a33235dfb0e633652ca7fa21d0fb0d0 (patch)
tree42e2bc1b3916a4c47ce60e4ffa8c16d60de784ca /llvm/lib/CodeGen/MachineSink.cpp
parent9c80516d3e3aae34b7dd7ee0204170c888fd7235 (diff)
downloadbcm5719-llvm-bab8d1790a33235dfb0e633652ca7fa21d0fb0d0.tar.gz
bcm5719-llvm-bab8d1790a33235dfb0e633652ca7fa21d0fb0d0.zip
[MachineSink] Fix for breaking phi edges with instructions with multiple defs
BreakPHIEdge would be set based on whether the instruction needs to insert a new critical edge to allow sinking into a block where the uses are PHI nodes. But for instructions with multiple defs it would be reset on the second def, allowing the instruciton to sink where it should not. Fixes PR44981 Differential Revision: https://reviews.llvm.org/D78087 (cherry picked from commit 44c4ba34d001dcf538d7396007b5611d6f697f86)
Diffstat (limited to 'llvm/lib/CodeGen/MachineSink.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineSink.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/llvm/lib/CodeGen/MachineSink.cpp b/llvm/lib/CodeGen/MachineSink.cpp
index a4ba197b7a1..239b6fd6fd6 100644
--- a/llvm/lib/CodeGen/MachineSink.cpp
+++ b/llvm/lib/CodeGen/MachineSink.cpp
@@ -269,30 +269,26 @@ MachineSinking::AllUsesDominatedByBlock(unsigned Reg,
// into and they are all PHI nodes. In this case, machine-sink must break
// the critical edge first. e.g.
//
- // %bb.1: derived from LLVM BB %bb4.preheader
+ // %bb.1:
// Predecessors according to CFG: %bb.0
// ...
- // %reg16385 = DEC64_32r %reg16437, implicit-def dead %eflags
+ // %def = DEC64_32r %x, implicit-def dead %eflags
// ...
// JE_4 <%bb.37>, implicit %eflags
// Successors according to CFG: %bb.37 %bb.2
//
- // %bb.2: derived from LLVM BB %bb.nph
- // Predecessors according to CFG: %bb.0 %bb.1
- // %reg16386 = PHI %reg16434, %bb.0, %reg16385, %bb.1
- BreakPHIEdge = true;
- for (MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
- MachineInstr *UseInst = MO.getParent();
- unsigned OpNo = &MO - &UseInst->getOperand(0);
- MachineBasicBlock *UseBlock = UseInst->getParent();
- if (!(UseBlock == MBB && UseInst->isPHI() &&
- UseInst->getOperand(OpNo+1).getMBB() == DefMBB)) {
- BreakPHIEdge = false;
- break;
- }
- }
- if (BreakPHIEdge)
+ // %bb.2:
+ // %p = PHI %y, %bb.0, %def, %bb.1
+ if (llvm::all_of(MRI->use_nodbg_operands(Reg), [&](MachineOperand &MO) {
+ MachineInstr *UseInst = MO.getParent();
+ unsigned OpNo = UseInst->getOperandNo(&MO);
+ MachineBasicBlock *UseBlock = UseInst->getParent();
+ return UseBlock == MBB && UseInst->isPHI() &&
+ UseInst->getOperand(OpNo + 1).getMBB() == DefMBB;
+ })) {
+ BreakPHIEdge = true;
return true;
+ }
for (MachineOperand &MO : MRI->use_nodbg_operands(Reg)) {
// Determine the block of the use.
OpenPOWER on IntegriCloud