<div dir="ltr"><div>Hello,</div><div><br></div><div>Why can't a constant physical register be ignored in MachineCSE::hasLivePhysRegDefUses()?</div><div>Like as shown below:</div><div>diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp<br>index 9561a06ce8d..b92c26feb30 100644<br>--- a/llvm/lib/CodeGen/MachineCSE.cpp<br>+++ b/llvm/lib/CodeGen/MachineCSE.cpp<br>@@ -297,6 +297,7 @@ bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI,<br>   // Next, collect all defs into PhysDefs.  If any is already in PhysRefs<br>   // (which currently contains only uses), set the PhysUseDef flag.<br>   PhysUseDef = false;<br>+  const MachineRegisterInfo &MRI = MI->getMF()->getRegInfo();<br>   MachineBasicBlock::const_iterator I = MI; I = std::next(I);<br>   for (const auto &MOP : llvm::enumerate(MI->operands())) {<br>     const MachineOperand &MO = MOP.value();<br>@@ -307,6 +308,8 @@ bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI,<br>       continue;<br>     if (Register::isVirtualRegister(Reg))<br>       continue;<br>+    if (MRI.isConstantPhysReg(Reg))<br>+      continue;<br>     // Check against PhysRefs even if the def is "dead".<br>     if (PhysRefs.count(Reg))<br>       PhysUseDef = true;</div><div><br></div><div><br></div><div>Thanks,</div><div>Vivek<br></div></div>