vivek pandya via llvm-dev
2020-Oct-08 11:58 UTC
[llvm-dev] Ignore Constant Physical Register Def in MachineCSE::hasLivePhysRegDefUses()
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>
Quentin Colombet via llvm-dev
2020-Oct-08 16:42 UTC
[llvm-dev] Ignore Constant Physical Register Def in MachineCSE::hasLivePhysRegDefUses()
Hi Vivek, Constant physical register should be fine to ignore. Cheers, -Quentin> On Oct 8, 2020, at 4:58 AM, vivek pandya via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > 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 > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev