Skip to content

Commit 4d5fdb0

Browse files
committed
Use unsigned shifts instead of signed shifts
1 parent 0ba9493 commit 4d5fdb0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

simulator/mips/mips_instr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ T align_up(T value) { return ((value + ((1ull << N) - 1)) >> N) << N; }
2626
template<typename T>
2727
auto mips_multiplication(T x, T y) {
2828
using T2 = doubled_t<T>;
29+
using UT2 = unsign_t<T2>;
2930
using ReturnType = std::pair<unsign_t<T>, unsign_t<T>>;
30-
auto value = static_cast<T2>(x) * static_cast<T2>(y);
31+
auto value = static_cast<UT2>(static_cast<T2>(x) * static_cast<T2>(y));
3132
return ReturnType(value, value >> bitwidth<T>);
3233
}
3334

@@ -37,8 +38,7 @@ auto mips_division(T x, T y) {
3738
if ( y == 0)
3839
return ReturnType();
3940

40-
// NOLINTNEXTLINE(misc-suspicious-semicolon)
41-
if constexpr( !std::is_same_v<T, unsign_t<T>>) // signed type
41+
if constexpr( !std::is_same_v<T, unsign_t<T>>) // signed type NOLINTNEXTLINE(misc-suspicious-semicolon)
4242
if ( y == -1 && x == static_cast<T>(msb_set<unsign_t<T>>())) // x86 has an exception here
4343
return ReturnType();
4444

0 commit comments

Comments
 (0)