[PATCH] D29343: InferAddressSpaces: Avoid double map lookup

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 12:28:24 PST 2017


arsenm created this revision.
Herald added a subscriber: wdng.

https://reviews.llvm.org/D29343

Files:
  lib/Transforms/Scalar/InferAddressSpaces.cpp


Index: lib/Transforms/Scalar/InferAddressSpaces.cpp
===================================================================
--- lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -591,14 +591,12 @@
   // 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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29343.86475.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170131/d2a6ada4/attachment.bin>


More information about the llvm-commits mailing list