aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 06a6749375..a7e817a8e6 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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;
}