[PATCH] D71660: [ValueTracking] isKnownNonZero() should take non-null-ness assumptions into consideration (PR43267)
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 11:36:01 PST 2019
nikic added a comment.
> I get that. The question is, given we have AssumptionCache abstraction, why do we want to avoid it.
As this code now handles more predicates than the other code-path, I'm okay with your approach.
================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:623
+ return true;
+ }
+ }
----------------
lebedev.ri wrote:
> jdoerfert wrote:
> > < is also fine, however unlikely.
> Right, https://rise4fun.com/Alive/plslNp
As you went through the effort of supporting different predicates, possibly extend this to also handle non-zero constant? That is, not just `x > 0` but also `x > 100`. Something along the lines of...
```
if (!match(Cmp, m_ICmp(Pred, m_V, m_APInt(C))))
return false;
// Possibly without the non-canonical predicates?
switch (Pred) {
case ICmpInst::ICMP_NE:
return C->isNullValue();
case ICmpInst::ICMP_UGT:
return true;
case ICmpInst::ICMP_UGE:
return !C->isNullValue();
case ICmpInst::ICMP_SGT:
return C->isNonNegative();
case ICmpInst::ICMP_SGE:
return C->isStrictlyPositive();
case ICmpInst::ICMP_SLT:
return !C->isStrictlyPositive();
case ICmpInst::ICMP_SLE:
return C->isNegative();
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71660/new/
https://reviews.llvm.org/D71660
More information about the llvm-commits
mailing list