[PATCH] D62629: [InstCombine] Update fptrunc (fneg x)) -> (fneg (fptrunc x) for unary FNeg

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 14:42:26 PDT 2019


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


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:1625
+    Value *InnerTrunc = Builder.CreateFPTrunc(X, Ty);
+    return BinaryOperator::CreateFNegFMF(InnerTrunc, cast<Instruction>(Op));
   }
----------------
craig.topper wrote:
> If you started with a unary fneg, shouldn't we end up with a unary fneg?
So this combine actually covers both unary and binary FNeg. `m_FNeg(X)` will match an `FSub(-0.0,X)`. The end goal is that both will end up producing an unary FNeg.

But, yeah, I see what you're saying. I could dispatch on the operator type for now, but it would be code to clean up later. I suppose the BinaryOperator will have to be switched to an UnaryOperator in the future anyway, so I'm not sure how much work I'm saving.

Just thinking aloud, I don't have a preference...


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62629





More information about the llvm-commits mailing list