diff options
author | Maksim Kita <kitaetoya@gmail.com> | 2023-07-19 17:07:40 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2023-07-19 17:12:27 +0200 |
commit | 8981520b19f2d2fe3d2bc80cf26318ee6b5b7473 (patch) | |
tree | cda96a55ba4b90ee38d3ef0aba89f85a01224e8f /llvm/lib/Analysis/ValueTracking.cpp | |
parent | e537c839757c6bae91bd5adbf65eb4e06a040840 (diff) | |
download | llvm-8981520b19f2d2fe3d2bc80cf26318ee6b5b7473.zip llvm-8981520b19f2d2fe3d2bc80cf26318ee6b5b7473.tar.gz llvm-8981520b19f2d2fe3d2bc80cf26318ee6b5b7473.tar.bz2 |
[AggressiveInstCombine] Fold strcmp for short string literals
Fold strcmp() against 1-char string literals.
This designates AggressiveInstCombine as the pass for libcalls
simplifications that may need to change the control flow graph.
Fixes https://github.com/llvm/llvm-project/issues/58003.
Differential Revision: https://reviews.llvm.org/D154725
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 4be171e..8940c2c 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -261,6 +261,13 @@ bool llvm::haveNoCommonBitsSet(const Value *LHS, const Value *RHS, return KnownBits::haveNoCommonBitsSet(LHSKnown, RHSKnown); } +bool llvm::isOnlyUsedInZeroComparison(const Instruction *I) { + return !I->user_empty() && all_of(I->users(), [](const User *U) { + ICmpInst::Predicate P; + return match(U, m_ICmp(P, m_Value(), m_Zero())); + }); +} + bool llvm::isOnlyUsedInZeroEqualityComparison(const Instruction *I) { return !I->user_empty() && all_of(I->users(), [](const User *U) { ICmpInst::Predicate P; |