[llvm-commits] [llvm] r42930 - /llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Devang Patel dpatel at apple.com
Fri Oct 12 13:10:21 PDT 2007


Author: dpatel
Date: Fri Oct 12 15:10:21 2007
New Revision: 42930

URL: http://llvm.org/viewvc/llvm-project?rev=42930&view=rev
Log:
Dest type is always i8 *. This allows some simplification.
Do not filter memmove.


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

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=42930&r1=42929&r2=42930&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri Oct 12 15:10:21 2007
@@ -7669,43 +7669,22 @@
       // If MemCpyInst length is 1/2/4/8 bytes then replace memcpy with
       // load/store.
       ConstantInt *MemOpLength = dyn_cast<ConstantInt>(CI.getOperand(3));
-      if (isa<MemCpyInst>(MI))
-        if (MemOpLength) {
+      if (MemOpLength) {
         unsigned Size = MemOpLength->getZExtValue();
         unsigned Align = cast<ConstantInt>(CI.getOperand(4))->getZExtValue();
-        const PointerType *PTy = cast<PointerType>(CI.getOperand(1)->getType());
-        const Type *MTy = PTy->getElementType();
         PointerType *NewPtrTy = NULL;
-        if (MTy == Type::Int8Ty) {
-          if (Size == 8)
-            NewPtrTy = PointerType::get(Type::Int64Ty);
-          else if (Size == 4)
-            NewPtrTy = PointerType::get(Type::Int32Ty);
-          else if (Size == 2)
-            NewPtrTy = PointerType::get(Type::Int16Ty);
-          else if (Size == 1)
-            NewPtrTy = PointerType::get(Type::Int8Ty);
-        } else if (MTy == Type::Int16Ty) {
-          if (Size == 4)
-            NewPtrTy = PointerType::get(Type::Int64Ty);
-          else if (Size == 2)
-            NewPtrTy = PointerType::get(Type::Int32Ty);
-          else if (Size == 1)
-            NewPtrTy = PointerType::get(Type::Int16Ty);
-        } else if (MTy == Type::Int32Ty) {
-          if (Size == 2)
-            NewPtrTy = PointerType::get(Type::Int64Ty);
-          else if (Size == 1)
-            NewPtrTy = PointerType::get(Type::Int32Ty);
-        } else if (MTy == Type::Int64Ty) {
-          if (Size == 1)
-            NewPtrTy = PointerType::get(Type::Int64Ty);
-        }
+        // Destination pointer type is always i8 *
+        if (Size == 8)
+          NewPtrTy = PointerType::get(Type::Int64Ty);
+        else if (Size == 4)
+          NewPtrTy = PointerType::get(Type::Int32Ty);
+        else if (Size == 2)
+          NewPtrTy = PointerType::get(Type::Int16Ty);
+        else if (Size == 1)
+          NewPtrTy = PointerType::get(Type::Int8Ty);
         if (NewPtrTy) {
-          Value *Src =
-            InsertCastBefore(Instruction::BitCast,CI.getOperand(2),NewPtrTy,CI);
-          Value *Dest = 
-            InsertCastBefore(Instruction::BitCast,CI.getOperand(1),NewPtrTy,CI);
+          Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2), NewPtrTy, CI);
+          Value *Dest = InsertCastBefore(Instruction::BitCast, CI.getOperand(1), NewPtrTy, CI);
           Value *L = new LoadInst(Src, "tmp", false, Align, &CI);
           Value *NS = new StoreInst(L, Dest, false, Align, &CI);
           CI.replaceAllUsesWith(NS);





More information about the llvm-commits mailing list