if (TargetRegisterInfo::isVirtualRegister(Reg)) {
SlotIndex LastUse = Before;
for (MachineOperand &MO : MRI.use_nodbg_operands(Reg)) {
+ if (MO.isUndef())
+ continue;
unsigned SubReg = MO.getSubReg();
if (SubReg != 0 && LaneMask != 0
&& (TRI.getSubRegIndexLaneMask(SubReg) & LaneMask) == 0)
// Check if MII uses Reg.
for (MIBundleOperands MO(*MII); MO.isValid(); ++MO)
- if (MO->isReg() &&
+ if (MO->isReg() && !MO->isUndef() &&
TargetRegisterInfo::isPhysicalRegister(MO->getReg()) &&
TRI.hasRegUnit(MO->getReg(), Reg))
return Idx.getRegSlot();
});
}
+TEST(LiveIntervalTest, MoveOverUndefUse0) {
+ // findLastUseBefore() used by handleMoveUp() must ignore undef operands.
+ liveIntervalTest(
+" %0 = IMPLICIT_DEF\n"
+" NOOP\n"
+" NOOP implicit undef %0\n"
+" %0 = IMPLICIT_DEF implicit %0(tied-def 0)\n",
+ [](MachineFunction &MF, LiveIntervals &LIS) {
+ testHandleMove(MF, LIS, 3, 1);
+ });
+}
+
+TEST(LiveIntervalTest, MoveOverUndefUse1) {
+ // findLastUseBefore() used by handleMoveUp() must ignore undef operands.
+ liveIntervalTest(
+" %rax = IMPLICIT_DEF\n"
+" NOOP\n"
+" NOOP implicit undef %rax\n"
+" %rax = IMPLICIT_DEF implicit %rax(tied-def 0)\n",
+ [](MachineFunction &MF, LiveIntervals &LIS) {
+ testHandleMove(MF, LIS, 3, 1);
+ });
+}
+
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
initLLVM();