[PATCH] D67849: [InstCombine] (a+b) < a && (a+b) != 0 -> (0-b) < a iff a/b != 0 (PR43259)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 13:26:25 PDT 2019
lebedev.ri 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)
----------------
spatel wrote:
> 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().
I didn't precommit this specifically because i wasn't able to come up with a test for this,
even though i use it in `foldUnsignedUnderflowCheck()` already.
But okay, let me precommit it...
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