[llvm-commits] [llvm] r129532 - /llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp

Mon P Wang wangmp at apple.com
Thu Apr 14 12:20:42 PDT 2011


Author: wangmp
Date: Thu Apr 14 14:20:42 2011
New Revision: 129532

URL: http://llvm.org/viewvc/llvm-project?rev=129532&view=rev
Log:
Cleanup r129509 based on comments by Chris

Modified:
    llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=129532&r1=129531&r2=129532&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Thu Apr 14 14:20:42 2011
@@ -682,24 +682,23 @@
 static Value *CreateShuffleVectorCast(Value *FromVal, const Type *ToType,
                                       IRBuilder<> &Builder) {
   const Type *FromType = FromVal->getType();
-  const VectorType *FromVTy = dyn_cast<VectorType>(FromType);
-  const VectorType *ToVTy = dyn_cast<VectorType>(ToType);
-  assert(FromVTy && ToVTy &&
-         (ToVTy->getElementType() == FromVTy->getElementType()) &&
+  const VectorType *FromVTy = cast<VectorType>(FromType);
+  const VectorType *ToVTy = cast<VectorType>(ToType);
+  assert((ToVTy->getElementType() == FromVTy->getElementType()) &&
          "Vectors must have the same element type");
-   LLVMContext &Context = FromVal->getContext();
    Value *UnV = UndefValue::get(FromType);
    unsigned numEltsFrom = FromVTy->getNumElements();
    unsigned numEltsTo = ToVTy->getNumElements();
 
    SmallVector<Constant*, 3> Args;
+   const Type* Int32Ty = Builder.getInt32Ty();
    unsigned minNumElts = std::min(numEltsFrom, numEltsTo);
    unsigned i;
    for (i=0; i != minNumElts; ++i)
-     Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), i));
+     Args.push_back(ConstantInt::get(Int32Ty, i));
 
    if (i < numEltsTo) {
-     Constant* UnC = UndefValue::get(Type::getInt32Ty(Context));
+     Constant* UnC = UndefValue::get(Int32Ty);
      for (; i != numEltsTo; ++i)
        Args.push_back(UnC);
    }





More information about the llvm-commits mailing list