From: Krzysztof Parzyszek Date: Wed, 9 Aug 2017 19:58:00 +0000 (+0000) Subject: [Hexagon] Tie implicit uses to defs in predicated instructions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c052f6d2ac7488bcc12a4e150d5ade301b8f8fca;p=llvm [Hexagon] Tie implicit uses to defs in predicated instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310514 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Hexagon/HexagonExpandCondsets.cpp b/lib/Target/Hexagon/HexagonExpandCondsets.cpp index bacb4b1a192..b37a1e71630 100644 --- a/lib/Target/Hexagon/HexagonExpandCondsets.cpp +++ b/lib/Target/Hexagon/HexagonExpandCondsets.cpp @@ -488,16 +488,32 @@ void HexagonExpandCondsets::updateDeadsInRange(unsigned Reg, LaneBitmask LM, if (!HII->isPredicated(*DefI)) continue; // Construct the set of all necessary implicit uses, based on the def - // operands in the instruction. - std::set ImpUses; - for (auto &Op : DefI->operands()) - if (Op.isReg() && Op.isDef() && DefRegs.count(Op)) - ImpUses.insert(Op); + // operands in the instruction. We need to tie the implicit uses to + // the corresponding defs. + std::map ImpUses; + for (unsigned i = 0, e = DefI->getNumOperands(); i != e; ++i) { + MachineOperand &Op = DefI->getOperand(i); + if (!Op.isReg() || !DefRegs.count(Op)) + continue; + if (Op.isDef()) { + ImpUses.insert({Op, i}); + } else { + // This function can be called for the same register with different + // lane masks. If the def in this instruction was for the whole + // register, we can get here more than once. Avoid adding multiple + // implicit uses (or adding an implicit use when an explicit one is + // present). + ImpUses.erase(Op); + } + } if (ImpUses.empty()) continue; MachineFunction &MF = *DefI->getParent()->getParent(); - for (RegisterRef R : ImpUses) + for (std::pair P : ImpUses) { + RegisterRef R = P.first; MachineInstrBuilder(MF, DefI).addReg(R.Reg, RegState::Implicit, R.Sub); + DefI->tieOperands(P.second, DefI->getNumOperands()-1); + } } }