aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 09fee7c..bd85b4a 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -3795,10 +3795,14 @@ Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
const Type *AllocElTy = AI.getAllocatedType();
const Type *CastElTy = PTy->getElementType();
if (!AllocElTy->isSized() || !CastElTy->isSized()) return 0;
-
+
+ unsigned AllocElTyAlign = TD->getTypeSize(AllocElTy);
+ unsigned CastElTyAlign = TD->getTypeSize(CastElTy);
+ if (CastElTyAlign < AllocElTyAlign) return 0;
+
uint64_t AllocElTySize = TD->getTypeSize(AllocElTy);
uint64_t CastElTySize = TD->getTypeSize(CastElTy);
-
+
// If the allocation is for an even multiple of the cast type size
if (CastElTySize == 0 || AllocElTySize % CastElTySize != 0)
return 0;