[PATCH] D25991: [PPC] Peephole to remove extra fcmp that checks for NaN

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 18:22:29 PDT 2016


hfinkel added inline comments.


================
Comment at: lib/Target/PowerPC/PPCInstrInfo.cpp:1585
+  unsigned otherReg =
+    (CROp->getOperand(1).getReg() == CopyReg ?
+                                     CROp->getOperand(2).getReg() :
----------------
amehsan wrote:
> hfinkel wrote:
> > What is the conditional here on CopyReg actually testing. How could it be zero (i.e. an invalid register) if hasOneUse(CopyReg) was true?
> The CROp has two source operands (Operands 1 and 2). If Operand(1) is the same Reg that was defined by Copy insn we just visited (CopyReg), then we look at Operand (2) and go to its definition. Otherwise, Operand(2) will be CopyReg and we should start from Operand(1) and go to its definition, etc. 
I still don't understand. CopyReg is defined above as:

  unsigned CopyReg = CopyMI->getOperand(0).getReg();
  if (!MRI->hasOneUse(CopyReg))
    return false;

under what conditions is CopyReg zero (i.e. an invalid register)?



https://reviews.llvm.org/D25991





More information about the llvm-commits mailing list