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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 23 13:21:27 PDT 2019


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1144-1145
                                     Instruction &CxtI) {
+  const SimplifyQuery Q = SQ.getWithInstruction(&CxtI);
+
   // Fold (!iszero(A & K1) & !iszero(A & K2)) ->  (A & (K1 | K2)) == (K1 | K2)
----------------
lebedev.ri wrote:
> spatel wrote:
> > Does this diff mean the existing code is buggy or somehow less powerful? Is there a path where the context instruction is not the 'and' or 'or'?
> The current code is less powerful.
> Without this, none of those folds happen.
> In `SQ`, `CxtI` is `nullptr`.
Then we should make that change ahead of this patch? IMO, it's ok to change it without adding a special test, but it's independent of the main diff since we're already calling isKnownNonZero() from foldUnsignedUnderflowCheck().


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