[PATCH] D61693: Rough out InstCombine::visitFNeg(...)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 12:43:00 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1828-1829
+
+  // Fold negation into constant operand. This is limited with one-use because
+  // fneg is assumed better for analysis and cheaper in codegen than fmul/fdiv.
+  // -(X * C) --> X * (-C)
----------------
I'm not confident this one-use check should be here.
We start with two ops - negation and some inner operand.
We will drop the negation, replace with with a single op we build.
Therefore there is no instruction count explosion.
And less instructions should be pretty much always better.

Though i see that this is only moving it around.

The performance concern (the inverse transform,
`X * (-C)` -> `-(X * C)` if `(X * C)` already exists)
should be a separate fold in dagcombine..


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61693





More information about the llvm-commits mailing list