diff --git a/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp b/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp --- a/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp +++ b/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp @@ -44,11 +44,13 @@ multiplier = static_cast(shiftedM); - // Shifting tops out at 63 bits. Right shift to make 63 bits the max. - if (shift > 63) { + // Shifting tops out at 62 bits. Right shift to make 62 bits the max. + // The limit of 62 on shift allows the shift to be decomposed as + // two right shifts of 31. + if (shift > 62) { // Shifting the multiplier by more than 31-bits is unnecessary. - multiplier = multiplier >> std::min(31, shift - 63); - shift = 63; + multiplier = multiplier >> std::min(31, shift - 62); + shift = 62; } } @@ -79,11 +81,13 @@ multiplier = static_cast(shiftedM); - // Shifting tops out at 63 bits. Right shift to make 63 bits the max. - if (shift > 63) { + // Shifting tops out at 62 bits. Right shift to make 62 bits the max. + // The limit of 62 on shift allows the shift to be decomposed as + // two right shifts of 31. + if (shift > 62) { // Shifting the multiplier by more than 32-bits is unnecessary. - multiplier = multiplier >> std::min(31, shift - 63); - shift = 63; + multiplier = multiplier >> std::min(31, shift - 62); + shift = 62; } }