| ... | ... | @@ -2666,8 +2666,8 @@ fn binOpBigInt(func: *CodeGen, lhs: WValue, rhs: WValue, ty: Type, op: Op) Inner |
| 2666 | 2666 | switch (op) { |
| 2667 | 2667 | .mul => return func.callIntrinsic("__multi3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }), |
| 2668 | 2668 | .div => switch (int_info.signedness) { |
| 2669 | | .signed => return func.callIntrinsic("__udivti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }), |
| 2670 | | .unsigned => return func.callIntrinsic("__divti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }), |
| 2669 | .signed => return func.callIntrinsic("__divti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }), |
| 2670 | .unsigned => return func.callIntrinsic("__udivti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }), |
| 2671 | 2671 | }, |
| 2672 | 2672 | .rem => switch (int_info.signedness) { |
| 2673 | 2673 | .signed => return func.callIntrinsic("__modti3", &.{ ty.toIntern(), ty.toIntern() }, ty, &.{ lhs, rhs }), |
| ... | ... | @@ -4378,7 +4378,7 @@ fn airIntcast(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4378 | 4378 | else |
| 4379 | 4379 | try func.intcast(operand, operand_ty, ty); |
| 4380 | 4380 | |
| 4381 | | return func.finishAir(inst, result, &.{}); |
| 4381 | return func.finishAir(inst, result, &.{ty_op.operand}); |
| 4382 | 4382 | } |
| 4383 | 4383 | |
| 4384 | 4384 | /// Upcasts or downcasts an integer based on the given and wanted types, |
| ... | ... | @@ -4677,10 +4677,20 @@ fn airTrunc(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 4677 | 4677 | const ty_op = func.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; |
| 4678 | 4678 | |
| 4679 | 4679 | const operand = try func.resolveInst(ty_op.operand); |
| 4680 | | const wanted_ty = ty_op.ty.toType(); |
| 4680 | const wanted_ty: Type = ty_op.ty.toType(); |
| 4681 | 4681 | const op_ty = func.typeOf(ty_op.operand); |
| 4682 | const pt = func.pt; |
| 4683 | const mod = pt.zcu; |
| 4684 | |
| 4685 | if (wanted_ty.zigTypeTag(mod) == .Vector or op_ty.zigTypeTag(mod) == .Vector) { |
| 4686 | return func.fail("TODO: trunc for vectors", .{}); |
| 4687 | } |
| 4688 | |
| 4689 | const result = if (op_ty.bitSize(pt) == wanted_ty.bitSize(pt)) |
| 4690 | func.reuseOperand(ty_op.operand, operand) |
| 4691 | else |
| 4692 | try func.trunc(operand, wanted_ty, op_ty); |
| 4682 | 4693 | |
| 4683 | | const result = try func.trunc(operand, wanted_ty, op_ty); |
| 4684 | 4694 | return func.finishAir(inst, result, &.{ty_op.operand}); |
| 4685 | 4695 | } |
| 4686 | 4696 | |