From 4a34e7615a177755ed525ad924a93023b5670124 Mon Sep 17 00:00:00 2001 From: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> Date: Thu, 21 Dec 2023 10:44:59 -0800 Subject: [PATCH] Update riscv/arith.h Signed-off-by: Nicolas Brunie <82109999+nibrunieAtSi5@users.noreply.github.com> --- riscv/arith.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv/arith.h b/riscv/arith.h index 7e471b2cb6..b61b28c4e3 100644 --- a/riscv/arith.h +++ b/riscv/arith.h @@ -40,7 +40,7 @@ inline int64_t mulhsu(int64_t a, uint64_t b) { int negate = a < 0; uint64_t res = mulhu(a < 0 ? -(uint64_t)a : a, b); - return negate ? ~res + (a * b == 0) : res; + return negate ? ~res + ((uint64_t)a * b == 0) : res; } //ref: https://locklessinc.com/articles/sat_arithmetic/