aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2022-12-05 04:29:48 -0500
committerAndrew Kelley <andrew@ziglang.org>2022-12-06 12:15:04 -0700
commitfad2142ecf2dcfe4b73f1707559dce7e8e9fce50 (patch)
treec90aa9ac2131c68492cd0e34e0b416f641a2b7ad
parent9f4ef4de23927f724413efa6ef54c2cd08a05976 (diff)
downloadzig-fad2142ecf2dcfe4b73f1707559dce7e8e9fce50.tar.gz
zig-fad2142ecf2dcfe4b73f1707559dce7e8e9fce50.zip
zig.h: fix shift ub for a shlo by 0
-rw-r--r--lib/zig.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/zig.h b/lib/zig.h
index f827af1d5c..234ed707f7 100644
--- a/lib/zig.h
+++ b/lib/zig.h
@@ -810,7 +810,7 @@ static inline void zig_vmulo_i16(zig_u8 *ov, zig_i16 *res, int n,
\
static inline bool zig_shlo_u##w(zig_u##w *res, zig_u##w lhs, zig_u8 rhs, zig_u8 bits) { \
*res = zig_shlw_u##w(lhs, rhs, bits); \
- return (lhs & zig_maxInt_u##w << (bits - rhs)) != zig_as_u##w(0); \
+ return lhs > zig_maxInt_u##w >> rhs; \
} \
\
static inline bool zig_shlo_i##w(zig_i##w *res, zig_i##w lhs, zig_u8 rhs, zig_u8 bits) { \
@@ -1340,7 +1340,7 @@ static inline zig_i128 zig_mulw_i128(zig_i128 lhs, zig_i128 rhs, zig_u8 bits) {
static inline bool zig_shlo_u128(zig_u128 *res, zig_u128 lhs, zig_u8 rhs, zig_u8 bits) {
*res = zig_shlw_u128(lhs, rhs, bits);
- return zig_and_u128(lhs, zig_shl_u128(zig_maxInt_u128, bits - rhs)) != zig_as_u128(0, 0);
+ return zig_cmp_u128(lhs, zig_shr_u128(zig_maxInt_u128, rhs)) > zig_as_i32(0);
}
static inline bool zig_shlo_i128(zig_i128 *res, zig_i128 lhs, zig_u8 rhs, zig_u8 bits) {