summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-03-03 11:12:57 +0000
committerFangrui Song <maskray@google.com>2019-03-03 11:12:57 +0000
commit981f216d1da586c67c5bf7b3e61ebf867dff9dae (patch)
treecf2c368f3936244d31aeab414d93c55a86dfe096
parent8f04766d133440bc5d6f8241395c44f0eb2b0b74 (diff)
downloadbcm5719-llvm-981f216d1da586c67c5bf7b3e61ebf867dff9dae.tar.gz
bcm5719-llvm-981f216d1da586c67c5bf7b3e61ebf867dff9dae.zip
[DemandedBits] Optimize a find()+insert pattern with try_emplace and APInt::operator|=
llvm-svn: 355284
-rw-r--r--llvm/lib/Analysis/DemandedBits.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/llvm/lib/Analysis/DemandedBits.cpp b/llvm/lib/Analysis/DemandedBits.cpp
index 0df47a9eda6..48412d204dc 100644
--- a/llvm/lib/Analysis/DemandedBits.cpp
+++ b/llvm/lib/Analysis/DemandedBits.cpp
@@ -402,14 +402,9 @@ void DemandedBits::performAnalysis() {
// If we've added to the set of alive bits (or the operand has not
// been previously visited), then re-queue the operand to be visited
// again.
- APInt ABPrev(BitWidth, 0);
- auto ABI = AliveBits.find(I);
- if (ABI != AliveBits.end())
- ABPrev = ABI->second;
-
- APInt ABNew = AB | ABPrev;
- if (ABNew != ABPrev || ABI == AliveBits.end()) {
- AliveBits[I] = std::move(ABNew);
+ auto Res = AliveBits.try_emplace(I);
+ if (Res.second || (AB |= Res.first->second) != Res.first->second) {
+ Res.first->second = std::move(AB);
Worklist.insert(I);
}
}
OpenPOWER on IntegriCloud