[llvm] r175076 - LoopVectorize: Simplify code for clarity.

Benjamin Kramer benny.kra at googlemail.com
Wed Feb 13 13:12:29 PST 2013


Author: d0k
Date: Wed Feb 13 15:12:29 2013
New Revision: 175076

URL: http://llvm.org/viewvc/llvm-project?rev=175076&view=rev
Log:
LoopVectorize: Simplify code for clarity.

No functionality change.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=175076&r1=175075&r2=175076&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Wed Feb 13 15:12:29 2013
@@ -2805,17 +2805,17 @@ unsigned LoopVectorizationCostModel::get
           continue;
 
       // Examine the stored values.
-      StoreInst *ST = 0;
-      if ((ST = dyn_cast<StoreInst>(it)))
+      if (StoreInst *ST = dyn_cast<StoreInst>(it))
         T = ST->getValueOperand()->getType();
 
       // Ignore loaded pointer types and stored pointer types that are not
       // consecutive. However, we do want to take consecutive stores/loads of
       // pointer vectors into account.
-      if (T->isPointerTy() && isConsecutiveLoadOrStore(it))
-        MaxWidth = std::max(MaxWidth, DL->getPointerSizeInBits());
-      else
-        MaxWidth = std::max(MaxWidth, T->getScalarSizeInBits());
+      if (T->isPointerTy() && !isConsecutiveLoadOrStore(it))
+        continue;
+
+      MaxWidth = std::max(MaxWidth,
+                          (unsigned)DL->getTypeSizeInBits(T->getScalarType()));
     }
   }
 
@@ -3242,13 +3242,11 @@ namespace llvm {
 
 bool LoopVectorizationCostModel::isConsecutiveLoadOrStore(Instruction *Inst) {
   // Check for a store.
-  StoreInst *ST = dyn_cast<StoreInst>(Inst);
-  if (ST)
+  if (StoreInst *ST = dyn_cast<StoreInst>(Inst))
     return Legal->isConsecutivePtr(ST->getPointerOperand()) != 0;
 
   // Check for a load.
-  LoadInst *LI = dyn_cast<LoadInst>(Inst);
-  if (LI)
+  if (LoadInst *LI = dyn_cast<LoadInst>(Inst))
     return Legal->isConsecutivePtr(LI->getPointerOperand()) != 0;
 
   return false;





More information about the llvm-commits mailing list