Fix bug with zero sized casts
authorChris Lattner <sabre@nondot.org>
Mon, 3 Nov 2003 01:29:41 +0000 (01:29 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 3 Nov 2003 01:29:41 +0000 (01:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9667 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index bbdfda3f76bae2648546d11b3917730ab8c974c7..534ba5946e208e87fdf3909bd78d8c2210edfd06 100644 (file)
@@ -1552,7 +1552,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
         unsigned CastElTySize = TD->getTypeSize(CastElTy);
         
         // If the allocation is for an even multiple of the cast type size
-        if (AllocElTySize % CastElTySize == 0) {
+        if (CastElTySize && (AllocElTySize % CastElTySize == 0)) {
           Value *Amt = ConstantUInt::get(Type::UIntTy, 
                                          AllocElTySize/CastElTySize);
           std::string Name = AI->getName(); AI->setName("");