1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00

[ConstantFolding] Use sdiv_ov

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

llvm-svn: 275273
This commit is contained in:
David Majnemer 2016-07-13 15:53:46 +00:00
parent af898a0a8f
commit e104185427

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 // index for this level and proceed to the next level to see if it can
// accommodate the offset. // accommodate the offset.
NewIdxs.push_back(ConstantInt::get(IntPtrTy, 0)); NewIdxs.push_back(ConstantInt::get(IntPtrTy, 0));
} else if (ElemSize.isAllOnesValue()) {
// Avoid signed overflow.
break;
} else { } else {
// The element size is non-zero divide the offset by the element // The element size is non-zero divide the offset by the element
// size (rounding down), to compute the index at this level. // 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; Offset -= NewIdx * ElemSize;
NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx)); NewIdxs.push_back(ConstantInt::get(IntPtrTy, NewIdx));
} }