[llvm] r355284 - [DemandedBits] Optimize a find()+insert pattern with try_emplace and APInt::operator|=
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 3 03:12:57 PST 2019
Author: maskray
Date: Sun Mar 3 03:12:57 2019
New Revision: 355284
URL: http://llvm.org/viewvc/llvm-project?rev=355284&view=rev
Log:
[DemandedBits] Optimize a find()+insert pattern with try_emplace and APInt::operator|=
Modified:
llvm/trunk/lib/Analysis/DemandedBits.cpp
Modified: llvm/trunk/lib/Analysis/DemandedBits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DemandedBits.cpp?rev=355284&r1=355283&r2=355284&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DemandedBits.cpp (original)
+++ llvm/trunk/lib/Analysis/DemandedBits.cpp Sun Mar 3 03:12:57 2019
@@ -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);
}
}
More information about the llvm-commits
mailing list