Don't attempt to divide INT_MIN by -1; consider such cases to

have overflowed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96428 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-02-17 00:41:53 +00:00
parent bd12fe8b69
commit 968cb939e5
2 changed files with 30 additions and 0 deletions

View File

@ -2112,12 +2112,16 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
Formula F = Base;
// Check that the multiplication doesn't overflow.
if (F.AM.BaseOffs == INT64_MIN && Factor == -1)
continue;
F.AM.BaseOffs = (uint64_t)Base.AM.BaseOffs * Factor;
if ((int64_t)F.AM.BaseOffs / Factor != Base.AM.BaseOffs)
continue;
// Check that multiplying with the use offset doesn't overflow.
int64_t Offset = LU.MinOffset;
if (Offset == INT64_MIN && Factor == -1)
continue;
Offset = (uint64_t)Offset * Factor;
if ((int64_t)Offset / Factor != LU.MinOffset)
continue;