[PATCH] D45204: [X86][MIPS][ARM] New machine instruction property 'isMoveReg'

Alexander Ivchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 26 05:39:06 PDT 2018


aivchenk added a comment.
Herald added a subscriber: jrtc27.

In a lot of cases, we would like to treat MoveReg-type instructions and generic COPY instruction in the same way.
E.g. in this code:

  // Analyze copies (which don't overlap themselves).
  if (MI->isCopy() && !TRI->regsOverlap(MI->getOperand(0).getReg(),
                                        MI->getOperand(1).getReg())) {
    unsigned Def = MI->getOperand(0).getReg();
    unsigned Src = MI->getOperand(1).getReg();

>
=

  const MachineOperand *DefOp = nullptr;
  const MachineOperand *SrcOp = nullptr;	 
  // Analyze copies (which don't overlap themselves).	 
  if (TII->isCopyInstr(*MI, SrcOp, DefOp) &&	 
      !TRI->regsOverlap(DefOp->getReg(), SrcOp->getReg())) {	 
    unsigned DefReg = DefOp->getReg();
    unsigned SrcReg = SrcOp->getReg();

But in order for this to work, we need to modify isCopyInstr to include isCopy check:

+++ b/lib/Target/X86/X86InstrInfo.cpp
@@ -3114,7 +3114,7 @@ void X86InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
 bool X86InstrInfo::isCopyInstr(const MachineInstr &MI,

  const MachineOperand *&Src,
  const MachineOperand *&Dest) const {

- if (MI.isMoveReg()) {

+  if (MI.isCopy() || MI.isMoveReg()) {

  Dest = &MI.getOperand(0);
  Src = &MI.getOperand(1);
  return true;

Do you think it makes sense?


Repository:
  rL LLVM

https://reviews.llvm.org/D45204





More information about the llvm-commits mailing list