mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
Sema: remove incorrect safety check for saturating left shift
This commit is contained in:
parent
135a34c963
commit
6ec275ebd8
@ -13677,7 +13677,7 @@ fn zirShl(
|
|||||||
try sema.requireRuntimeBlock(block, src, runtime_src);
|
try sema.requireRuntimeBlock(block, src, runtime_src);
|
||||||
if (block.wantSafety()) {
|
if (block.wantSafety()) {
|
||||||
const bit_count = scalar_ty.intInfo(zcu).bits;
|
const bit_count = scalar_ty.intInfo(zcu).bits;
|
||||||
if (!std.math.isPowerOfTwo(bit_count)) {
|
if (air_tag != .shl_sat and !std.math.isPowerOfTwo(bit_count)) {
|
||||||
const bit_count_val = try pt.intValue(scalar_rhs_ty, bit_count);
|
const bit_count_val = try pt.intValue(scalar_rhs_ty, bit_count);
|
||||||
const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: {
|
const ok = if (rhs_ty.zigTypeTag(zcu) == .vector) ok: {
|
||||||
const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());
|
const bit_count_inst = Air.internedToRef((try sema.splat(rhs_ty, bit_count_val)).toIntern());
|
||||||
|
|||||||
@ -170,8 +170,6 @@ test "Saturating Shift Left" {
|
|||||||
|
|
||||||
const S = struct {
|
const S = struct {
|
||||||
fn shlSat(x: anytype, y: std.math.Log2Int(@TypeOf(x))) @TypeOf(x) {
|
fn shlSat(x: anytype, y: std.math.Log2Int(@TypeOf(x))) @TypeOf(x) {
|
||||||
// workaround https://github.com/ziglang/zig/issues/23033
|
|
||||||
@setRuntimeSafety(false);
|
|
||||||
return x <<| y;
|
return x <<| y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5473,8 +5473,6 @@ inline fn shlSaturate(comptime Type: type, lhs: Type, rhs: Type) Type {
|
|||||||
// workaround https://github.com/ziglang/zig/issues/23139
|
// workaround https://github.com/ziglang/zig/issues/23139
|
||||||
return lhs <<| @min(@abs(rhs), splat(ChangeScalar(Type, u64), imax(u64)));
|
return lhs <<| @min(@abs(rhs), splat(ChangeScalar(Type, u64), imax(u64)));
|
||||||
}
|
}
|
||||||
// workaround https://github.com/ziglang/zig/issues/23033
|
|
||||||
@setRuntimeSafety(false);
|
|
||||||
return lhs <<| @abs(rhs);
|
return lhs <<| @abs(rhs);
|
||||||
}
|
}
|
||||||
test shlSaturate {
|
test shlSaturate {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user