IR: Properly canonicalize PointerType in ConstantExpr GEPs

No additional test was needed, Other/constant-fold-gep.ll detects this
just fine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194221 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2013-11-07 22:29:42 +00:00
parent 0ab2058852
commit f9c692cfeb

View File

@ -1966,11 +1966,12 @@ static Constant *ConstantFoldGetElementPtrImpl(Constant *C,
else if (VectorType *VTy = dyn_cast<VectorType>(LastTy))
NumElements = VTy->getNumElements();
if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx0)) {
int64_t Idx0Val = CI->getSExtValue();
if (NumElements > 0 && Idx0Val >= 0 &&
(uint64_t)Idx0Val < NumElements)
IsSequentialAccessInRange = true;
if (NumElements > 0) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx0)) {
int64_t Idx0Val = CI->getSExtValue();
if (Idx0Val >= 0 && (uint64_t)Idx0Val < NumElements)
IsSequentialAccessInRange = true;
}
} else if (PointerType *PTy = dyn_cast<PointerType>(LastTy))
// Only handle pointers to sized types, not pointers to functions.
if (PTy->getElementType()->isSized())