[NFC] Assert non-zero factor before division

This is to ensure that zero denominator leads to controlled
assertion failure rather than UB.
This commit is contained in:
Max Kazantsev 2021-06-18 15:49:56 +07:00
parent 6f665cd53d
commit fa5eb22ad4
1 changed files with 1 additions and 0 deletions

View File

@ -3919,6 +3919,7 @@ void LSRInstance::GenerateICmpZeroScales(LSRUse &LU, unsigned LUIdx,
if (Base.BaseOffset == std::numeric_limits<int64_t>::min() && Factor == -1)
continue;
int64_t NewBaseOffset = (uint64_t)Base.BaseOffset * Factor;
assert(Factor != 0 && "Zero factor not expected!");
if (NewBaseOffset / Factor != Base.BaseOffset)
continue;
// If the offset will be truncated at this use, check that it is in bounds.