authorgravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2025-07-11 03:40:30+02:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-07-30 10:15:48+01:00
log6ec275ebd8fce2e816f3f66e0fec5e53669b96c1
treea85c56f7a86c011e0e109f99ef8e56f67de0073f
parent135a34c9631254d43b37be6c7b41d56669960669

Sema: remove incorrect safety check for saturating left shift


3 files changed, 1 insertions(+), 5 deletions(-)

src/Sema.zig+1-1
......@@ -13677,7 +13677,7 @@ fn zirShl(
1367713677 try sema.requireRuntimeBlock(block, src, runtime_src);
1367813678 if (block.wantSafety()) {
1367913679 const bit_count = scalar_ty.intInfo(zcu).bits;
13680 if (!std.math.isPowerOfTwo(bit_count)) {
13680 if (air_tag != .shl_sat and !std.math.isPowerOfTwo(bit_count)) {
1368113681 const bit_count_val = try pt.intValue(scalar_rhs_ty, bit_count);
1368213682 const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: {
1368313683 const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());
test/behavior/bit_shifting.zig-2
......@@ -170,8 +170,6 @@ test "Saturating Shift Left" {
170170
171171 const S = struct {
172172 fn shlSat(x: anytype, y: std.math.Log2Int(@TypeOf(x))) @TypeOf(x) {
173 // workaround https://github.com/ziglang/zig/issues/23033
174 @setRuntimeSafety(false);
175173 return x <<| y;
176174 }
177175
test/behavior/x86_64/binary.zig-2
......@@ -5473,8 +5473,6 @@ inline fn shlSaturate(comptime Type: type, lhs: Type, rhs: Type) Type {
54735473 // workaround https://github.com/ziglang/zig/issues/23139
54745474 return lhs <<| @min(@abs(rhs), splat(ChangeScalar(Type, u64), imax(u64)));
54755475 }
5476 // workaround https://github.com/ziglang/zig/issues/23033
5477 @setRuntimeSafety(false);
54785476 return lhs <<| @abs(rhs);
54795477}
54805478test shlSaturate {