diff options
author | Dmitry Makogon <d.makogon@g.nsu.ru> | 2023-04-12 18:44:40 +0700 |
---|---|---|
committer | Dmitry Makogon <d.makogon@g.nsu.ru> | 2023-04-12 18:46:11 +0700 |
commit | 797da79a928eef3b389883ea873cc32060e812fa (patch) | |
tree | 3de7aa345062980ce1f78a248228bedebb9b5a14 /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | 7e5b10b9f74d4e34a0eb2db806b98ecb1c31daf1 (diff) | |
download | llvm-797da79a928eef3b389883ea873cc32060e812fa.zip llvm-797da79a928eef3b389883ea873cc32060e812fa.tar.gz llvm-797da79a928eef3b389883ea873cc32060e812fa.tar.bz2 |
[LoopUtils] Add isKnownPositiveInLoop and isKnownNonPositiveInLoop functions
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 1c58370..31872c1 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1136,6 +1136,20 @@ bool llvm::isKnownNonNegativeInLoop(const SCEV *S, const Loop *L, SE.isLoopEntryGuardedByCond(L, ICmpInst::ICMP_SGE, S, Zero); } +bool llvm::isKnownPositiveInLoop(const SCEV *S, const Loop *L, + ScalarEvolution &SE) { + const SCEV *Zero = SE.getZero(S->getType()); + return SE.isAvailableAtLoopEntry(S, L) && + SE.isLoopEntryGuardedByCond(L, ICmpInst::ICMP_SGT, S, Zero); +} + +bool llvm::isKnownNonPositiveInLoop(const SCEV *S, const Loop *L, + ScalarEvolution &SE) { + const SCEV *Zero = SE.getZero(S->getType()); + return SE.isAvailableAtLoopEntry(S, L) && + SE.isLoopEntryGuardedByCond(L, ICmpInst::ICMP_SLE, S, Zero); +} + bool llvm::cannotBeMinInLoop(const SCEV *S, const Loop *L, ScalarEvolution &SE, bool Signed) { unsigned BitWidth = cast<IntegerType>(S->getType())->getBitWidth(); |