[polly] r185260 - BlockGenerator: Simplify the old value searching code.

Hongbin Zheng etherzhhb at gmail.com
Sat Jun 29 06:22:15 PDT 2013


Author: ether
Date: Sat Jun 29 08:22:15 2013
New Revision: 185260

URL: http://llvm.org/viewvc/llvm-project?rev=185260&view=rev
Log:
BlockGenerator: Simplify the old value searching code.

Orignally, we first test if a ValueMap contains a Value, and than use the
index operator to get the corresponding new value. This requires the ValueMap
to lookup the key (i.e. the old value) twice.

Now, we directly use the "lookup" function provided by DenseMap to implement
the same functionality.

Modified:
    polly/trunk/lib/CodeGen/BlockGenerators.cpp

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=185260&r1=185259&r2=185260&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Sat Jun 29 08:22:15 2013
@@ -166,9 +166,7 @@ Value *BlockGenerator::getNewValue(const
   if (isa<Constant>(Old))
     return const_cast<Value *>(Old);
 
-  if (GlobalMap.count(Old)) {
-    Value *New = GlobalMap[Old];
-
+  if (Value *New = GlobalMap.lookup(Old)) {
     if (Old->getType()->getScalarSizeInBits() <
         New->getType()->getScalarSizeInBits())
       New = Builder.CreateTruncOrBitCast(New, Old->getType());
@@ -176,10 +174,8 @@ Value *BlockGenerator::getNewValue(const
     return New;
   }
 
-  if (BBMap.count(Old)) {
-    assert(BBMap[Old] && "BBMap[Old] should not be NULL!");
-    return BBMap[Old];
-  }
+  if (Value *New = BBMap.lookup(Old))
+    return New;
 
   if (SCEVCodegen && SE.isSCEVable(Old->getType()))
     if (const SCEV *Scev = SE.getSCEVAtScope(const_cast<Value *>(Old), L)) {
@@ -395,8 +391,8 @@ Value *VectorBlockGenerator::getVectorVa
                                             ValueMapT &VectorMap,
                                             VectorValueMapT &ScalarMaps,
                                             Loop *L) {
-  if (VectorMap.count(Old))
-    return VectorMap[Old];
+  if (Value *NewValue = VectorMap.lookup(Old))
+    return NewValue;
 
   int Width = getVectorWidth();
 





More information about the llvm-commits mailing list