| ... | @@ -6973,9 +6973,20 @@ fn airShlSat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { | ... | @@ -6973,9 +6973,20 @@ fn airShlSat(cg: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 6973 | return cg.fail("TODO: Saturating shifting left for integers with bitsize '{d}'", .{int_info.bits}); | 6973 | return cg.fail("TODO: Saturating shifting left for integers with bitsize '{d}'", .{int_info.bits}); |
| 6974 | } | 6974 | } |
| 6975 | | 6975 | |
| 6976 | const lhs = try cg.resolveInst(bin_op.lhs); | | |
| 6977 | const rhs = try cg.resolveInst(bin_op.rhs); | | |
| 6978 | const wasm_bits = toWasmBits(int_info.bits).?; | 6976 | const wasm_bits = toWasmBits(int_info.bits).?; |
| | 6977 | |
| | 6978 | const lhs = try cg.resolveInst(bin_op.lhs); |
| | 6979 | const rhs = rhs: { |
| | 6980 | const rhs = try cg.resolveInst(bin_op.rhs); |
| | 6981 | const rhs_ty = cg.typeOf(bin_op.rhs); |
| | 6982 | // The type of `rhs` is the log2 int of the type of `lhs`, but WASM wants the lhs and rhs types to match. |
| | 6983 | if (toWasmBits(@intCast(rhs_ty.bitSize(zcu))).? == wasm_bits) { |
| | 6984 | break :rhs rhs; // the WASM types match, so no cast necessary |
| | 6985 | } |
| | 6986 | const casted = try cg.intcast(rhs, rhs_ty, ty); |
| | 6987 | break :rhs try casted.toLocal(cg, ty); |
| | 6988 | }; |
| | 6989 | |
| 6979 | const result = try cg.allocLocal(ty); | 6990 | const result = try cg.allocLocal(ty); |
| 6980 | | 6991 | |
| 6981 | if (wasm_bits == int_info.bits) { | 6992 | if (wasm_bits == int_info.bits) { |