mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 12:59:04 +00:00
stage2-wasm: clz fix
This commit is contained in:
parent
a429d04ba9
commit
15bc2ab0a8
@ -6272,11 +6272,21 @@ fn airClz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
|
||||
|
||||
switch (wasm_bits) {
|
||||
32 => {
|
||||
try cg.emitWValue(operand);
|
||||
if (int_info.signedness == .signed) {
|
||||
const mask = ~@as(u32, 0) >> @intCast(32 - int_info.bits);
|
||||
_ = try cg.binOp(operand, .{ .imm32 = mask }, ty, .@"and");
|
||||
} else {
|
||||
try cg.emitWValue(operand);
|
||||
}
|
||||
try cg.addTag(.i32_clz);
|
||||
},
|
||||
64 => {
|
||||
try cg.emitWValue(operand);
|
||||
if (int_info.signedness == .signed) {
|
||||
const mask = ~@as(u64, 0) >> @intCast(64 - int_info.bits);
|
||||
_ = try cg.binOp(operand, .{ .imm64 = mask }, ty, .@"and");
|
||||
} else {
|
||||
try cg.emitWValue(operand);
|
||||
}
|
||||
try cg.addTag(.i64_clz);
|
||||
try cg.addTag(.i32_wrap_i64);
|
||||
},
|
||||
|
||||
@ -65,7 +65,6 @@ test "@clz" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user