diff options
author | Philip Reames <listmail@philipreames.com> | 2016-03-09 21:31:47 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2016-03-09 21:31:47 +0000 |
commit | 8f12eba78d7ef7cd849af8e6658e6a20c6f6f772 (patch) | |
tree | 394453df7083c9113b4d4b1676f6a209e24008cb /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 2b4df612ecb3503cb849231f96e2b90f8db546fe (diff) | |
download | bcm5719-llvm-8f12eba78d7ef7cd849af8e6658e6a20c6f6f772.tar.gz bcm5719-llvm-8f12eba78d7ef7cd849af8e6658e6a20c6f6f772.zip |
[ValueTracking] Extract isKnownPositive [NFCI]
Extract out a generic interface from a recently landed patch and document a TODO in case compile time becomes a problem.
llvm-svn: 263062
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 098da0afca5..79529e5fa79 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -182,6 +182,18 @@ bool llvm::isKnownNonNegative(Value *V, const DataLayout &DL, unsigned Depth, return NonNegative; } +bool llvm::isKnownPositive(Value *V, const DataLayout &DL, unsigned Depth, + AssumptionCache *AC, const Instruction *CxtI, + const DominatorTree *DT) { + if (auto *CI = dyn_cast<ConstantInt>(V)) + return CI->getValue().isStrictlyPositive(); + + // TODO: We'd doing two recursive queries here. We should factor this such + // that only a single query is needed. + return isKnownNonNegative(V, DL, Depth, AC, CxtI, DT) && + isKnownNonZero(V, DL, Depth, AC, CxtI, DT); +} + static bool isKnownNonEqual(Value *V1, Value *V2, const Query &Q); bool llvm::isKnownNonEqual(Value *V1, Value *V2, const DataLayout &DL, |