[mips] Check the register class before replacing materializations of zero with $zero...
[oota-llvm.git] / lib / Target / Mips / MipsSEISelDAGToDAG.cpp
index dff30c78bb54832d4e86978945eb3391b4c54844..6f001ea74b30496dfaf9abf00109ed152ccc67ce 100644 (file)
@@ -115,6 +115,11 @@ bool MipsSEDAGToDAGISel::replaceUsesWithZeroReg(MachineRegisterInfo *MRI,
     if (MI->isPHI() || MI->isRegTiedToDefOperand(OpNo) || MI->isPseudo())
       continue;
 
+    // Also, we have to check that the register class of the operand
+    // contains the zero register.
+    if (!MRI->getRegClass(MO.getReg())->contains(ZeroReg))
+      continue;
+
     MO.setReg(ZeroReg);
   }