[llvm] [ValueTracking] improve `isKnownNonZero` precision for `smax` (PR #88170)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 22:55:56 PDT 2024
================
@@ -2828,23 +2828,44 @@ static bool isKnownNonZeroFromOperator(const Operator *I,
case Intrinsic::uadd_sat:
return isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q) ||
isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q);
- case Intrinsic::smin:
case Intrinsic::smax: {
- auto KnownOpImpliesNonZero = [&](const KnownBits &K) {
- return II->getIntrinsicID() == Intrinsic::smin
- ? K.isNegative()
- : K.isStrictlyPositive();
+ // If either arg is strictly positive the result is non-zero. Otherwise
+ // the result is non-zero if both ops are non-zero.
+ auto IsNonZero = [&](Value *Op, std::optional<bool> &OpNonZero,
+ KnownBits OpKnown) {
----------------
nikic wrote:
```suggestion
const KnownBits &OpKnown) {
```
https://github.com/llvm/llvm-project/pull/88170
More information about the llvm-commits
mailing list