aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorAnna Thomas <anna@azul.com>2021-09-20 16:37:38 -0400
committerAnna Thomas <anna@azul.com>2021-09-21 10:04:04 -0400
commit69921f6f4558a2c5c8e48c5b12d83a65127bfecc (patch)
treefefff8aef5347a6e94b7fd4ca7739748f437224c /llvm/lib/IR/Value.cpp
parentee31ad0ab5f7d443b0bd582582a3524dcf7f13f0 (diff)
downloadllvm-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.cpp12
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);
}