[llvm-dev] Ignore Constant Physical Register Def in MachineCSE::hasLivePhysRegDefUses()

vivek pandya via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 8 04:58:52 PDT 2020


Hello,

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


Thanks,
Vivek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201008/8cea502c/attachment.html>


More information about the llvm-dev mailing list