[PATCH] D67553: [InstSimplify] Match 1.0 and 0.0 for both operands in SimplifyFMAMul

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 13 09:16:21 PDT 2019


reames accepted this revision.
reames added inline comments.
This revision is now accepted and ready to land.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:4561
                               const SimplifyQuery &Q, unsigned MaxRecurse) {
   // fmul X, 1.0 ==> X
   if (match(Op1, m_FPOne()))
----------------
fhahn wrote:
> lebedev.ri wrote:
> > I'm wondering if 
> > ```
> > {
> > if(isa<Constant>(Op0)) std::swap(Op0, Op1);
> > ```
> > would be simpler?
> I initially also used to swap the operands, but we'd also have to check if it's a 1.1 or 0.0 constant I think, to handle `fmul 10.0, 0.0`. That's not a problem with SimplifyFMulInst, as constant folding would cover this case.
I believe that fmul is not necessarily commutative (for nan inputs).  Given that, swap would be correct for this case, but dangerous in general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67553





More information about the llvm-commits mailing list