Skip to content

Commit

Permalink
[ValueTracking] Check non-zero operator before dominating condition (…
Browse files Browse the repository at this point in the history
…NFC)

Prefer checking for non-zero operator before non-zero via
dominating conditions. This is to make sure we don't have
compile-time regressions when special cases that are currently
part of isKnownNonZero() get moved into isKnownNonZeroFromOperator().
  • Loading branch information
nikic committed Jul 21, 2023
1 parent ae60706 commit 4f7e034
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llvm/lib/Analysis/ValueTracking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2856,13 +2856,14 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,
}
}

if (const auto *I = dyn_cast<Operator>(V))
if (isKnownNonZeroFromOperator(I, DemandedElts, Depth, Q))
return true;

if (!isa<Constant>(V) &&
isKnownNonNullFromDominatingCondition(V, Q.CxtI, Q.DT))
return true;

if (const auto *I = dyn_cast<Operator>(V))
return isKnownNonZeroFromOperator(I, DemandedElts, Depth, Q);

return false;
}

Expand Down

0 comments on commit 4f7e034

Please sign in to comment.