summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff options
context:
space:
mode:
authorLauro Ramos Venancio <lauro.venancio@gmail.com>2007-07-31 20:13:21 +0000
committerLauro Ramos Venancio <lauro.venancio@gmail.com>2007-07-31 20:13:21 +0000
commit549e775e67a2257ada472b4bb976882edc0b6a7a (patch)
treec7d2e5f87b79ec221eb4378584f7caf0b769b683 /llvm/lib/Transforms/Scalar/InstructionCombining.cpp
parent54ec4bfa5f5fb11a21a10edbe2788fe816b40911 (diff)
downloadbcm5719-llvm-549e775e67a2257ada472b4bb976882edc0b6a7a.tar.gz
bcm5719-llvm-549e775e67a2257ada472b4bb976882edc0b6a7a.zip
Fix a bug in GetKnownAlignment of packed structs.
llvm-svn: 40649
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 06a67493750..a7e817a8e65 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -7533,11 +7533,13 @@ static unsigned GetKnownAlignment(Value *V, TargetData *TD) {
const Type *BasePtrTy = GEPI->getOperand(0)->getType();
const PointerType *PtrTy = cast<PointerType>(BasePtrTy);
- if (TD->getABITypeAlignment(PtrTy->getElementType())
- <= BaseAlignment) {
+ unsigned Align = TD->getABITypeAlignment(PtrTy->getElementType());
+ if (Align <= BaseAlignment) {
const Type *GEPTy = GEPI->getType();
const PointerType *GEPPtrTy = cast<PointerType>(GEPTy);
- return TD->getABITypeAlignment(GEPPtrTy->getElementType());
+ Align = std::min(Align, (unsigned)
+ TD->getABITypeAlignment(GEPPtrTy->getElementType()));
+ return Align;
}
return 0;
}
OpenPOWER on IntegriCloud