diff options
author | Chris Lattner <sabre@nondot.org> | 2005-10-24 06:26:18 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-10-24 06:26:18 +0000 |
commit | 18e78bb09eb04df4833f869357757fa379b13db9 (patch) | |
tree | 27d046e6ce4eb5ae0e038cd8449af4556598df1d /lib/Transforms/Scalar/InstructionCombining.cpp | |
parent | b53c2382a9a56e7dd210d6798e97b7aee4d9ac5d (diff) |
Fix a bug where we would 'promote' an allocation from one type to another
where the second has less alignment required. If we had explicit alignment
support in the IR, we could handle this case, but we can't until we do.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23960 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 09fee7cc4b..bd85b4abd5 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; |