Fix bug test/Regression/Transforms/LevelRaise/2002-03-21-MissedRaise3.ll
[oota-llvm.git] / lib / Transforms / ExprTypeConvert.cpp
index 5d6f8d298ddc63810a2f38cf4458f5bb46011407..cd76bdbf1f39999311da5b5a17e1f0e0555f197d 100644 (file)
@@ -57,8 +57,7 @@ static bool AllIndicesZero(const MemAccessInst *MAI) {
 //
 static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
                                     ValueTypeCache &CTMap) {
-  if (!MI->isArrayAllocation() ||            // No array allocation?
-      !isa<PointerType>(Ty)) return false;   // Malloc always returns pointers
+  if (!isa<PointerType>(Ty)) return false;   // Malloc always returns pointers
 
   // Deal with the type to allocate, not the pointer type...
   Ty = cast<PointerType>(Ty)->getElementType();
@@ -72,7 +71,7 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
   unsigned OldTypeSize = TD.getTypeSize(MI->getType()->getElementType());
 
   // Must have a scale or offset to analyze it...
-  if (!Expr.Offset && !Expr.Scale) return false;
+  if (!Expr.Offset && !Expr.Scale && OldTypeSize == 1) return false;
 
   // Get the offset and scale of the allocation...
   int OffsetVal = Expr.Offset ? getConstantValue(Expr.Offset) : 0;