[PATCH] D67849: [InstCombine] (a+b) < a && (a+b) != 0 -> (0-b) < a iff a/b != 0 (PR43259)

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 06:34:54 PDT 2019


xbolva00 added a subscriber: efriedma.
xbolva00 added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1064
 
+  auto IsKnownNonZero = [&](Value *V) {
+    return isKnownNonZero(V, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT);
----------------
lebedev.ri wrote:
> xbolva00 wrote:
> > lebedev.ri wrote:
> > > xbolva00 wrote:
> > > > I think we dont need this lambda.. Just inline it.
> > > I don't see why spelling all that each time is better.
> > So just add a new overload which takes
> > 
> > isKnownNonZero(V, Q)?
> ValueTracking.h (that defines internal `Query` struct) does not
> include InstructionSimplify (that defines `SimplifyQuery` struct).
> Going in either direction does not seem optimal, and seems out of the scope of the patch.
> 
> This isn't C, and in C++ i suppose using helpers if they improve code readability is not frowned upon..
Thanks for info - just wanted to say: If we can add a overload, we should.. (instead of using lambda).

For me, the 'isKnownNonZero(V, Q.DL, /*Depth=*/0, Q.AC, Q.CxtI, Q.DT);' is fine.

I am personally not very happy to look at the code where there are so many lambdas in one function (what may happen here in the future). I prefer static helper functions..

But this is just my opinion, but I would like to hear opinions of @spatel / @efriedma too.






Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67849





More information about the llvm-commits mailing list