Skip to content

Commit 6ec275e

Browse files
Justus2308mlugg
authored andcommitted
Sema: remove incorrect safety check for saturating left shift
1 parent 135a34c commit 6ec275e

File tree

3 files changed

+1
-5
lines changed

3 files changed

+1
-5
lines changed

src/Sema.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}
54805478
test shlSaturate {

0 commit comments

Comments
 (0)