File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -6272,11 +6272,21 @@ fn airClz(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void {
6272
6272
6273
6273
switch (wasm_bits ) {
6274
6274
32 = > {
6275
- try cg .emitWValue (operand );
6275
+ if (int_info .signedness == .signed ) {
6276
+ const mask = ~ @as (u32 , 0 ) >> @intCast (32 - int_info .bits );
6277
+ _ = try cg .binOp (operand , .{ .imm32 = mask }, ty , .@"and" );
6278
+ } else {
6279
+ try cg .emitWValue (operand );
6280
+ }
6276
6281
try cg .addTag (.i32_clz );
6277
6282
},
6278
6283
64 = > {
6279
- try cg .emitWValue (operand );
6284
+ if (int_info .signedness == .signed ) {
6285
+ const mask = ~ @as (u64 , 0 ) >> @intCast (64 - int_info .bits );
6286
+ _ = try cg .binOp (operand , .{ .imm64 = mask }, ty , .@"and" );
6287
+ } else {
6288
+ try cg .emitWValue (operand );
6289
+ }
6280
6290
try cg .addTag (.i64_clz );
6281
6291
try cg .addTag (.i32_wrap_i64 );
6282
6292
},
Original file line number Diff line number Diff line change @@ -65,7 +65,6 @@ test "@clz" {
65
65
if (builtin .zig_backend == .stage2_aarch64 ) return error .SkipZigTest ; // TODO
66
66
if (builtin .zig_backend == .stage2_arm ) return error .SkipZigTest ; // TODO
67
67
if (builtin .zig_backend == .stage2_sparc64 ) return error .SkipZigTest ; // TODO
68
- if (builtin .zig_backend == .stage2_wasm ) return error .SkipZigTest ; // TODO
69
68
if (builtin .zig_backend == .stage2_x86_64 and builtin .target .ofmt != .elf and builtin .target .ofmt != .macho ) return error .SkipZigTest ;
70
69
if (builtin .zig_backend == .stage2_spirv64 ) return error .SkipZigTest ;
71
70
You can’t perform that action at this time.
0 commit comments