Achieve same result but use fewer lines of code.
authorDevang Patel <dpatel@apple.com>
Mon, 15 Oct 2007 15:31:35 +0000 (15:31 +0000)
committerDevang Patel <dpatel@apple.com>
Mon, 15 Oct 2007 15:31:35 +0000 (15:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42985 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 3edc86b93d25aa0da79a4b4cb60533ae49975c0d..29223daab7a8f563f22a380d006837aeabd0b63c 100644 (file)
@@ -7674,14 +7674,13 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
         unsigned Align = cast<ConstantInt>(CI.getOperand(4))->getZExtValue();
         PointerType *NewPtrTy = NULL;
         // 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 Size is 8 then use Int64Ty
+        // If Size is 4 then use Int32Ty
+        // If Size is 2 then use Int16Ty
+        // If Size is 1 then use Int8Ty
+        if (Size && Size <=8 && !(Size&(Size-1)))
+          NewPtrTy = PointerType::get(IntegerType::get(Size<<3));
+
         if (NewPtrTy) {
           Value *Src = InsertCastBefore(Instruction::BitCast, CI.getOperand(2), NewPtrTy, CI);
           Value *Dest = InsertCastBefore(Instruction::BitCast, CI.getOperand(1), NewPtrTy, CI);