Handle regmasks in findRegisterDefOperandIdx().
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 14 Feb 2012 23:49:37 +0000 (23:49 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 14 Feb 2012 23:49:37 +0000 (23:49 +0000)
Only accept register masks when looking for an 'overlapping' def. When
Overlap is not set, the function searches for a proper definition of
Reg.

This means MI->modifiesRegister() considers register masks, but
MI->definesRegister() doesn't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150529 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineInstr.h
lib/CodeGen/MachineInstr.cpp

index 9a8ac7c029eb965ba03f01113a7418ca0269188e..7f29d316ea8592f4c44e22738c275d4d74cc65ac 100644 (file)
@@ -702,6 +702,7 @@ public:
   /// that are not dead are skipped. If Overlap is true, then it also looks for
   /// defs that merely overlap the specified register. If TargetRegisterInfo is
   /// non-null, then it also checks if there is a def of a super-register.
+  /// This may also return a register mask operand when Overlap is true.
   int findRegisterDefOperandIdx(unsigned Reg,
                                 bool isDead = false, bool Overlap = false,
                                 const TargetRegisterInfo *TRI = NULL) const;
index 0a657341ac8ad4476c27386c257bee33ccca467f..ff32a66b14c2d162c4cc310bf5b715e1095f1cce 100644 (file)
@@ -1045,6 +1045,10 @@ MachineInstr::findRegisterDefOperandIdx(unsigned Reg, bool isDead, bool Overlap,
   bool isPhys = TargetRegisterInfo::isPhysicalRegister(Reg);
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     const MachineOperand &MO = getOperand(i);
+    // Accept regmask operands when Overlap is set.
+    // Ignore them when looking for a specific def operand (Overlap == false).
+    if (isPhys && Overlap && MO.isRegMask() && MO.clobbersPhysReg(Reg))
+      return i;
     if (!MO.isReg() || !MO.isDef())
       continue;
     unsigned MOReg = MO.getReg();