diff options
author | Anna Thomas <anna@azul.com> | 2021-09-20 16:37:38 -0400 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2021-09-21 10:04:04 -0400 |
commit | 69921f6f4558a2c5c8e48c5b12d83a65127bfecc (patch) | |
tree | fefff8aef5347a6e94b7fd4ca7739748f437224c /llvm/lib/IR/Value.cpp | |
parent | ee31ad0ab5f7d443b0bd582582a3524dcf7f13f0 (diff) | |
download | llvm-69921f6f4558a2c5c8e48c5b12d83a65127bfecc.zip llvm-69921f6f4558a2c5c8e48c5b12d83a65127bfecc.tar.gz llvm-69921f6f4558a2c5c8e48c5b12d83a65127bfecc.tar.bz2 |
[InstCombine] Improve TryToSinkInstruction with multiple uses
This patch allows sinking an instruction which can have multiple uses in a
single user. We were previously over-restrictive by looking for exactly one use,
rather than one user.
Also added an API for retrieving a unique undroppable user.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D109700
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index a13380b..0f11bf61 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -176,6 +176,18 @@ Use *Value::getSingleUndroppableUse() { return Result; } +User *Value::getUniqueUndroppableUser() { + User *Result = nullptr; + for (auto *U : users()) { + if (!U->isDroppable()) { + if (Result && Result != U) + return nullptr; + Result = U; + } + } + return Result; +} + bool Value::hasNUndroppableUses(unsigned int N) const { return hasNItems(user_begin(), user_end(), N, isUnDroppableUser); } |