diff options
author | Anna Thomas <anna@azul.com> | 2021-09-15 18:42:44 +0000 |
---|---|---|
committer | Anna Thomas <anna@azul.com> | 2021-09-15 20:39:38 +0000 |
commit | 4ac4e52189aa6d80c3d59dc2c8f7dcc0cb7f9d58 (patch) | |
tree | 464c928258d6f73081c81be8b6e700e5084a3d43 /llvm/lib/IR/Value.cpp | |
parent | 248e430f37c8486e526147c5e6b8cbda1e633467 (diff) | |
download | llvm-4ac4e52189aa6d80c3d59dc2c8f7dcc0cb7f9d58.zip llvm-4ac4e52189aa6d80c3d59dc2c8f7dcc0cb7f9d58.tar.gz llvm-4ac4e52189aa6d80c3d59dc2c8f7dcc0cb7f9d58.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, the API for retrieving undroppable user has been updated accordingly since
in both usecases (Attributor and InstCombine), we seem to care about the user,
rather than the use.
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, 6 insertions, 6 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index da67da1..a47ab68 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -164,13 +164,13 @@ bool Value::hasOneUser() const { static bool isUnDroppableUser(const User *U) { return !U->isDroppable(); } -Use *Value::getSingleUndroppableUse() { - Use *Result = nullptr; - for (Use &U : uses()) { - if (!U.getUser()->isDroppable()) { - if (Result) +User *Value::getUniqueUndroppableUser() { + User *Result = nullptr; + for (auto *U : users()) { + if (!U->isDroppable()) { + if (Result && Result != U) return nullptr; - Result = &U; + Result = U; } } return Result; |