[ConstantFolding] Use sdiv_ov

This is a simplification, there should be no functional change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Majnemer 2016-07-13 15:53:46 +00:00
parent 15e94506a9
commit 549def0571

View File

@ -850,13 +850,13 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
// index for this level and proceed to the next level to see if it can
// accommodate the offset.
NewIdxs.push_back(ConstantInt::get(IntPtrTy, 0));
} else if (ElemSize.isAllOnesValue()) {
// Avoid signed overflow.
break;
} else {
// The element size is non-zero divide the offset by the element
// size (rounding down), to compute the index at this level.
APInt NewIdx = Offset.sdiv(ElemSize);
bool Overflow;
APInt NewIdx = Offset.sdiv_ov(ElemSize, Overflow);
if (Overflow)
break;
Offset -= NewIdx * ElemSize;
NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));
}