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 | 355ecc09f84271830a1fef121d38d4df3407a119 (patch) | |
| tree | 8bbef4e037c262c973af07cb89808d558841bc99 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp | |
| parent | ac87beb03accfa782685d54fcc6fd164934f5c70 (diff) | |
| download | bcm5719-llvm-355ecc09f84271830a1fef121d38d4df3407a119.tar.gz bcm5719-llvm-355ecc09f84271830a1fef121d38d4df3407a119.zip | |
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.
llvm-svn: 23960
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 09fee7cc4bd..bd85b4abd5d 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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; |

