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

Quentin Colombet via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 8 09:42:53 PDT 2020


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



More information about the llvm-dev mailing list