[PATCH] D62077: [InstSimplify] Teach fsub -0.0, (fneg X) ==> X about unary fneg

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 13:21:07 PDT 2019


cameron.mcinally marked an inline comment as done.
cameron.mcinally added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4402
     return X;
 
   // fsub 0.0, (fsub 0.0, X) ==> X if signed zeros are ignored.
----------------
I wasn't sure whether to go with the code above or explicitly match both FNeg and FSub. I.e.

```
  // fsub -0.0, (fsub -0.0, X) ==> X
  // fsub -0.0, (fneg X) ==> X
  Value *X;
  if (match(Op0, m_NegZeroFP()) &&
      (match(Op1, m_FSub(m_NegZeroFP(), m_Value(X))) ||
       match(Op1, m_FNeg(m_Value(X)))))
    return X;
```

An FSub(-0.0, X) --> FNeg(X) is ok -- and we should probably match them as such, as we do now. But a purist in the future might want to separate the two. 

Either option is safe to do, since tests will catch the purist's future change to m_FNeg(...). So it's really just a community preference.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62077/new/

https://reviews.llvm.org/D62077





More information about the llvm-commits mailing list