Fix a bug from r1.391 of this file, where we checked the size instead of
authorChris Lattner <sabre@nondot.org>
Sun, 1 Oct 2006 19:40:58 +0000 (19:40 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 1 Oct 2006 19:40:58 +0000 (19:40 +0000)
the alignment when promoting allocations.  This implements
InstCombine/cast.ll:test32

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30682 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index 19051fa2e15a6ee296c3a791670e1f9f444af7b0..9bfd66afb2905a94966003b27c3e6848fd7f608b 100644 (file)
@@ -5053,8 +5053,8 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
   const Type *CastElTy = PTy->getElementType();
   if (!AllocElTy->isSized() || !CastElTy->isSized()) return 0;
 
-  unsigned AllocElTyAlign = TD->getTypeSize(AllocElTy);
-  unsigned CastElTyAlign = TD->getTypeSize(CastElTy);
+  unsigned AllocElTyAlign = TD->getTypeAlignment(AllocElTy);
+  unsigned CastElTyAlign = TD->getTypeAlignment(CastElTy);
   if (CastElTyAlign < AllocElTyAlign) return 0;
 
   // If the allocation has multiple uses, only promote it if we are strictly