[llvm] r293719 - InferAddressSpaces: Avoid double map lookup
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 31 15:48:44 PST 2017
Author: arsenm
Date: Tue Jan 31 17:48:44 2017
New Revision: 293719
URL: http://llvm.org/viewvc/llvm-project?rev=293719&view=rev
Log:
InferAddressSpaces: Avoid double map lookup
Modified:
llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp?rev=293719&r1=293718&r2=293719&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InferAddressSpaces.cpp Tue Jan 31 17:48:44 2017
@@ -583,14 +583,12 @@ Optional<unsigned> InferAddressSpaces::u
// of all its pointer operands.
unsigned NewAS = UninitializedAddressSpace;
for (Value *PtrOperand : getPointerOperands(V)) {
- unsigned OperandAS;
- if (InferredAddrSpace.count(PtrOperand))
- OperandAS = InferredAddrSpace.lookup(PtrOperand);
- else
- OperandAS = PtrOperand->getType()->getPointerAddressSpace();
- NewAS = joinAddressSpaces(NewAS, OperandAS);
+ auto I = InferredAddrSpace.find(PtrOperand);
+ unsigned OperandAS = I != InferredAddrSpace.end() ?
+ I->second : PtrOperand->getType()->getPointerAddressSpace();
// join(flat, *) = flat. So we can break if NewAS is already flat.
+ NewAS = joinAddressSpaces(NewAS, OperandAS);
if (NewAS == FlatAddrSpace)
break;
}
More information about the llvm-commits
mailing list